:root {
  color-scheme: light;
  --bg: #eeece7;
  --paper: #f7f5ef;
  --ink: #171714;
  --soft: #68655f;
  --faint: #918d84;
  --line: #aaa69d;
  --hair: rgba(23, 23, 20, .23);
  --accent: #d97757;
  --accent-soft: rgba(217, 119, 87, .11);
  --sans: "DengXian", "等线", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --serif: "STZhongsong", "华文中宋", "Songti SC", "Noto Serif CJK SC", serif;
  --mono: "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171716;
  --paper: #211f1c;
  --ink: #eeeae1;
  --soft: #aaa69e;
  --faint: #817d76;
  --line: #5e5a54;
  --hair: rgba(238, 234, 225, .2);
  --accent: #e58a68;
  --accent-soft: rgba(229, 138, 104, .14);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: var(--sans); transition: color .25s, background .25s; }
button, input { font: inherit; }
button { color: inherit; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; height: 68px; margin: 0 auto; padding: 0 max(4vw, 28px); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px); }
.topbar::after { position: absolute; right: max(4vw, 28px); bottom: 0; left: max(4vw, 28px); height: 1px; content: ""; background: var(--ink); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand i, footer i { width: 12px; height: 12px; background: var(--accent); }
.brand b, footer b { font-family: var(--serif); font-size: 18px; }
.topbar nav { display: flex; align-items: stretch; height: 100%; }
.topbar button { min-width: 44px; border: 0; padding: 0 16px; background: transparent; cursor: pointer; font-weight: 700; }
.topbar button:hover { color: var(--paper); background: var(--ink); }
main { width: min(1500px, calc(100% - 8vw)); margin: auto; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(40px, 8vw, 130px); align-items: end; min-height: 610px; padding: 80px 2vw 90px; border-bottom: 1px solid var(--ink); }
.folio { margin: 0 0 22px; color: var(--soft); font: 700 11px/1.3 var(--mono); letter-spacing: .12em; }
.hero h1 { max-width: 780px; margin: 0; font-family: var(--serif); font-size: clamp(54px, 6.5vw, 104px); line-height: .98; letter-spacing: -.06em; }
.hero-copy > p:last-child { max-width: 620px; margin: 38px 0 0; color: var(--soft); font-family: var(--serif); font-size: 18px; line-height: 1.8; }
.upload-card { position: relative; padding: 26px; border: 1px solid var(--ink); background: var(--paper); box-shadow: 18px 18px 0 var(--accent-soft); }
.upload-card::before { position: absolute; top: -11px; right: 24px; content: "UPLOAD"; padding: 3px 8px; color: var(--paper); background: var(--ink); font: 700 10px var(--mono); letter-spacing: .12em; }
.invite-field span { display: block; margin-bottom: 8px; color: var(--soft); font-size: 12px; font-weight: 700; }
.invite-field input { width: 100%; height: 45px; border: 0; border-bottom: 1px solid var(--ink); padding: 0 2px; color: var(--ink); background: transparent; outline: none; }
.invite-field input:focus { border-color: var(--accent); }
.drop-zone { display: grid; place-items: center; min-height: 210px; margin-top: 26px; border: 1px dashed var(--line); cursor: pointer; text-align: center; transition: .18s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone input { display: none; }
.drop-zone strong { display: block; max-width: 90%; font-family: var(--serif); font-size: 23px; overflow-wrap: anywhere; }
.drop-zone small { display: block; margin-top: -60px; color: var(--soft); }
.privacy-option { display: flex; align-items: flex-start; gap: 11px; margin-top: 18px; cursor: pointer; }
.privacy-option input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.privacy-option span { display: grid; gap: 3px; }
.privacy-option b { font-size: 13px; }
.privacy-option small { color: var(--soft); font-size: 11px; }
.retention-copy { margin: 14px 0 0; color: var(--soft); font-size: 11px; line-height: 1.6; }
.upload-actions { display: flex; align-items: center; gap: 18px; margin-top: 20px; }
.primary, .back, .reader-actions button, .view-tabs button { border: 0; cursor: pointer; }
.primary { min-width: 142px; height: 44px; color: var(--paper); background: var(--ink); font-weight: 800; }
.primary:hover { background: var(--accent); }
.primary:disabled { opacity: .5; cursor: wait; }
#uploadState { color: var(--soft); font-size: 12px; }
.upload-meter { height: 2px; margin-top: 18px; background: var(--hair); }
.upload-meter i, .progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }
.archive { padding: 70px 2vw 120px; }
.archive > header, .reader-head { display: flex; align-items: end; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--ink); }
h2 { margin: 0; font-family: var(--serif); font-size: clamp(34px, 4vw, 58px); letter-spacing: -.04em; }
#serviceState { color: var(--soft); font: 12px var(--mono); }
.job-list { display: grid; grid-template-columns: repeat(3, 1fr); }
.job-card { position: relative; min-height: 190px; border-bottom: 1px solid var(--hair); padding: 24px; cursor: pointer; background: transparent; transition: .18s; }
.job-card:not(:nth-child(3n+1)) { border-left: 1px solid var(--hair); }
.job-card:hover { color: var(--paper); background: var(--ink); }
.job-card .number { color: var(--accent); font: 700 11px var(--mono); }
.job-card h3 { margin: 22px 0 32px; font-family: var(--serif); font-size: 24px; line-height: 1.2; }
.job-meta { display: flex; justify-content: space-between; color: var(--soft); font: 11px var(--mono); }
.job-card:hover .job-meta { color: color-mix(in srgb, var(--paper) 68%, transparent); }
.empty { grid-column: 1 / -1; padding: 70px 24px; color: var(--soft); text-align: center; }
.reader { padding: 46px 0 70px; }
.back { margin-bottom: 22px; padding: 0; color: var(--soft); background: transparent; font-weight: 700; }
.back:hover { color: var(--accent); }
.reader-head h2 { max-width: 900px; font-size: clamp(30px, 3.4vw, 52px); overflow-wrap: anywhere; }
.reader-actions { display: flex; gap: 1px; background: var(--line); }
.reader-actions button { min-height: 42px; padding: 0 15px; background: var(--paper); font-weight: 750; }
.reader-actions button:hover { color: var(--paper); background: var(--accent); }
.status-strip { display: grid; grid-template-columns: 150px 110px 1fr 240px; align-items: center; min-height: 52px; border-bottom: 1px solid var(--hair); color: var(--soft); font: 11px var(--mono); }
.unlisted-notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 15px; border-bottom: 1px solid var(--hair); color: var(--soft); background: var(--accent-soft); font-size: 12px; }
.unlisted-notice[hidden] { display: none; }
.unlisted-notice b { color: var(--ink); }
.unlisted-notice button { flex: 0 0 auto; border: 0; padding: 8px 12px; color: var(--paper); background: var(--ink); cursor: pointer; font-weight: 700; }
.unlisted-notice button:hover { background: var(--accent); }
.retention-notice { padding: 9px 15px; border-bottom: 1px solid var(--hair); color: var(--soft); font-size: 11px; }
.progress { height: 2px; background: var(--hair); }
.reader-grid { display: grid; grid-template-columns: 76px minmax(340px, 1fr) minmax(380px, 1fr); height: calc(100vh - 260px); min-height: 570px; border-bottom: 1px solid var(--ink); }
.page-rail { overflow: auto; border-right: 1px solid var(--hair); padding: 10px 8px; scrollbar-width: thin; }
.page-button { display: grid; place-items: center; width: 100%; height: 48px; border: 0; border-bottom: 1px solid var(--hair); color: var(--soft); background: transparent; cursor: pointer; font: 11px var(--mono); }
.page-button[data-status="complete"]::after { width: 5px; height: 5px; margin-top: 3px; border-radius: 50%; content: ""; background: #52785f; }
.page-button.active { color: var(--paper); background: var(--ink); }
.source-pane, .ocr-pane { display: grid; grid-template-rows: 46px minmax(0, 1fr); min-width: 0; background: var(--paper); }
.source-pane { border-right: 1px solid var(--ink); }
.source-pane > header, .ocr-pane > header { display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--hair); font-size: 12px; }
.source-pane > header span { color: var(--soft); font: 10px var(--mono); }
#pdfFrame, #htmlFrame { width: 100%; height: 100%; border: 0; background: #777; }
#htmlFrame { background: var(--paper); }
.view-tabs { display: flex; align-self: stretch; }
.view-tabs button { padding: 0 12px; color: var(--soft); background: transparent; font: 10px var(--mono); }
.view-tabs button.active { color: var(--paper); background: var(--ink); }
#textView { min-width: 0; margin: 0; overflow: auto; padding: 28px; color: var(--ink); background: var(--paper); font: 13px/1.7 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
footer { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 120px; color: var(--soft); }
footer span { margin-left: 10px; font: 10px var(--mono); }
footer a { color: inherit; text-underline-offset: 3px; }
footer a:hover { color: var(--accent); }

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr; padding-top: 60px; }
  .job-list { grid-template-columns: repeat(2, 1fr); }
  .job-card:not(:nth-child(3n+1)) { border-left: 0; }
  .job-card:nth-child(even) { border-left: 1px solid var(--hair); }
  .reader-grid { grid-template-columns: 62px 1fr; height: auto; }
  .source-pane, .ocr-pane { height: 70vh; }
  .ocr-pane { grid-column: 2; border-top: 1px solid var(--ink); }
  .page-rail { grid-row: 1 / span 2; }
  .status-strip { grid-template-columns: 100px 80px 1fr 160px; }
}
@media (max-width: 680px) {
  main { width: calc(100% - 28px); }
  .topbar { padding: 0 14px; }
  .topbar::after { right: 14px; left: 14px; }
  .hero { min-height: 0; padding: 46px 0 60px; }
  .hero h1 { font-size: 48px; }
  .upload-card { padding: 19px; box-shadow: 8px 8px 0 var(--accent-soft); }
  .archive { padding: 50px 0 80px; }
  .job-list { grid-template-columns: 1fr; }
  .job-card:nth-child(even) { border-left: 0; }
  .reader-head { align-items: stretch; flex-direction: column; gap: 24px; }
  .reader-actions { align-self: stretch; }
  .reader-actions button { flex: 1; }
  .status-strip { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 0; }
  .status-strip .progress { grid-column: 1 / -1; }
  .unlisted-notice { align-items: flex-start; flex-direction: column; }
  .reader-grid { grid-template-columns: 48px minmax(0, 1fr); min-height: 0; }
  .source-pane, .ocr-pane { height: 68vh; }
  footer { flex-wrap: wrap; padding: 28px 18px; text-align: center; }
  footer span { flex-basis: 100%; margin: 2px 0 0; line-height: 1.7; }
}

@media (prefers-reduced-motion: no-preference) {
  .hero-copy, .upload-card { animation: enter .5s cubic-bezier(.2,.7,.2,1) both; }
  .upload-card { animation-delay: .08s; }
  @keyframes enter { from { opacity: 0; transform: translateY(18px); } }
}
