/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background-color: var(--bg-page);
}

/* ===== CSS Variables ===== */
:root {
    --bg-page: #f5f5f5;
    --bg-container: #ffffff;
    --bg-container-hover: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --link-color: #1a73e8;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 2px 8px rgba(0, 0, 0, 0.2);
    --tag-bg: #e8f0fe;
    --tag-color: #1a73e8;
    --btn-deeplink-bg: #5865f2;
    --btn-deeplink-active: #4752c4;
    --btn-original-bg: #03c75a;
    --btn-original-active: #02b050;
    --btn-text-color: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #121212;
        --bg-container: #1e1e1e;
        --bg-container-hover: #2a2a2a;
        --text-primary: #e0e0e0;
        --text-secondary: #aaaaaa;
        --text-muted: #777777;
        --border-color: #333333;
        --link-color: #6ea8fe;
        --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-strong: 0 2px 8px rgba(0, 0, 0, 0.5);
        --tag-bg: rgba(110, 168, 254, 0.15);
        --tag-color: #6ea8fe;
        --btn-deeplink-bg: #6b7cff;
        --btn-deeplink-active: #5b69da;
        --btn-original-bg: #16a34a;
        --btn-original-active: #15803d;
        --btn-text-color: #f8fafc;
    }
}

/* ===== Base Typography ===== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: calc(48px + env(safe-area-inset-top)) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a {
    color: var(--link-color);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Fixed Header ===== */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    background-color: var(--bg-container);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.back-btn:active {
    background-color: var(--bg-container-hover);
}

.fixed-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 120px);
}

/* ===== Article Common Styles ===== */
.article-container {
    background-color: var(--bg-container);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .article-container {
        border-radius: 0;
        padding: 20px;
        box-shadow: none;
    }
}

.article-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.article-title {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 15px 0;
    color: var(--text-primary);
}

.article-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.article-title-row .article-title {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.article-meta {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.article-meta-footer {
    margin-top: 24px;
    justify-content: flex-end;
}

.article-author {
    font-weight: 500;
    color: var(--link-color);
    text-decoration: none;
}

.article-author:hover {
    text-decoration: underline;
}

.article-content {
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content img {
    max-width: 100%;
    height: auto;
}

/* ===== Tags ===== */
.tag {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--tag-color);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ===== Floating Buttons ===== */
.floating-buttons {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    max-width: 800px;
    width: calc(100% - 40px);
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.floating-btn {
    flex: 1;
    padding: 14px 0;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: block;
    box-shadow: var(--shadow-strong);
    color: var(--btn-text-color);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.floating-btn:disabled {
    cursor: default;
}

.floating-split {
    flex: 1;
    display: flex;
    min-width: 0;
    position: relative;
}

.floating-split .floating-btn {
    box-shadow: none;
}

.floating-split-main {
    flex: 1;
    border-radius: 8px 0 0 8px;
}

.floating-split-toggle {
    flex: 0 0 48px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 0 8px 8px 0;
    padding: 0;
}

.floating-split-toggle svg {
    display: block;
    margin: 0 auto;
}

.floating-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 160px;
    padding: 6px;
    border-radius: 12px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-strong);
    display: none;
    flex-direction: column;
    gap: 4px;
}

.floating-menu.open {
    display: flex;
}

.floating-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.floating-menu-item.active,
.floating-menu-item:hover {
    background: var(--bg-container-hover);
}

.btn-deeplink {
    background-color: var(--btn-deeplink-bg);
}

.btn-deeplink:active {
    background-color: var(--btn-deeplink-active);
}

.btn-original {
    background-color: var(--btn-original-bg);
}

.btn-original:active {
    background-color: var(--btn-original-active);
}

/* ===== Address ===== */
.address {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.address:empty {
    display: none;
}

/* ===== Article Info ===== */
.article-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.article-info:empty {
    display: none;
}

.article-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.article-info-row-strong {
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-container-hover);
}

.article-info-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
}

.article-info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.article-tag-row {
    margin-top: 2px;
}

.article-author-row {
    margin-top: 4px;
}

.article-author-row .article-author {
    color: var(--text-primary);
    text-decoration: none;
}

/* ===== Common Navigation ===== */
.menu-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(14px);
}

.menu-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.menu-icon {
    width: 16px;
    height: 12px;
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
}

.menu-icon span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 260;
    background: rgba(6, 12, 18, 0.72);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.nav-overlay.open {
    opacity: 1;
    visibility: visible;
}

.nav-panel {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(360px, calc(100% - 28px));
    overflow: auto;
    border-radius: 0 18px 18px 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-left: 0;
    background: linear-gradient(140deg, rgba(19, 33, 42, 0.95), rgba(11, 19, 25, 0.95));
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.35);
    padding: calc(12px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    transform: translateX(-100%);
    transition: transform 0.24s ease;
}

.nav-overlay.open .nav-panel {
    transform: translateX(0);
}

.nav-panel-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.nav-panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.nav-close-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.88);
    border-radius: 10px;
    min-height: 36px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-item {
    display: grid;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    text-decoration: none;
    color: #fff;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(12, 19, 25, 0.42);
    font-size: 14px;
    font-weight: 700;
}

.nav-link-toggle {
    width: 100%;
    cursor: pointer;
}

.nav-link-label {
    min-width: 0;
    flex: 1;
}

.nav-link-label-wrap {
    min-width: 0;
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-link-chevron {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item.expanded .nav-link-chevron {
    transform: rotate(180deg);
    color: #67d6ff;
}

.nav-link-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #ff6b6b;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.28);
    flex-shrink: 0;
}

.nav-link.active {
    border-color: rgba(56, 189, 248, 0.48);
    background: rgba(56, 189, 248, 0.16);
    color: #67d6ff;
}

.nav-link.active .nav-link-badge {
    background: #38bdf8;
    color: #082032;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.25);
}

.nav-submenu {
    display: grid;
    gap: 8px;
    margin-top: -2px;
    padding: 4px 0 2px 12px;
}

.nav-submenu-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.86);
    padding: 10px 12px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    font-size: 13px;
    font-weight: 600;
}

.nav-submenu-link.active,
.nav-submenu-link:hover {
    color: #67d6ff;
    border-color: rgba(56, 189, 248, 0.36);
    background: rgba(56, 189, 248, 0.12);
}

.nav-submenu-link-hub {
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    letter-spacing: 0.01em;
}

body.nav-open {
    overflow: hidden;
}

.common-desktop-nav {
    display: none;
}

@media (min-width: 1024px) {
    .menu-toggle-btn {
        display: none;
    }

    .nav-overlay {
        display: none !important;
    }

    .header-inner.common-nav-ready {
        max-width: min(1280px, calc(100vw - 48px)) !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
        justify-content: flex-start !important;
    }

    .header-inner.common-nav-ready > h1 {
        position: relative;
        z-index: 1;
        flex: 0 1 auto;
        max-width: min(280px, 24vw);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        text-align: left;
        margin-right: auto;
    }

    .header-inner.common-nav-ready > .header-actions,
    .header-inner.common-nav-ready > .header-menu {
        display: none !important;
    }

    .common-desktop-nav {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: min(760px, calc(100% - 320px));
        display: flex;
        justify-content: center;
        z-index: 2;
    }

    .common-desktop-nav-list {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 4px 8px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 999px;
        background: rgba(7, 14, 20, 0.38);
        backdrop-filter: blur(18px);
        box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
    }

    .common-desktop-nav-item {
        position: relative;
        display: flex;
    }

    .common-desktop-nav-item.has-children::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        height: 18px;
    }

    .common-desktop-nav-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 36px;
        padding: 0 14px;
        border-radius: 999px;
        text-decoration: none;
        color: rgba(255, 255, 255, 0.78);
        font-size: 13px;
        font-weight: 600;
        letter-spacing: -0.01em;
        transition: color 0.18s ease, background-color 0.18s ease;
    }

    .common-desktop-nav-link:hover,
    .common-desktop-nav-link.active,
    .common-desktop-nav-item.open > .common-desktop-nav-link {
        color: #fff;
        background: rgba(255, 255, 255, 0.1);
    }

    .common-desktop-nav-link.active {
        color: #8be1ff;
        background: rgba(56, 189, 248, 0.14);
    }

    .common-desktop-nav-link .nav-link-badge {
        min-width: 18px;
        height: 18px;
        padding: 0 6px;
        font-size: 11px;
        box-shadow: none;
    }

    .common-desktop-submenu {
        position: absolute;
        top: calc(100% + 8px);
        left: 50%;
        transform: translate(-50%, -6px);
        min-width: 220px;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    }

    .common-desktop-nav-item.open > .common-desktop-submenu {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, 0);
        pointer-events: auto;
    }

    .common-desktop-submenu-list {
        display: grid;
        gap: 4px;
        padding: 8px;
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        background: rgba(8, 15, 22, 0.92);
        backdrop-filter: blur(22px);
        box-shadow: 0 26px 54px rgba(0, 0, 0, 0.34);
    }

    .common-desktop-submenu-link {
        display: flex;
        align-items: center;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 12px;
        text-decoration: none;
        color: rgba(255, 255, 255, 0.78);
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
    }

    .common-desktop-submenu-link:hover,
    .common-desktop-submenu-link.active {
        color: #fff;
        background: rgba(255, 255, 255, 0.08);
    }

    .common-desktop-submenu-link.active {
        color: #8be1ff;
        background: rgba(56, 189, 248, 0.14);
    }
}

/* ===== Wide Header Controls ===== */
@media (min-width: 1024px) {
    .header-inner {
        max-width: none !important;
    }
}

/* ===== LaraLife App ===== */
body.laralife .fixed-header,
body.laralife .floating-buttons {
    display: none !important;
}

body.laralife {
    padding-top: env(safe-area-inset-top);
}
