:root {
    color-scheme: light;
    --page-bg: #f6f7f8;
    --surface: #fff;
    --ink: #202326;
    --muted: #737980;
    --accent: #777e85;
    --accent-dark: #34393e;
    --line: #e8eaec;
    --shadow: 0 18px 52px rgba(26, 31, 36, 0.055);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    scroll-padding-top: 6rem;
}

body.article-page,
body.portal-page {
    min-height: 100vh;
    margin: 0;
    background: var(--page-bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
        "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.75;
}

a {
    color: var(--accent-dark);
    text-underline-offset: 0.18em;
}

a:hover {
    color: #17191b;
}

button,
textarea {
    font: inherit;
}

.site-nav {
    position: sticky;
    z-index: 30;
    top: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 4px 20px rgba(24, 28, 32, 0.035);
    backdrop-filter: blur(16px);
}

.nav-inner {
    position: relative;
    display: flex;
    width: min(100% - 2.5rem, 1120px);
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto;
}

.brand-logo {
    position: absolute;
    left: 50%;
    display: inline-flex;
    align-items: center;
    color: var(--ink);
    font-size: 1.2rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-decoration: none;
    transform: translateX(-50%);
    white-space: nowrap;
}

.brand-logo .nav-icon {
    margin-right: 0.45rem;
}

.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.desktop-nav .nav-icon,
.drawer-link .nav-icon {
    width: 1.1rem;
    height: 1.1rem;
}

.invisible-takeoff-link {
    position: absolute;
    z-index: 1;
    top: 10px;
    right: 0;
    display: block;
    width: 44px;
    height: 44px;
    overflow: hidden;
    opacity: 0;
    white-space: nowrap;
}

.desktop-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 48px 0 auto;
    padding: 0;
    list-style: none;
}

.desktop-nav a {
    display: flex;
    height: 44px;
    align-items: center;
    gap: 0.45rem;
    padding: 0 0.8rem;
    border-radius: 9px;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 550;
    text-decoration: none;
    transition: background-color 160ms ease;
}

.desktop-nav a:hover {
    background: #f3f4f5;
    color: var(--ink);
}

.drawer-trigger {
    display: none;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.drawer-trigger:hover,
.drawer-trigger:focus-visible {
    background: #f1f2f3;
}

.menu-icon {
    width: 21px;
    height: 15px;
    background: linear-gradient(currentColor 0 0) top / 100% 2px no-repeat,
        linear-gradient(currentColor 0 0) center / 100% 2px no-repeat,
        linear-gradient(currentColor 0 0) bottom / 100% 2px no-repeat;
}

.drawer-backdrop[hidden] {
    display: none;
}

.drawer-backdrop {
    position: fixed;
    z-index: 49;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(20, 23, 26, 0.32);
    cursor: default;
    animation: backdrop-in 180ms ease both;
}

.mobile-drawer {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    display: flex;
    width: min(84vw, 340px);
    flex-direction: column;
    gap: 0.35rem;
    padding: 5.5rem 1rem 1rem;
    border-right: 1px solid var(--line);
    background: #fff;
    box-shadow: 12px 0 36px rgba(24, 28, 32, 0.1);
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 220ms ease, visibility 220ms ease;
    will-change: transform;
}

.mobile-drawer.is-open {
    visibility: visible;
    transform: translateX(0);
}

.drawer-link {
    display: flex;
    min-height: 50px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    color: var(--ink);
    font-weight: 550;
    text-decoration: none;
}

.drawer-link:hover,
.drawer-link:focus-visible {
    background: #f3f4f5;
    color: var(--accent-dark);
}

.drawer-open {
    overflow: hidden;
}

.page-container {
    width: min(100% - 2.5rem, 920px);
    margin: 2rem auto;
    padding: clamp(1.5rem, 5vw, 3.75rem);
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.article-page .page-container {
    margin-top: clamp(2rem, 6vw, 4.5rem);
    margin-bottom: 4rem;
}

.article-page .page-container > h5 {
    max-width: 760px;
    margin: 0 auto 1.75rem;
    color: var(--ink);
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    font-weight: 700;
    line-height: 1.38;
    letter-spacing: -0.035em;
    text-wrap: pretty;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, #d9dcdf, rgba(217, 220, 223, 0.1));
}

.image-responsive {
    display: block;
    max-width: 100%;
    height: auto;
}

.article-page .image-responsive {
    width: 100%;
    margin: 2rem auto 2.5rem;
    border: 1px solid #eff0f1;
    border-radius: 16px;
    background: #f8f8f8;
}

.article-page p {
    max-width: 760px;
    margin: 0 auto 1.4rem;
    color: #41464b;
    font-size: 1.05rem;
    line-height: 2;
    overflow-wrap: anywhere;
}

.tab-bar {
    border-top: 1px solid var(--line);
}

.tab-list {
    display: flex;
    width: min(100% - 2.5rem, 1120px);
    min-height: 48px;
    align-items: stretch;
    gap: 0.35rem;
    margin: 0 auto;
    padding: 0;
    overflow-x: auto;
    list-style: none;
    scrollbar-width: thin;
}

.tab-list li {
    flex: 0 0 auto;
}

.tab-link {
    position: relative;
    display: flex;
    min-height: 48px;
    align-items: center;
    padding: 0 1.1rem;
    color: #62676b;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
    transition: color 160ms ease, background-color 160ms ease;
}

.tab-link:hover,
.tab-link[aria-selected="true"] {
    background: #f7f8f8;
    color: #202326;
}

.tab-link[aria-selected="true"]::after {
    position: absolute;
    right: 1rem;
    bottom: 0;
    left: 1rem;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: #34393e;
    content: "";
}

.tab-panel[hidden] {
    display: none;
}

.portal-page .page-container {
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding: clamp(1.5rem, 4vw, 2.75rem);
}

#attention .page-container {
    border-color: var(--line);
    background: #fff;
}

#attention p {
    margin: 0.25rem 0 0.85rem;
}

#attention p:last-child {
    margin-bottom: 0;
}

#log h4 {
    margin: 0 0 1.75rem;
    padding: 1.25rem 1.4rem;
    border: 1px solid var(--line);
    border-left: 3px solid #aeb2b6;
    border-radius: 12px;
    background: #fafafa;
    color: #303438;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    line-height: 1.8;
}

#log h4 a {
    display: inline-block;
    margin-top: 0.3rem;
}

#log .divider {
    margin: 1.5rem 0;
    background: var(--line);
}

#log ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#log li {
    padding: 0.85rem 0 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
    color: #4b5054;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

#log li.log-highlight {
    margin-bottom: 0.75rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid #dfe2e4;
    border-left: 4px solid #60686f;
    border-radius: 12px;
    background: #f3f5f6;
    box-shadow: 0 5px 16px rgba(26, 31, 36, 0.06);
    color: #202326;
    font-size: clamp(1.05rem, 2.4vw, 1.2rem);
    font-weight: 700;
    line-height: 1.8;
}

#log li.log-highlight + li {
    border-top: 1px solid var(--line);
}

#client h5 {
    margin-top: 0;
    color: #303438;
    font-size: clamp(1.25rem, 3vw, 1.65rem);
    line-height: 1.6;
}

#client a {
    font-weight: 600;
}

#server label {
    display: block;
    width: min(100%, 520px);
    margin-inline: auto;
    color: #4b5054;
    font-size: 1rem;
}

.subscription-input {
    display: block;
    width: min(100%, 520px);
    min-height: 6rem;
    margin: 0.5rem auto 1.5rem;
    padding: 0.85rem 1rem;
    border: 1px solid #d9dcde;
    border-radius: 12px;
    background: #fafafa;
    color: #33383c;
    font: 0.9rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    resize: vertical;
}

.subscription-actions {
    display: flex;
    width: min(100%, 520px);
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.6rem 0.85rem;
    margin: -0.75rem auto 1.5rem;
}

.copy-link-button {
    min-height: 42px;
    padding: 0.55rem 1rem;
    border: 1px solid #303438;
    border-radius: 10px;
    background: #303438;
    color: #fff;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background-color 160ms ease, transform 160ms ease;
}

.copy-link-button:hover:not(:disabled) {
    transform: translateY(-1px);
    background: #111315;
}

.copy-link-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.copy-link-status {
    color: var(--accent-dark);
    font-size: 0.9rem;
}

.qr-container > div {
    width: min(100%, 360px);
    margin-inline: auto;
}

.qr-container .image-responsive {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible {
    outline: 3px solid #858b90;
    outline-offset: 3px;
}

@keyframes backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 992px) {
    .drawer-trigger {
        display: inline-flex;
    }

    .desktop-nav {
        display: none;
    }
}

@media (max-width: 600px) {
    body.article-page,
    body.portal-page {
        font-size: 15px;
    }

    .nav-inner {
        width: min(100% - 1.5rem, 1120px);
        min-height: 60px;
    }

    .brand-logo {
        font-size: 1.1rem;
    }

    .tab-list {
        width: 100%;
        gap: 0;
        padding: 0 0.25rem;
    }

    .page-container {
        width: min(100% - 1.25rem, 920px);
        margin: 1rem auto;
        padding: 1.25rem;
        border-radius: 16px;
    }

    .article-page .page-container {
        margin-top: 1.25rem;
        margin-bottom: 2rem;
    }

    .article-page .page-container > h5 {
        margin-bottom: 1.25rem;
        font-size: clamp(1.35rem, 6vw, 1.7rem);
        letter-spacing: -0.025em;
    }

    .article-page p {
        font-size: 1rem;
        line-height: 1.9;
    }

    .portal-page .page-container {
        margin-top: 1rem;
        margin-bottom: 1rem;
        padding: 1.25rem;
    }

    .tab-link {
        min-height: 46px;
        padding: 0 0.75rem;
        font-size: 0.82rem;
    }

    #log h4 {
        padding: 0.9rem 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
