:root {
    color-scheme: light;
    --color-bg: #f5f7fb;
    --color-surface: #ffffff;
    --color-surface-soft: #f8faff;
    --color-border: #dfe6f2;
    --color-border-strong: #c9d5e8;
    --color-primary: #175cff;
    --color-primary-hover: #0d47d9;
    --color-primary-soft: #eaf0ff;
    --color-text: #1f2937;
    --color-muted: #637083;
    --color-subtle: #8a96a8;
    --color-danger: #c03535;
    --color-success: #1f8f57;
    --color-on-primary: #ffffff;
    --color-header-bg: rgba(255, 255, 255, 0.96);
    --color-input-bg: #ffffff;
    --color-button-bg: #ffffff;
    --color-table-head: #f7f9fd;
    --color-row-bg: #ffffff;
    --color-row-hover: #f8fbff;
    --color-row-selected: #eef4ff;
    --color-badge-bg: #f0f4fa;
    --color-mark-bg: #fff1a6;
    --color-modal-overlay: rgba(15, 23, 42, 0.48);
    --color-preview-text: #111827;
    --color-notification-bg: #111827;
    --shadow-focus: 0 0 0 2px rgba(23, 92, 255, 0.12);
    --shadow-modal: 0 24px 72px rgba(15, 23, 42, 0.28);
    --shadow-notification: 0 16px 40px rgba(15, 23, 42, 0.24);
    --shadow-soft: 0 16px 36px rgba(31, 50, 88, 0.08);
    --radius: 8px;
    --header-height: 68px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: #1a1a1c;
    --color-surface: #242427;
    --color-surface-soft: #2b2b2f;
    --color-border: rgba(255, 255, 255, 0.15);
    --color-border-strong: rgba(255, 255, 255, 0.25);
    --color-primary: #4374f2;
    --color-primary-hover: #335bc4;
    --color-primary-soft: rgba(67, 116, 242, 0.16);
    --color-text: rgba(255, 255, 255, 0.96);
    --color-muted: rgba(255, 255, 255, 0.78);
    --color-subtle: rgba(255, 255, 255, 0.58);
    --color-danger: #f7716d;
    --color-success: #82c04d;
    --color-on-primary: #ffffff;
    --color-header-bg: rgba(36, 36, 39, 0.94);
    --color-input-bg: #242427;
    --color-button-bg: #242427;
    --color-table-head: #353539;
    --color-row-bg: #242427;
    --color-row-hover: #2b2b2f;
    --color-row-selected: rgba(67, 116, 242, 0.18);
    --color-badge-bg: #2b2b2f;
    --color-mark-bg: rgba(240, 147, 75, 0.3);
    --color-modal-overlay: rgba(0, 0, 0, 0.58);
    --color-preview-text: rgba(255, 255, 255, 0.9);
    --color-notification-bg: #353539;
    --shadow-focus: 0 0 0 2px rgba(67, 116, 242, 0.24);
    --shadow-modal: 0 24px 72px rgba(0, 0, 0, 0.5);
    --shadow-notification: 0 16px 40px rgba(0, 0, 0, 0.32);
    --shadow-soft: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --color-bg: #1a1a1c;
        --color-surface: #242427;
        --color-surface-soft: #2b2b2f;
        --color-border: rgba(255, 255, 255, 0.15);
        --color-border-strong: rgba(255, 255, 255, 0.25);
        --color-primary: #4374f2;
        --color-primary-hover: #335bc4;
        --color-primary-soft: rgba(67, 116, 242, 0.16);
        --color-text: rgba(255, 255, 255, 0.96);
        --color-muted: rgba(255, 255, 255, 0.78);
        --color-subtle: rgba(255, 255, 255, 0.58);
        --color-danger: #f7716d;
        --color-success: #82c04d;
        --color-on-primary: #ffffff;
        --color-header-bg: rgba(36, 36, 39, 0.94);
        --color-input-bg: #242427;
        --color-button-bg: #242427;
        --color-table-head: #353539;
        --color-row-bg: #242427;
        --color-row-hover: #2b2b2f;
        --color-row-selected: rgba(67, 116, 242, 0.18);
        --color-badge-bg: #2b2b2f;
        --color-mark-bg: rgba(240, 147, 75, 0.3);
        --color-modal-overlay: rgba(0, 0, 0, 0.58);
        --color-preview-text: rgba(255, 255, 255, 0.9);
        --color-notification-bg: #353539;
        --shadow-focus: 0 0 0 2px rgba(67, 116, 242, 0.24);
        --shadow-modal: 0 24px 72px rgba(0, 0, 0, 0.5);
        --shadow-notification: 0 16px 40px rgba(0, 0, 0, 0.32);
        --shadow-soft: none;
    }
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

button,
input {
    font: inherit;
}

input::placeholder {
    color: var(--color-subtle);
}

button {
    color: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.site-header__inner {
    width: 80vw;
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text);
    font-weight: 700;
    text-decoration: none;
    min-width: 0;
}

.brand__mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-weight: 800;
}

.brand__text {
    font-size: 18px;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 1 576px;
    min-width: 0;
    margin-left: auto;
    gap: 10px;
}

.theme-toggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 6px;
    padding: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    transition: color 0.16s ease;
}

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

.theme-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.theme-toggle svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle__icon--sun {
    display: none;
}

.theme-toggle.is-dark .theme-toggle__icon--moon {
    display: none;
}

.theme-toggle.is-dark .theme-toggle__icon--sun {
    display: block;
}

main {
    padding-bottom: 56px;
}

.repository-section {
    width: 80vw;
    margin: 16px auto 0;
}

.section-shell {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--color-border);
}

.section-heading h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.25;
    font-weight: 700;
}

.section-heading p {
    margin: 8px 0 0;
    color: var(--color-muted);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 52px;
    padding: 10px 32px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-soft);
}

.crumb {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--color-primary);
    padding: 3px 8px;
    cursor: pointer;
}

.crumb:hover {
    background: var(--color-button-bg);
    border-color: var(--color-border);
}

.crumb:not(:last-child)::after {
    content: "/";
    margin-left: 10px;
    color: var(--color-subtle);
}

.crumb:last-child {
    color: var(--color-text);
    cursor: default;
}

.repository-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    min-height: 52px;
    padding: 8px 32px;
}

.search-box {
    display: flex;
    flex: 1 1 460px;
    max-width: 620px;
    min-width: 0;
}

.site-header .search-box {
    flex: 1 1 auto;
    max-width: none;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    background: var(--color-input-bg);
}

.site-header .search-box input {
    width: 100%;
    min-width: 0;
    height: 32px;
    border: 0;
    border-radius: 5px;
    outline: none;
    padding: 0 12px;
    color: var(--color-text);
    background: var(--color-input-bg);
}

.site-header .search-box:focus-within {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.site-header .search-box input:focus {
    border-color: transparent;
    box-shadow: none;
}

.site-header .search-box .btn {
    min-height: 32px;
    border-radius: 5px;
    padding: 0 18px;
}

.search-box input {
    width: 100%;
    min-width: 0;
    height: 40px;
    border: 1px solid var(--color-border-strong);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    outline: none;
    padding: 0 14px;
    color: var(--color-text);
    background: var(--color-input-bg);
}

.search-box input:focus {
    border-color: var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--color-primary);
}

.batch-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    color: var(--color-muted);
    white-space: nowrap;
}

#btn-download {
    min-height: 32px;
    border-radius: 7px;
    padding: 0 14px;
    font-size: 13px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--color-button-bg);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-outline {
    border-color: var(--color-border-strong);
    color: var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.46;
}

.table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--color-border);
}

.file-table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    table-layout: fixed;
}

.file-table th,
.file-table td {
    border-bottom: 1px solid var(--color-border);
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
}

.file-table th {
    background: var(--color-table-head);
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 700;
}

.file-table tbody tr {
    background: var(--color-row-bg);
}

.file-table tbody tr:hover {
    background: var(--color-row-hover);
}

.file-table tbody tr.selected {
    background: var(--color-row-selected);
}

.col-checkbox {
    width: 56px;
}

.col-name {
    width: 38%;
}

.col-type {
    width: 110px;
}

.col-size {
    width: 120px;
}

.col-time {
    width: 170px;
}

.col-actions {
    width: 210px;
}

.file-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.file-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    overflow: hidden;
}

.file-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-name {
    min-width: 0;
}

.file-link {
    display: inline;
    border: 0;
    background: transparent;
    color: var(--color-text);
    padding: 0;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    word-break: break-word;
}

.file-link:hover {
    color: var(--color-primary);
}

.file-path {
    margin-top: 2px;
    color: var(--color-subtle);
    font-size: 12px;
    word-break: break-all;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: var(--color-badge-bg);
    color: var(--color-muted);
    padding: 1px 10px;
    font-size: 12px;
    font-weight: 600;
}

.file-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    min-height: 30px;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    background: var(--color-button-bg);
    color: var(--color-primary);
    padding: 0 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.action-btn:hover {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.loading,
.empty-message {
    height: 120px;
    color: var(--color-muted);
    text-align: center;
}

.empty-message strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text);
    font-size: 16px;
}

mark {
    background: var(--color-mark-bg);
    border-radius: 3px;
    padding: 0 2px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--color-modal-overlay);
    padding: 28px;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: min(720px, 100%);
    max-height: min(82vh, 760px);
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

.modal-large {
    width: min(980px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    margin: 0;
    min-width: 0;
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-button-bg);
    cursor: pointer;
    color: var(--color-muted);
    font-size: 24px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.modal-body {
    min-height: 220px;
    overflow: auto;
    padding: 22px;
}

.preview-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.preview-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--color-preview-text);
    font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.preview-frame {
    width: 100%;
    min-height: 62vh;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.notification {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    max-width: min(420px, calc(100vw - 48px));
    display: none;
    border-radius: 8px;
    background: var(--color-notification-bg);
    color: var(--color-on-primary);
    padding: 12px 16px;
    box-shadow: var(--shadow-notification);
}

.notification.show {
    display: block;
}

.notification.success {
    background: var(--color-success);
}

.notification.error {
    background: var(--color-danger);
}

@media (max-width: 820px) {
    .site-header {
        height: auto;
    }

    .site-header__inner {
        width: calc(100% - 28px);
        min-height: var(--header-height);
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding: 12px 0;
        gap: 10px;
    }

    .header-actions {
        width: 100%;
        flex: 0 0 auto;
        margin-left: 0;
        gap: 8px;
    }

    .repository-section {
        width: calc(100% - 16px);
    }

    .section-heading,
    .repository-tools {
        flex-direction: column;
        align-items: stretch;
    }

    .section-heading,
    .breadcrumb,
    .repository-tools {
        padding-left: 18px;
        padding-right: 18px;
    }

    .section-heading h2 {
        font-size: 22px;
    }

    .search-box {
        width: 100%;
        flex-basis: auto;
        max-width: none;
    }

    .site-header .search-box {
        flex: 1 1 auto;
    }

    .batch-actions {
        justify-content: space-between;
        white-space: normal;
    }

    .table-wrap {
        overflow: visible;
    }

    .file-table,
    .file-table thead,
    .file-table tbody,
    .file-table tr,
    .file-table th,
    .file-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .file-table {
        table-layout: auto;
    }

    .file-table thead {
        display: none;
    }

    .file-table tbody tr {
        position: relative;
        padding: 14px 18px;
        border-bottom: 1px solid var(--color-border);
    }

    .file-table td {
        border-bottom: 0;
        padding: 4px 0;
    }

    .file-table td.col-checkbox {
        position: absolute;
        top: 16px;
        right: 18px;
        width: auto;
    }

    .file-table td.col-name {
        padding-right: 34px;
    }

    .file-table td.col-type,
    .file-table td.col-size,
    .file-table td.col-time {
        color: var(--color-muted);
        font-size: 13px;
    }

    .file-table td.col-type::before {
        content: "类型：";
    }

    .file-table td.col-size::before {
        content: "大小：";
    }

    .file-table td.col-time::before {
        content: "更新时间：";
    }

    .file-actions {
        margin-top: 8px;
    }

    .action-btn {
        flex: 1 1 84px;
    }

    .modal {
        padding: 14px;
    }

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

@media (max-width: 520px) {
    .brand__text {
        font-size: 16px;
    }

    .repository-section {
        margin-top: 12px;
    }

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

    .site-header .search-box {
        flex: 1 1 auto;
    }

    .theme-toggle {
        flex-basis: 36px;
    }

    .search-box input {
        border-right: 0;
    }

    .search-box .btn {
        border-radius: 0 8px 8px 0;
        padding: 0 14px;
    }
}
