:root {
    color-scheme: light;
    --page-max-width: 1180px;
    --page-gutter: 16px;
    --category-nav-width: 144px;
    --page-bg: #f4f4f5;
    --surface: #ffffff;
    --surface-muted: #f4f4f5;
    --border: #d4d4d8;
    --border-strong: #3f3f46;
    --text: #18181b;
    --text-soft: #52525b;
    --text-muted: #a1a1aa;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --status: #059669;
    --header-bg: rgba(255, 255, 255, .94);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

html.dark {
    color-scheme: dark;
    --page-bg: #09090b;
    --surface: #121215;
    --surface-muted: #18181b;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #f4f4f5;
    --text-soft: #a1a1aa;
    --text-muted: #71717a;
    --accent: #60a5fa;
    --accent-soft: #172554;
    --status: #34d399;
    --header-bg: rgba(9, 9, 11, .92);
}

* {
    box-sizing: border-box;
    border-radius: 0 !important;
}

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

body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.5;
    transition: background-color .2s ease, color .2s ease;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

::selection {
    background: var(--accent);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--page-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    border-bottom: 1px solid var(--border);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
}

.header-inner,
.page-shell,
.footer-inner {
    width: calc(100% - var(--page-gutter) * 2);
    max-width: var(--page-max-width);
    margin-inline: auto;
}

.full-width {
    --page-max-width: 1560px;
}

.header-inner {
    display: flex;
    min-height: 62px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
}

.brand-name {
    overflow: hidden;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-prompt,
.brand-cursor {
    color: var(--accent);
}

.brand-cursor {
    animation: blink 1s steps(2, start) infinite;
}

.brand-subtitle {
    overflow: hidden;
    border-left: 1px solid var(--border);
    padding-left: 12px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: .02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-nav,
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.desktop-nav {
    min-width: 0;
    flex: 1;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
}

.desktop-nav::-webkit-scrollbar {
    display: none;
}

.desktop-nav a,
.mobile-nav a,
.account-link {
    padding: 7px 9px;
    color: var(--text-soft);
    font-family: var(--font-sans);
    font-size: 13px;
    transition: background-color .15s ease, color .15s ease;
}

.desktop-nav a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-nav a:hover,
.mobile-nav a:hover,
.account-link:hover {
    background: var(--surface-muted);
    color: var(--accent);
}

.header-actions {
    flex-shrink: 0;
}

.theme-toggle {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    padding: 5px 8px;
    background: var(--surface-muted);
    color: var(--text-soft);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 10px;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-icon {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: square;
    stroke-linejoin: miter;
    stroke-width: 1.7;
}

.is-hidden,
[hidden] {
    display: none !important;
}

.page-shell {
    flex: 1;
    padding-block: 28px 64px;
}

.search-panel {
    margin-bottom: 22px;
}

.search-form {
    display: flex;
    gap: 8px;
}

.search-field {
    display: flex;
    min-width: 0;
    min-height: 44px;
    flex: 1;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    padding: 0 12px;
    background: var(--surface);
    transition: border-color .15s ease;
}

.search-field:focus-within {
    border-color: var(--accent);
}

.search-prompt {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 15px;
}

.search-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    padding: 10px 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
}

.search-field input::placeholder {
    color: var(--text-muted);
}

.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration {
    display: none;
}

.search-actions {
    display: flex;
    gap: 8px;
}

.search-button {
    min-width: 78px;
    border: 1px solid var(--border);
    padding: 0 13px;
    background: var(--surface-muted);
    color: var(--text-soft);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.search-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.search-google {
    border-color: var(--text);
    background: var(--text);
    color: var(--page-bg);
}

.search-google:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.search-hint {
    margin: 7px 0 0;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12px;
}

.mobile-nav {
    display: none;
}

.navigation-content {
    display: grid;
    gap: 28px;
}

.nav-section {
    min-width: 0;
    scroll-margin-top: 76px;
}

.section-heading {
    display: flex;
    min-height: 31px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    padding-bottom: 6px;
}

.section-heading h2 {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0;
}

.section-heading h2 > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-index {
    flex-shrink: 0;
    color: var(--accent);
}

.category-icon,
.private-icon {
    flex-shrink: 0;
    color: var(--accent);
    font-size: 14px;
}

.private-icon {
    color: #f59e0b;
}

.category-count {
    flex-shrink: 0;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.nav-card {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 90px;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    border: 1px solid var(--border);
    padding: 7px 9px 6px;
    background: var(--surface);
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}

.nav-card:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
}

.card-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
}

.link-favicon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
}

.link-title {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-card:hover .link-title {
    color: var(--accent);
}

.card-arrow {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
}

.link-description {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.link-domain {
    overflow: hidden;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.private-badge {
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 6px;
    background: #f59e0b;
    color: #18181b;
    font-size: 10px;
}

.sr-only {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.more-card {
    align-items: flex-start;
    justify-content: center;
    border-style: dashed;
    background: var(--surface-muted);
}

.more-card:hover {
    background: var(--accent-soft);
}

.more-title {
    color: var(--accent);
    font-size: 15px;
    font-weight: 700;
}

.empty-category,
.empty-state,
.no-results {
    border: 1px dashed var(--border);
    padding: 22px;
    color: var(--text-soft);
    text-align: center;
}

.empty-category {
    margin: 0;
    font-size: 13px;
}

.empty-state {
    font-family: var(--font-mono);
    font-size: 12px;
}

.empty-state p,
.no-results p {
    margin: 0 0 5px;
}

.empty-state a {
    color: var(--accent);
}

.no-results {
    margin-top: 22px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.no-results span {
    color: var(--text-muted);
    font-size: 10px;
}

.back-link {
    display: inline-block;
    margin-bottom: 22px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 12px;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 15px 0;
    background: var(--surface);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-inner a {
    color: var(--text-soft);
}

.footer-inner a:hover {
    color: var(--accent);
}

.status-online {
    color: var(--status);
}

.floating-actions {
    position: fixed;
    z-index: 15;
    right: max(var(--page-gutter), calc((100% - var(--page-max-width)) / 2));
    bottom: 70px;
    display: grid;
    gap: 7px;
}

.floating-button {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 14px;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.floating-button:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.category-nav-toggle {
    color: var(--accent);
}

.floating-category-nav {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    display: none;
    width: 216px;
    max-width: calc(100vw - var(--page-gutter) * 2);
    max-height: calc(100vh - 280px);
    max-height: calc(100dvh - 280px);
    flex-direction: column;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
}

.floating-category-nav.is-open {
    display: flex;
}

.category-nav-heading {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding: 10px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
}

.category-nav-count,
.category-nav-index {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
}

.category-nav-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 5px;
    scroll-behavior: auto;
}

.category-nav-link {
    display: flex;
    min-height: 36px;
    align-items: center;
    gap: 7px;
    border-left: 2px solid transparent;
    padding: 7px 6px;
    color: var(--text-soft);
    font-size: 12px;
    transition: background-color .15s ease, color .15s ease;
}

.category-nav-link.is-child {
    padding-left: 14px;
}

.category-nav-index,
.category-nav-link > .fa-lock {
    flex-shrink: 0;
}

.category-nav-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-nav-link:hover {
    background: var(--surface-muted);
    color: var(--accent);
}

.category-nav-link.is-active {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.category-nav-link.is-active .category-nav-index {
    color: var(--accent);
}

@media (min-width: 1080px) and (min-height: 600px) {
    .has-category-nav .page-shell {
        padding-right: calc(var(--category-nav-width) + 20px);
    }

    .category-nav-toggle {
        display: none;
    }

    .floating-category-nav {
        position: fixed;
        top: 175px;
        right: max(var(--page-gutter), calc((100% - var(--page-max-width)) / 2));
        bottom: auto;
        display: flex;
        width: var(--category-nav-width);
        box-shadow: none;
    }
}

@media (max-height: 599px) {
    .floating-category-nav {
        right: calc(100% + 10px);
        bottom: 0;
        max-width: calc(100vw - var(--page-gutter) * 2 - 48px);
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
    }
}

.top-button {
    display: none;
}

.top-button.is-visible {
    display: grid;
}

@keyframes blink {
    to { visibility: hidden; }
}

@media (min-width: 560px) {
    .link-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 820px) {
    .link-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1080px) {
    .link-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1180px) {
    .link-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 1360px) {
    .full-width .link-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .desktop-nav {
        display: none;
    }

    .mobile-nav {
        display: flex;
        overflow-x: auto;
        gap: 5px;
        margin: -9px 0 22px;
        border-bottom: 1px solid var(--border);
        padding: 0 0 8px;
        scrollbar-width: none;
    }

    .mobile-nav::-webkit-scrollbar {
        display: none;
    }

    .mobile-nav a {
        flex-shrink: 0;
        background: var(--surface-muted);
    }
}

@media (max-width: 520px) {
    :root {
        --page-gutter: 12px;
    }

    .header-inner {
        gap: 7px;
    }

    .brand {
        gap: 0;
    }

    .brand-subtitle {
        display: none;
    }

    .account-link {
        padding-inline: 5px;
        font-size: 12px;
    }

    .theme-toggle {
        gap: 4px;
        padding-inline: 6px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .search-button {
        min-height: 38px;
    }

    .footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
