:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --surface: #ffffff;
    --surface-strong: #f0f8f5;
    --text: #16201d;
    --muted: #6d7873;
    --border: #e4e9e7;
    --accent: #28b77a;
    --accent-strong: #12895a;
    --cyan: #2a9fd6;
    --warm: #f5b84b;
    --danger: #dc4c64;
    --shadow: 0 10px 30px rgba(18, 54, 42, 0.08);
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #151917;
        --surface: #1f2522;
        --surface-strong: #203028;
        --text: #eef6f1;
        --muted: #a0aea7;
        --border: #303936;
        --accent: #46d798;
        --accent-strong: #7be0b0;
        --cyan: #64bee4;
        --warm: #f0c15c;
        --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #151917;
    --surface: #1f2522;
    --surface-strong: #203028;
    --text: #eef6f1;
    --muted: #a0aea7;
    --border: #303936;
    --accent: #46d798;
    --accent-strong: #7be0b0;
    --cyan: #64bee4;
    --warm: #f0c15c;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    letter-spacing: 0;
}

.inspection-shield {
    position: fixed;
    left: 50%;
    top: 24px;
    z-index: 9999;
    transform: translate(-50%, -16px);
    min-width: 160px;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: var(--shadow);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.inspection-shield.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

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

button,
input,
textarea,
select {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

.site-shell {
    width: min(100%, 560px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 14px 40px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 10px 0;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.brand-mark,
.brand-image {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    flex: 0 0 34px;
}

.brand-mark {
    background: linear-gradient(145deg, var(--accent), var(--cyan));
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.brand-image {
    object-fit: cover;
}

.brand-name {
    overflow: hidden;
    color: var(--text);
    font-size: 19px;
    font-weight: 760;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    gap: 8px;
}

.site-domain {
    max-width: 160px;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-button {
    position: relative;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}

.theme-button::before {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    content: "";
}

.theme-button[data-current-theme="dark"]::before {
    width: 14px;
    height: 14px;
    margin: auto;
    border-radius: 50%;
    background: currentColor;
    box-shadow: -5px -1px 0 0 var(--surface);
}

.theme-button:not([data-current-theme="dark"])::before {
    width: 13px;
    height: 13px;
    margin: auto;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-shadow: 0 -8px 0 -5px currentColor, 0 8px 0 -5px currentColor, 8px 0 0 -5px currentColor, -8px 0 0 -5px currentColor;
}

.banner-wrap {
    margin-top: 8px;
}

.banner {
    display: block;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.banner img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.notice {
    display: flex;
    align-items: center;
    min-height: 42px;
    margin: 14px 0 18px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

.notice-dot {
    width: 7px;
    height: 7px;
    margin-right: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--accent);
}

.nav-section {
    margin-top: 22px;
}

.nav-section h2 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 17px;
    font-weight: 760;
    line-height: 1.25;
}

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

.nav-button {
    aspect-ratio: 2.75 / 1;
    min-height: 58px;
}

.nav-button,
.install-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 680;
    line-height: 1.25;
    text-align: center;
    box-shadow: 0 5px 18px rgba(18, 54, 42, 0.05);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex: 0 0 24px;
    object-fit: cover;
}

.nav-button:hover,
.install-row:hover,
.source-row:hover,
.channel-card:hover {
    border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
    transform: translateY(-1px);
}

.source-list,
.install-list {
    display: grid;
    gap: 10px;
}

.source-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 66px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: left;
    box-shadow: 0 5px 18px rgba(18, 54, 42, 0.05);
    transition: transform 160ms ease, border-color 160ms ease;
}

.source-icon,
.channel-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
}

.source-icon {
    width: 42px;
    height: 42px;
    font-size: 13px;
}

.source-icon.has-image,
.channel-icon.has-image {
    overflow: hidden;
    background: transparent;
}

.source-icon img,
.channel-icon img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.source-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.source-copy strong,
.channel-copy strong {
    overflow: hidden;
    font-size: 15px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-copy small,
.channel-copy small {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-action {
    padding: 7px 9px;
    border-radius: 7px;
    background: var(--surface-strong);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 760;
    white-space: nowrap;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.channel-card {
    display: grid;
    min-width: 0;
    min-height: 112px;
    padding: 13px 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-align: center;
    box-shadow: 0 5px 18px rgba(18, 54, 42, 0.05);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.channel-icon {
    width: 38px;
    height: 38px;
    margin: 0 auto 9px;
    font-size: 12px;
}

.channel-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.icon-wechat,
.icon-mini,
.icon-home {
    background: linear-gradient(145deg, #18b871, #2ccf8b);
}

.icon-douyin,
.icon-video,
.icon-sign {
    background: linear-gradient(145deg, #20242a, #2a9fd6);
}

.icon-bilibili {
    background: linear-gradient(145deg, #23a6d5, #6ac9ed);
}

.icon-redbook {
    background: linear-gradient(145deg, #e64e61, #f5b84b);
}

.icon-link,
.icon-source {
    background: linear-gradient(145deg, #73818b, #9ba8ad);
}

.site-footer {
    margin: 34px 0 0;
    padding: 20px 10px 14px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    text-align: center;
}

.admin-page {
    background: var(--bg);
}

.admin-shell {
    width: min(100%, 1080px);
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.admin-header h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.admin-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.admin-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
}

.admin-nav,
.admin-panel,
.login-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.admin-nav {
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 10px;
}

.admin-nav button,
.button,
.ghost-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 720;
}

.admin-nav button {
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
}

.admin-nav button.is-active {
    background: var(--surface-strong);
    color: var(--accent-strong);
}

.admin-panel {
    padding: 18px;
}

.admin-panel h2 {
    margin: 0 0 16px;
    font-size: 19px;
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

.form-grid > .full {
    grid-column: 1 / -1;
}

.field span,
.item-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.35;
}

.field textarea {
    min-height: 78px;
    resize: vertical;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.button {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    padding: 0 14px;
}

.ghost-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0 12px;
}

.danger-button {
    border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--border));
    background: transparent;
    color: var(--danger);
    padding: 0 12px;
}

.status-line {
    min-height: 20px;
    color: var(--muted);
    font-size: 13px;
}

.section-editor,
.item-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.section-editor {
    margin-bottom: 14px;
    padding: 14px;
}

.section-editor header,
.item-editor header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.section-editor header strong {
    font-size: 16px;
}

.item-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.item-editor {
    padding: 12px;
    background: var(--surface);
}

.inline-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 720;
}

.login-panel {
    width: min(100%, 420px);
    margin: 8vh auto;
    padding: 22px;
}

.login-panel h1 {
    margin: 0 0 10px;
    font-size: 24px;
}

.setup-box,
.error-box {
    margin: 14px 0;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.55;
}

.setup-box {
    border: 1px solid color-mix(in srgb, var(--warm) 48%, var(--border));
    background: color-mix(in srgb, var(--warm) 12%, var(--surface));
}

.error-box {
    border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
    background: color-mix(in srgb, var(--danger) 10%, var(--surface));
    color: var(--danger);
}

.code-line {
    display: block;
    overflow-x: auto;
    margin-top: 8px;
    padding: 9px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .site-shell {
        padding-inline: 12px;
    }

    .site-domain {
        max-width: 112px;
    }

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

    .channel-card {
        min-height: 104px;
        padding-inline: 6px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-nav {
        display: flex;
        overflow-x: auto;
    }

    .admin-nav button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .admin-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (min-width: 900px) {
    .site-shell {
        width: min(100%, 1000px);
        padding-inline: 0;
    }

    .topbar {
        min-height: 56px;
        padding-inline: 15px;
    }

    .notice {
        min-height: 62px;
        margin: 10px 15px 14px;
        padding: 18px 20px;
    }

    .notice strong {
        margin-right: 4px;
    }

    .banner-wrap {
        margin-top: 0;
    }

    .banner {
        width: 600px;
        margin: 0 auto;
    }

    .banner img {
        aspect-ratio: 16 / 9;
    }

    main .nav-section:first-child {
        margin-top: 40px;
    }

    main .nav-section + .nav-section {
        margin-top: 50px;
    }

    .nav-section h2 {
        padding-inline: 15px;
        font-size: 18px;
    }

    .section-buttons h2 {
        margin-bottom: 16px;
    }

    .button-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        padding-inline: 15px;
    }

    .nav-button {
        aspect-ratio: 2.72 / 1;
        min-height: 78px;
        padding-inline: 18px;
    }

    .nav-icon {
        width: 26px;
        height: 26px;
        flex-basis: 26px;
    }

    .source-list {
        grid-template-columns: repeat(3, 303px);
        gap: 10px 30px;
        justify-content: start;
        padding-inline: 15px;
    }

    [aria-labelledby="section-sources"] .source-row:first-child {
        grid-column: 1 / -1;
        min-height: 60px;
    }

    [aria-labelledby="section-system"] .source-list {
        grid-template-columns: repeat(2, 470px);
    }

    .source-row {
        min-height: 100px;
    }

    .channel-grid {
        grid-template-columns: repeat(2, 470px);
        gap: 30px;
        justify-content: start;
        padding-inline: 15px;
    }
}

@media (max-width: 380px) {
    .brand-name {
        max-width: 112px;
    }

    .channel-copy strong {
        font-size: 13px;
    }

    .channel-copy small {
        font-size: 11px;
    }
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.is-visible {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: min(100%, 420px);
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-content h3 {
    margin: 0;
    padding: 20px 20px 0;
    font-size: 18px;
    font-weight: 760;
}

.modal-body {
    padding: 16px 20px 20px;
}

.modal-body p {
    margin: 8px 0;
    font-size: 15px;
    line-height: 1.6;
}

.code-box {
    margin: 16px 0;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 14px;
    word-break: break-all;
}

.modal-copy {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 720;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-copy:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
}
