/* ============================================================
   文件中心 · File Center
   浅色档案索引风格：墨绿 + 黄铜，行式台账 + 右侧检视抽屉
   ============================================================ */

:root {
    --canvas: #F1F3EF;
    --surface: #FBFCFA;
    --surface-2: #E9EDE7;
    --ink: #17211D;
    --ink-soft: #3B4A44;
    --muted: #67746D;
    --line: #D7DED7;
    --line-strong: #C2CDC5;
    --primary: #1F4D3F;
    --primary-hover: #173D32;
    --primary-soft: #E3ECE6;
    --brass: #B8862F;
    --brass-soft: #F0E5CE;
    --danger: #A63A2E;
    --danger-soft: #F6E4E1;
    --radius: 10px;
    --radius-sm: 7px;
    --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-display: Georgia, "Songti SC", "STSong", "SimSun", serif;
    --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --shadow-pop: 0 18px 40px -18px rgba(23, 33, 29, .45);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button { cursor: pointer; }

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

code {
    font-family: var(--font-mono);
    font-size: .92em;
}

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

/* ---------------- 通用按钮 ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.btn-primary {
    background: var(--primary);
    color: #F3F7F2;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-primary:disabled {
    background: var(--line-strong);
    color: var(--surface);
    cursor: not-allowed;
}

.btn-ghost {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--ink-soft);
}

.btn-ghost:hover {
    background: var(--surface-2);
    border-color: var(--line-strong);
}

.btn-danger {
    background: var(--danger);
    color: #FFF6F4;
}

.btn-danger:hover { background: #8F3026; }

.btn-danger-ghost {
    color: var(--danger);
    border-color: transparent;
}

.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-block { width: 100%; height: 46px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
}

.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.icon-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.link-btn {
    border: 0;
    background: none;
    padding: 0;
    color: var(--primary);
    font-size: 12.5px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---------------- 品牌标记 ---------------- */

.mark {
    position: relative;
    width: 20px;
    height: 20px;
    flex: none;
}

.mark::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    width: 20px;
    height: 15px;
    border-radius: 3px;
    background: var(--brass);
}

.mark::after {
    content: "";
    position: absolute;
    left: 2px;
    top: 1px;
    width: 9px;
    height: 6px;
    border-radius: 2px 2px 0 0;
    background: var(--brass);
    opacity: .78;
}

/* ---------------- 登录 ---------------- */

.login {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(340px, 44%) minmax(0, 1fr);
}

.login-aside {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(32px, 5vw, 72px);
    background: #173A30;
    background-image: repeating-linear-gradient(90deg, rgba(243, 247, 242, .045) 0 1px, transparent 1px 104px);
    color: #EDF2ED;
}

.login-aside::after {
    content: "";
    position: absolute;
    right: -170px;
    bottom: -190px;
    width: 520px;
    height: 520px;
    border: 1px solid rgba(184, 134, 47, .32);
    border-radius: 50%;
    pointer-events: none;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.login-brand-text {
    display: flex;
    flex-direction: column;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .02em;
}

.login-brand-text small {
    font-size: 10.5px;
    font-weight: 400;
    letter-spacing: .14em;
    color: rgba(237, 242, 237, .55);
}

.login-statement {
    position: relative;
    z-index: 1;
    max-width: 460px;
}

.login-statement h1 {
    margin: 0 0 24px;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(36px, 4vw, 54px);
    line-height: 1.22;
    letter-spacing: .01em;
}

.login-statement p {
    margin: 0;
    max-width: 34ch;
    font-size: 14px;
    line-height: 1.85;
    color: rgba(237, 242, 237, .68);
}

.login-aside-foot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    letter-spacing: .1em;
    color: rgba(237, 242, 237, .55);
}

.login-aside-foot .rule {
    width: 34px;
    height: 1px;
    background: var(--brass);
    opacity: .85;
}

.login-main {
    display: grid;
    place-items: center;
    padding: 40px 24px;
    background: var(--canvas);
}

.login-form {
    width: min(372px, 100%);
}

.login-form h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 30px;
    letter-spacing: .01em;
}

.login-lede {
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 13.5px;
}

.login-hint {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
}

.field > span {
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .02em;
}

.field input,
.field textarea {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 14.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field textarea {
    height: auto;
    padding: 11px 12px;
    resize: vertical;
    line-height: 1.7;
    font-family: var(--font-mono);
    font-size: 13px;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-error {
    margin: 0 0 14px;
    padding: 9px 12px;
    border-radius: 7px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
}

/* ---------------- 顶栏 ---------------- */

.app {
    min-height: 100dvh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 22px;
    height: 66px;
    padding: 0 24px;
    background: rgba(251, 252, 250, .94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.brand-name {
    font-size: 17.5px;
    font-weight: 650;
    letter-spacing: .02em;
}

.brand-en {
    padding-left: 10px;
    margin-left: 2px;
    border-left: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .08em;
}

.search {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    max-width: 540px;
    height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
    transition: border-color .15s ease, background .15s ease;
}

.search:focus-within {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-icon {
    width: 17px;
    height: 17px;
    flex: none;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
}

.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font-size: 14px;
    outline: none;
}

.search input::placeholder { color: #92A099; }

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

.search-kbd {
    flex: none;
    padding: 1px 6px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.user { position: relative; }

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 8px 0 4px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
}

.user-btn:hover { background: var(--surface-2); }

.user-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12.5px;
    font-weight: 650;
}

.user-name {
    font-size: 13px;
    color: var(--ink-soft);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 208px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
}

.popover-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}

.popover-head strong { font-size: 13.5px; }

.popover-head span {
    font-size: 11.5px;
    color: var(--muted);
}

.popover button,
.popover-link {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    text-align: left;
    font-size: 13px;
    color: var(--ink-soft);
    text-decoration: none;
}

.popover button:hover,
.popover-link:hover { background: var(--surface-2); }

/* ---------------- 工作区 ---------------- */

.workspace {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: calc(100dvh - 66px);
}

.workspace.admin-mode { display: block; }

.workspace.admin-mode .rail,
.workspace.admin-mode #ledger { display: none; }

/* 左侧索引栏 */

.rail {
    position: sticky;
    top: 66px;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 66px);
    padding: 30px 18px 24px;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    min-width: 0;
}

.rail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 10px 14px;
}

.rail-head h2 {
    margin: 0;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--muted);
}

.rail-total {
    font-size: 11.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-soft);
    font-size: 14px;
    text-align: left;
}

.category-item span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-item .count {
    flex: none;
    font-size: 11.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.category-item:hover { background: var(--surface-2); }

.category-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brass);
}

.category-item.active .count { color: var(--primary); }

.rail-foot {
    margin-top: auto;
    padding: 20px 10px 0;
    border-top: 1px solid var(--line);
}

.storage-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.storage-top span {
    font-size: 12px;
    color: var(--muted);
}

.storage-top strong {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
}

.meter {
    height: 5px;
    margin-top: 10px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
}

.meter i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 99px;
    background: var(--brass);
    transition: width .4s ease;
}

.storage-sub {
    margin: 9px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
}

/* 主台账 */

.ledger {
    padding: 32px clamp(18px, 3vw, 44px) 64px;
    min-width: 0;
}

.ledger-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.ledger-head h1,
.admin-head h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 29px;
    letter-spacing: .01em;
}

.ledger-sub {
    margin: 5px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.sort {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.sort span {
    font-size: 12px;
    color: var(--muted);
}

.sort select {
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface);
    font-size: 12.5px;
    color: var(--ink-soft);
}

.table-head,
.file-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 128px 92px 140px 84px;
    align-items: center;
    gap: 12px;
}

.table-head {
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    letter-spacing: .04em;
    color: var(--muted);
}

.table-head .col-name { grid-column: 1 / 3; }

.file-row {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .12s ease;
}

.file-row:hover,
.file-row:focus-visible {
    background: rgba(233, 237, 231, .6);
}

.file-row.selected {
    background: var(--surface);
    box-shadow: inset 2px 0 0 var(--brass);
}

.cell-name {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.file-glyph {
    position: relative;
    flex: none;
    width: 36px;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    overflow: hidden;
}

.file-glyph::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--glyph, var(--muted));
}

.file-glyph::after {
    content: "";
    position: absolute;
    right: -1px;
    top: -1px;
    width: 11px;
    height: 11px;
    background: var(--surface-2);
    clip-path: polygon(0 0, 100% 100%, 0 100%);
    border-left: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}

.file-glyph b {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--glyph, var(--muted));
    text-transform: uppercase;
    overflow: hidden;
    white-space: nowrap;
}

.glyph-image { --glyph: #B8862F; }
.glyph-audio { --glyph: #3E7A5E; }
.glyph-video { --glyph: #3D5A80; }
.glyph-pdf { --glyph: #A6402F; }
.glyph-text { --glyph: #6C6455; }
.glyph-other { --glyph: #6B7A72; }

.cell-name > span {
    display: block;
    min-width: 0;
    max-width: 100%;
}

.file-name {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--ink);
}

.file-sub {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chip {
    display: inline-block;
    max-width: 100%;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 11.5px;
    color: var(--ink-soft);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chip.muted { color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); }

.cell-size,
.cell-time {
    font-size: 12.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    opacity: 0;
    transition: opacity .12s ease;
}

.file-row:hover .cell-actions,
.file-row:focus-within .cell-actions,
.file-row.selected .cell-actions {
    opacity: 1;
}

.cell-actions .icon-btn { width: 30px; height: 30px; }

.empty {
    display: grid;
    justify-items: center;
    padding: 76px 20px;
    text-align: center;
}

.empty-glyph {
    position: relative;
    width: 58px;
    height: 70px;
    margin-bottom: 18px;
    border: 1.5px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
}

.empty-glyph::before {
    content: "";
    position: absolute;
    right: -1.5px;
    top: -1.5px;
    width: 18px;
    height: 18px;
    background: var(--canvas);
    border-left: 1.5px solid var(--line-strong);
    border-bottom: 1.5px solid var(--line-strong);
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.empty-glyph::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 18px;
    height: 1px;
    background: var(--line-strong);
    box-shadow: 0 -8px 0 var(--line-strong), 0 -16px 0 var(--line-strong);
}

.empty h3 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 22px;
}

.empty p {
    margin: 0 0 20px;
    max-width: 36ch;
    color: var(--muted);
    font-size: 13px;
}

.list-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
}

.list-count {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* ---------------- 检视抽屉 ---------------- */

.scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(23, 33, 29, .3);
    opacity: 0;
    transition: opacity .25s ease;
}

.scrim.visible { opacity: 1; }

.inspector {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: min(446px, 94vw);
    height: 100dvh;
    padding: 24px;
    border-left: 1px solid var(--line);
    background: var(--surface);
    box-shadow: -24px 0 60px -30px rgba(23, 33, 29, .5);
    overflow-y: auto;
    transform: translateX(102%);
    transition: transform .28s cubic-bezier(.22, .61, .36, 1);
}

.inspector[data-open="true"] { transform: translateX(0); }

.inspector-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    font-size: 11.5px;
    letter-spacing: .06em;
    color: var(--muted);
}

.inspector-title h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

.preview {
    display: grid;
    place-items: center;
    min-height: 220px;
    margin: 18px 0;
    padding: 0;
    border-radius: var(--radius);
    background: #101B17;
    overflow: hidden;
}

.preview img,
.preview video {
    display: block;
    max-width: 100%;
    max-height: 420px;
}

.preview audio {
    width: calc(100% - 32px);
}

.preview iframe {
    width: 100%;
    height: 430px;
    border: 0;
    background: #fff;
}

.preview pre {
    width: 100%;
    max-height: 420px;
    margin: 0;
    padding: 18px;
    overflow: auto;
    color: #E4EBE5;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-placeholder {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 46px 20px;
    text-align: center;
    color: rgba(237, 242, 237, .68);
}

.preview-placeholder .file-glyph {
    width: 48px;
    height: 56px;
    background: rgba(237, 242, 237, .08);
    border-color: rgba(237, 242, 237, .22);
}

.preview-placeholder strong { font-size: 13px; font-weight: 500; }

.preview-placeholder span { font-size: 12px; color: rgba(237, 242, 237, .45); }

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

.inspect-actions .btn { flex: 1 1 auto; }

.edit-form {
    display: grid;
    gap: 4px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--canvas);
}

.edit-form .field { margin-bottom: 8px; }

.edit-form .field input { height: 38px; background: var(--surface); }

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

.meta {
    margin: 22px 0 0;
    border-top: 1px solid var(--line);
}

.meta > div {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

.meta dt { font-size: 12px; color: var(--muted); }

.meta dd {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-soft);
    word-break: break-word;
}

.meta dd code { font-size: 11.5px; }

.meta dd .link-btn { margin-left: 8px; white-space: nowrap; }

.meta dd .sha {
    display: inline-block;
    max-height: 3.6em;
    overflow: hidden;
    color: var(--muted);
}

/* ---------------- 上传 / 确认弹窗 ---------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(23, 33, 29, .36);
    animation: fade-in .18s ease;
}

.modal-card {
    width: min(560px, 100%);
    max-height: 90dvh;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    overflow-y: auto;
}

.upload-card { width: min(620px, 100%); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-head h2,
.modal-card > h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 23px;
}

.dropzone {
    padding: 26px 20px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--canvas);
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
}

.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.dropzone p { margin: 0 0 6px; font-size: 13.5px; color: var(--ink-soft); }
.dropzone p.hint { margin: 0; font-size: 11.5px; color: var(--muted); }

.dropzone-glyph {
    position: relative;
    width: 34px;
    height: 40px;
    margin: 0 auto 12px;
    border: 1.5px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
}

.dropzone-glyph::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    border-top: 1.5px solid var(--brass);
    border-left: 1.5px solid var(--brass);
    transform: translate(-50%, -38%) rotate(45deg);
}

.upload-queue {
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
    max-height: 168px;
    overflow-y: auto;
}

.upload-queue li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.upload-queue .queue-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.upload-queue .queue-size { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }

.upload-queue .queue-remove {
    flex: none;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 15px;
    line-height: 1;
}

.upload-queue .queue-remove:hover { color: var(--danger); }

.upload-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 16px;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 12px;
    color: var(--muted);
}

.upload-progress .meter { flex: 1; margin-top: 0; }

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.confirm-card { width: min(400px, 100%); }

.confirm-card p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.7;
}

/* ---------------- 管理 ---------------- */

.admin {
    padding: 32px clamp(18px, 3vw, 44px) 64px;
}

.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    max-width: 1120px;
}

.panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.panel h2 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.panel-copy {
    margin: 0 0 16px;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--muted);
}

.panel-copy code,
.hint code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-2);
    font-size: 11.5px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    cursor: pointer;
    user-select: none;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
    position: relative;
    width: 38px;
    height: 22px;
    flex: none;
    border-radius: 999px;
    background: var(--line-strong);
    transition: background .15s ease;
}

.switch-track span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s ease;
}

.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track span { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brass); outline-offset: 2px; }

.switch-text { font-size: 13px; color: var(--ink-soft); }

.hint {
    margin: 6px 0 14px;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--muted);
}

.key-value {
    display: block;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
    font-size: 12px;
    word-break: break-all;
    color: var(--ink-soft);
}

.stats { margin: 0; }

.stats > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.stats dt { color: var(--muted); }

.stats dd {
    margin: 0;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
    text-align: right;
}

.stack { display: grid; gap: 4px; }

.code-block {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------------- 其他 ---------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 90;
    max-width: min(460px, calc(100vw - 32px));
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--ink);
    color: #F3F7F2;
    font-size: 13px;
    box-shadow: var(--shadow-pop);
    transform: translateX(-50%);
    animation: toast-in .2s ease;
}

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

.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    background: rgba(31, 77, 63, .88);
    color: #F3F7F2;
}

.drop-overlay > div {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 48px 72px;
    border: 2px dashed rgba(243, 247, 242, .45);
    border-radius: 16px;
}

.drop-overlay strong { font-size: 18px; font-weight: 500; }
.drop-overlay span { font-size: 12.5px; color: rgba(243, 247, 242, .7); }

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

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
    .table-head,
    .file-row {
        grid-template-columns: 44px minmax(0, 1fr) 108px 84px 116px 72px;
        gap: 10px;
    }
}

@media (max-width: 900px) {
    .login { grid-template-columns: 1fr; }
    .login-aside {
        padding: 28px 24px 32px;
        gap: 26px;
    }
    .login-aside::after { display: none; }
    .login-statement h1 { margin-bottom: 12px; font-size: 30px; }
    .login-statement p { font-size: 12.5px; }
    .login-aside-foot { display: none; }
    .login-main { padding: 34px 24px 48px; }

    .workspace { grid-template-columns: 1fr; }
    .rail {
        position: static;
        height: auto;
        padding: 16px 16px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }
    .rail-head { padding: 0 2px 10px; }
    .category-list {
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .category-list::-webkit-scrollbar { display: none; }
    .category-item {
        width: auto;
        flex: none;
        padding: 7px 12px;
        border: 1px solid var(--line);
        background: var(--surface);
        font-size: 13px;
    }
    .category-item .count { margin-left: 4px; }
    .category-item.active { box-shadow: none; border-color: var(--primary); }
    .rail-foot { display: none; }

    .ledger, .admin { padding: 22px 16px 56px; }
    .ledger-head h1, .admin-head h1 { font-size: 25px; }
    .admin-grid { grid-template-columns: 1fr; }
    .upload-fields { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        gap: 10px;
        padding: 12px 14px;
    }
    .brand-en { display: none; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .search-kbd { display: none; }
    .topbar-actions { gap: 6px; }
    .user-name { display: none; }

    .table-head { display: none; }
    .file-list { border-top: 1px solid var(--line); }
    .file-row {
        grid-template-columns: 38px minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        padding: 11px 4px;
        column-gap: 10px;
        row-gap: 2px;
        min-width: 0;
    }
    .cell-category, .cell-time { display: none; }
    .file-glyph { grid-column: 1; grid-row: 1 / 3; }
    .cell-name { grid-column: 2; grid-row: 1 / 3; }
    .cell-size { grid-column: 3; grid-row: 1; font-size: 11.5px; text-align: right; }
    .cell-actions { grid-column: 3; grid-row: 2; justify-content: flex-end; opacity: 1; }

    .file-glyph { width: 34px; height: 39px; }
    .inspector { width: 100vw; padding: 18px; }
    .preview iframe { height: 60vh; }
    .inspect-actions .btn { flex: 1 1 44%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}
