:root {
  --paper: #f3efe6; --paper-2: #ebe5d8; --ink: #1b1a17; --ink-2: #57534b; --ink-3: #8c867a;
  --rule: #1b1a17; --hair: #cfc7b6; --accent: #b8361d; --ok: #3d7a2e;
  --serif-cn: "Noto Serif SC", "Songti SC", "STSong", serif;
  --serif-en: "Playfair Display", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151412; --paper-2: #1d1c19; --ink: #ece6da; --ink-2: #b3ab9c; --ink-3: #7c7568;
    --rule: #ece6da; --hair: #38352f; --accent: #e0674b; --ok: #8cc06f;
    color-scheme: dark;
  }
}
@view-transition { navigation: auto; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif-cn); font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
code, kbd { font-family: var(--mono); font-size: .85em; }
kbd { border: 1px solid var(--hair); padding: 0 5px; }
[hidden] { display: none !important; }
.page { max-width: 1180px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
@media (min-width: 720px) { .page { padding: 0 40px 64px; } }
.spacer { flex: 1; }

/* ---------- 报头 ---------- */
.masthead { display: flex; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; padding: 14px 0 10px; font-size: 13px; color: var(--ink-2); letter-spacing: .04em; border-bottom: 3px double var(--rule); }
.masthead .issue { text-decoration: none; }
.masthead .home { margin-left: auto; text-decoration: none; border-bottom: 1px solid var(--hair); }
.masthead .home:hover { color: var(--accent); border-color: var(--accent); }
.tabs { display: flex; gap: 22px; }
.tabs a { text-decoration: none; font-size: 15px; color: var(--ink-3); padding-bottom: 2px; border-bottom: 1.5px solid transparent; letter-spacing: .1em; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current=page] { color: var(--ink); border-color: var(--accent); }
@media (max-width: 560px) { .masthead .issue { display: none; } .tabs { gap: 16px; } }

.hero { padding: 36px 0 24px; border-bottom: 1px solid var(--rule); display: grid; gap: 12px; }
@media (min-width: 880px) { .hero { grid-template-columns: auto 1fr; align-items: end; gap: 48px; padding: 48px 0 28px; } }
.title { margin: 0; font-size: clamp(56px, 12vw, 128px); font-weight: 900; line-height: .95; letter-spacing: -.02em; }
.title em { font-family: var(--serif-en); font-weight: 400; font-size: .42em; color: var(--accent); margin-left: .2em; letter-spacing: 0; }
.deck { margin: 0; color: var(--ink-2); font-size: 16px; max-width: 28em; }
body.in-app .hero { padding: 24px 0 16px; }
body.in-app .title { font-size: clamp(40px, 7vw, 64px); }
body.in-app .deck { display: none; }

.kicker { display: flex; align-items: baseline; gap: 14px; margin: 36px 0 14px; font-size: 13px; letter-spacing: .2em; color: var(--ink-2); font-weight: 400; }
.kicker b { font-weight: 600; color: var(--ink); letter-spacing: .3em; }
.kicker i { font-family: var(--serif-en); letter-spacing: .02em; font-size: 15px; }
.kicker::after { content: ""; flex: 1; border-bottom: 1px solid var(--rule); transform: translateY(-4px); }

/* ---------- 通用控件 ---------- */
.btn { background: none; border: 0; padding: 8px 0 8px 16px; cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--accent); }
.btn.solid { background: var(--ink); color: var(--paper); padding: 12px 26px; font-size: 16px; letter-spacing: .08em; }
.btn.solid:hover { background: var(--accent); color: var(--paper); }
.btn:disabled { opacity: .5; cursor: progress; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); border-bottom: 1px solid var(--hair); white-space: nowrap; }
.link:hover { color: var(--accent); border-color: var(--accent); }
.link.danger { color: var(--accent); }
.link.done { color: var(--ok); border-color: var(--ok); }
.seg { display: inline-flex; }
.seg button { background: none; border: 0; border-bottom: 1px solid transparent; padding: 0 8px; cursor: pointer; color: var(--ink-3); }
.seg button[aria-pressed=true] { color: var(--ink); border-color: var(--accent); }
.seg.big button { font-size: 16px; padding: 2px 10px; letter-spacing: .1em; }
.seg.big button:first-child { padding-left: 0; }
.field { display: flex; border-bottom: 1px solid var(--rule); }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 10px 0; font-family: var(--mono); font-size: 16px; letter-spacing: .1em; }
input[type=search], select { background: transparent; border: 0; border-bottom: 1px solid var(--hair); padding: 4px 2px; font-size: 14px; outline: 0; border-radius: 0; }
input[type=search]:focus, select:focus { border-color: var(--ink); }
select { cursor: pointer; }
.err { min-height: 1.7em; margin: 10px 0 0; color: var(--accent); font-size: 14px; }
.aside { margin: 14px 0 0; font-size: 14px; color: var(--ink-3); }
.empty { padding: 32px 0; color: var(--ink-3); font-style: italic; }
.code { margin: 6px 0 0; padding: 7px 10px; background: var(--paper-2); border: 1px solid var(--hair); font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--ink); white-space: pre; overflow-x: auto; }

/* ---------- 进门 ---------- */
.login { max-width: 440px; padding-bottom: 24px; }
#login-passkey, #setup-form { margin-top: 24px; }

/* ---------- 冲洗台 ---------- */
.drop { position: relative; display: grid; place-items: center; text-align: center; min-height: 220px; padding: 32px 16px; border: 1px dashed var(--ink-3); cursor: pointer; transition: background .2s, border-color .2s; }
.drop:hover, .drop.over { background: var(--paper-2); border-color: var(--accent); }
.drop.over { border-style: solid; }
.drop strong { display: block; font-size: clamp(26px, 5vw, 38px); font-weight: 900; }
.drop small { display: block; margin-top: 6px; color: var(--ink-3); font-size: 14px; }
.drop input { display: none; }
.opts { display: flex; flex-wrap: wrap; gap: 8px 26px; align-items: center; padding: 12px 0; font-size: 14px; color: var(--ink-2); border-bottom: 1px solid var(--hair); }
.opts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opts input[type=checkbox], .opts input[type=range] { accent-color: var(--accent); }
.opts input[type=range] { width: 90px; }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.queue img { width: 56px; height: 56px; object-fit: cover; background: var(--paper-2); display: block; }
.queue .name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .meta { font-size: 13px; color: var(--ink-3); }
.queue .meta.ok { color: var(--ok); }
.queue .meta.bad { color: var(--accent); }
.queue .acts { align-self: end; font-size: 14px; padding-bottom: 7px; }
.progress { height: 2px; background: var(--hair); margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- 底片库 ---------- */
.lib-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 22px 0 12px; border-bottom: 1px solid var(--rule); }
.lib-bar input[type=search] { width: 160px; }
.selbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 0; background: var(--paper); border-bottom: 1px solid var(--hair); font-size: 14px; }
#view-library:not(.trash) .trash-only, #view-library.trash .sheet-only { display: none !important; }
.lib { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
@media (min-width: 900px) { .lib { grid-template-columns: minmax(0, 1fr) 340px; } }
.group h3 { display: flex; align-items: baseline; gap: 10px; margin: 24px 0 10px; font-size: 18px; font-weight: 600; }
.group h3 small { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } }
.cell { position: relative; display: block; padding: 0; border: 0; background: var(--paper-2); aspect-ratio: 1; cursor: pointer; overflow: hidden; outline-offset: 2px; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.cell:hover img { transform: scale(1.04); }
.cell[aria-current=true] { outline: 2px solid var(--accent); }
.cell .tick { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #fff; background: rgba(0, 0, 0, .25); display: none; }
.multi .cell .tick { display: block; }
.cell[aria-pressed=true] .tick { background: var(--accent); border-color: var(--accent); }
.cell[aria-pressed=true] .tick::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cell[aria-pressed=true] img { opacity: .75; }
.cell .left { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .45); text-align: left; }

/* 详情：宽屏是右侧一栏，窄屏是底部抽屉 */
.detail { align-self: start; position: sticky; top: 16px; padding-top: 24px; }
.detail .preview { display: grid; place-items: center; background: var(--paper-2); border: 1px solid var(--hair); min-height: 180px; max-height: 52vh; overflow: hidden; }
.detail .preview img { max-width: 100%; max-height: 52vh; display: block; object-fit: contain; }
.detail h4 { margin: 12px 0 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.4; }
.detail .facts { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); font-family: var(--mono); line-height: 1.6; }
.detail .fmt { margin-top: 14px; font-size: 14px; }
.detail .fmt .seg button:first-child { padding-left: 0; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; font-size: 14px; }
.detail .nav { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--ink-3); }
.detail .hint { color: var(--ink-3); font-size: 14px; border-top: 1px solid var(--hair); padding-top: 12px; }
.detail .close { display: none; }
@media (max-width: 899px) {
  .detail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 20; max-height: 88vh; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 3px double var(--rule); transform: translateY(105%); transition: transform .25s ease; }
  .detail.open { transform: none; }
  .detail .hint { display: none; }
  .detail .close { display: inline; position: absolute; top: 10px; right: 16px; }
  .detail .preview { margin-top: 26px; }
}

/* ---------- 设置 ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--hair); }
.rows li b { font-weight: 600; }
.rows li small { color: var(--ink-3); font-size: 13px; }
.usage { font-size: 15px; }
.usage .bar { height: 3px; background: var(--hair); margin: 10px 0 6px; max-width: 520px; }
.usage .bar i { display: block; height: 100%; background: var(--ink); }
.usage small { color: var(--ink-3); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 30; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--paper); padding: 8px 18px; font-size: 14px; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.colophon { margin-top: 56px; padding-top: 14px; border-top: 3px double var(--rule); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: 13px; color: var(--ink-3); }

/* 上传令牌 */
form.inline { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
form.inline label { font-size: 14px; white-space: nowrap; }
form.inline input[type=checkbox] { accent-color: var(--accent); }
form.inline input:not([type]) { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid var(--hair); padding: 4px 2px; font-size: 14px; outline: 0; border-radius: 0; color: inherit; }
form.inline input:focus { border-color: var(--ink); }
.token-new { margin-top: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.token-new p { flex-basis: 100%; margin: 0; }
.token-new code { word-break: break-all; user-select: all; }

/* 文件：没有缩略图时显示扩展名 */
.cell .file { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--hair); color: var(--ink-2); }
.cell .file b { font-family: var(--mono); font-size: 18px; letter-spacing: .06em; color: var(--accent); }
.cell .file small { font-size: 11px; color: var(--ink-3); width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell[aria-pressed=true] .file { opacity: .75; }
.queue .ext, .detail .preview .ext { display: grid; place-items: center; width: 56px; height: 56px; background: var(--paper-2); font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.detail .preview .ext { width: auto; height: auto; font-size: 28px; background: none; }
.detail .preview.text, .detail .preview.pdf { display: block; }
.detail .preview .text { margin: 0; padding: 12px; max-height: 52vh; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.detail .preview iframe { display: block; width: 100%; height: 52vh; border: 0; background: #fff; }
.detail .preview video { display: block; max-width: 100%; max-height: 52vh; }
.detail .preview audio { width: calc(100% - 24px); }
