:root {
  color-scheme: light;
  --bg: #ffffff; --panel: #ffffff; --line: #d5dee5; --ink: #1f2937; --muted: #526173;
  --accent: #087f70; --danger: #b42318; --radius: 10px;
}
* { box-sizing: border-box; }
/* Author display rules must never override the application's hidden state. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; letter-spacing: .3px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.topbar { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97);
  position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 12px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(72,179,162,.15); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.who strong { color: var(--ink); }
.flag { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--accent); }
main { padding: 20px 22px 60px; max-width: 1280px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
button { background: var(--accent); color: #ffffff; border: none; border-radius: 8px;
  padding: 8px 14px; font-weight: 600; cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.danger { background: transparent; color: var(--danger); border: 1px solid #e6aaa5; }
input, select, textarea { width: 100%; background: #ffffff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
label input, label select, label textarea { margin-top: 4px; color: var(--ink); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.error { color: var(--danger); font-size: 12px; }
.login-wrap { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: min(380px, 92vw); }
.login-card button { width: 100%; margin-top: 16px; }
.filters { margin-bottom: 16px; }
.filter-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filter-row label { margin: 0; min-width: 160px; flex: 0 1 200px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--accent); }
.chip button { background: none; border: none; color: var(--muted); padding: 0 2px; }
.status { color: var(--muted); font-size: 12px; min-height: 18px; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.page-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; }
.thumb { background: #f3f6f8; display: block; width: 100%; height: 170px; object-fit: contain; }
.meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.report-name { font-weight: 600; word-break: break-word; }
.tagline { color: var(--muted); font-size: 12px; }
.pairs { display: flex; flex-direction: column; gap: 6px; }
.pair { border-left: 2px solid var(--accent); padding-left: 8px; font-size: 12px; }
.pair .note { color: var(--muted); }
.pair .actions { display: flex; gap: 8px; margin-top: 4px; }
.pair .actions button { padding: 2px 8px; font-size: 11px; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.downloads a { color: var(--accent); font-size: 12px; text-decoration: none; border-bottom: 1px dotted var(--accent); }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 22px; color: var(--muted); }
.editor { position: fixed; top: 0; right: 0; width: min(420px, 96vw); height: 100vh; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); padding: 18px; z-index: 20; }
.editor-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 4px; }
.slot-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 12px 0; }
.slot-block h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.slot-block .empty { color: var(--muted); font-size: 12px; }
.pair-form { margin-top: 14px; }
.pair-form button { width: 100%; margin-top: 12px; }
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 0 20px 24px; }
@media (max-width: 640px) {
  main { padding: 14px 12px 50px; }
  .filter-row label { flex: 1 1 140px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .thumb { height: 130px; }
}

/* 导入 / 审核（v0.3.0） */
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.import-list, .review-list { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.import-row, .review-row {
  border: 1px solid rgba(0,0,0,.12); border-radius: 10px; padding: .75rem;
  display: flex; flex-direction: column; gap: .35rem; background: #fff;
}
.review-row { flex-direction: row; gap: .9rem; align-items: flex-start; }
.import-head { display: flex; gap: .5rem; align-items: center; }
.chip.good { background: #e6f5ec; color: #17663a; }
.chip.bad { background: #fdecea; color: #8a1c13; }
.thumb.small { width: 150px; height: auto; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); }
.review-meta { display: flex; flex-direction: column; gap: .3rem; flex: 1; }

/* Workspace shell and overlays follow the v0.3.3 prototype. */
:root {
  --bg: #f3f6f8;
  --ink: #203244;
  --muted: #64788a;
  --line: #dae3e9;
  --accent: #087b67;
  --danger: #a23c38;
  --radius: 12px;
}
body { font: 15px/1.65 system-ui, sans-serif; }
.topbar { position: static; padding: 18px 32px; background: white; gap: 12px; }
.brand strong { font-size: 21px; }
.sub { margin: 0; font-size: inherit; }
.flag {
  display: inline-block;
  padding: 3px 10px;
  border: 0;
  border-radius: 20px;
  background: #e4f3ee;
  color: #086854;
  font-size: 12px;
}
.flag.wait { background: #fff1d6; color: #805b18; }
.flag.off { background: #e9edf0; color: #5f6c76; }
main { max-width: 1240px; padding: 26px; }
h1 { font-size: 27px; margin: 0 0 8px; letter-spacing: normal; }
h2 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 1.17em; margin: 0 0 8px; }
h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); }
button, button.ghost, a.link, #workspace-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 9px 16px;
  font: inherit;
  text-decoration: none;
}
button.primary, a.link.primary, #login-form button[type=submit], #ask-ok {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.danger { border-color: #e4bdbb; color: var(--danger); background: white; }
button:not(:disabled):hover, #workspace-nav a:hover, a.link:hover { filter: brightness(.96); }
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid #a06f16;
  outline-offset: 2px;
}
:where(input, select, textarea)[aria-invalid="true"] {
  border-color: #b3261e;
  box-shadow: 0 0 0 1px #b3261e, 0 0 0 3px #b3261e22;
}
:where(input, select, textarea)[aria-invalid="true"]:focus {
  outline: 2px solid #b3261e;
  outline-offset: 1px;
}
input, select, textarea { border-color: #bfcdd8; border-radius: 7px; padding: 9px; }
textarea { min-height: 78px; }
label, .case-filter > span { font-size: 14px; }
label:has(> input[required]), label:has(> select[required]) { font-weight: 600; }
input[type="checkbox"] { width: 18px; height: 18px; flex: none; vertical-align: middle; accent-color: var(--accent); }
#workspace-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
#workspace-nav a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: white; }
.top, .workspace-heading, .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top, .workspace-heading { justify-content: space-between; }
.workspace-heading { margin-bottom: 16px; }
.workspace-heading h2 { margin: 0; }
.row > label { align-self: center; }
.panel, .card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.panel { margin-bottom: 18px; }
.shell > section > p.sub, .top p.sub, .panel > p.sub { margin: 8px 0 18px; }
.shell > section > .top { min-width: 0; }
.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.status:empty, .error:empty { display: none; }
.field-error { display: block; margin-top: 5px; }
.error { font-size: 13px; font-weight: 600; color: #a12822; }
.empty { padding: 42px 14px; text-align: center; color: var(--muted); }
.workspace-grid, .case-wall-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid > .empty { grid-column: 1 / -1; }
.block-tools, .list-tools, #report-map-tools, #import-search-tools {
  margin: 10px 0 14px;
  color: var(--muted);
}
summary { cursor: pointer; }
.block-tools > .row, .block-management-item { margin-top: 12px; }
.block-card { overflow-wrap: anywhere; }
.block-card .sub { margin: 8px 0 18px; }
.block-card-actions { gap: 5px; }
.block-case { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.case-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.case-tools label, .inline-check { margin: 0; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; }

#case-wall-view { margin-top: 22px; scroll-margin-top: 16px; }
.case-wall-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.case-filter-actions { margin-top: 10px; }
.case-wall-filters > * {
  display: grid;
  grid-template-columns: 8em minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: inherit;
}
.case-wall-filters > label > select { width: 100%; min-width: 0; margin: 0; }
.filter-picker { position: relative; min-width: 0; }
.filter-picker summary {
  position: relative;
  border: 1px solid #bfcdd8;
  border-radius: 7px;
  background: white;
  cursor: pointer;
  padding: 9px 25px 9px 12px;
  line-height: 20px;
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-picker summary::after {
  content: "";
  position: absolute;
  right: 10px;
  top: calc(50% - 4px);
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.filter-picker select {
  position: absolute;
  z-index: 3;
  top: calc(100% + 3px);
  left: 0;
  width: 100%;
  box-shadow: 0 8px 18px #20324430;
}
.case-wall-grid { margin-top: 18px; }
.case-wall-card, .comparison-card { min-width: 0; overflow-wrap: anywhere; }
.case-wall-card h3 { margin-top: 8px; }
.case-wall-card small.sub { font-size: smaller; }
.case-wall-card p { margin: 8px 0 18px; }
.case-page-viewer > .row { margin-top: 8px; }
.art { aspect-ratio: 1.55; width: 100%; background: white; border-bottom: 1px solid var(--line); }
.case-image-viewport { width: 100%; aspect-ratio: 1.55; overflow: auto; background: #f5f8fa; border-bottom: 1px solid var(--line); }
.case-wall-card .case-image-viewport { display: grid; place-items: center; overflow: hidden; }
.case-wall-card .case-thumb { height: 100%; min-height: 0; }
.case-thumb { display: block; width: 100%; min-height: 100%; object-fit: contain; }
.case-tags p { margin: 3px 0; }

dialog:not([open]) { display: none; }
dialog {
  border: 0;
  border-radius: 14px;
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: 90dvh;
  overflow: auto;
  padding: 28px;
  background: white;
  color: var(--ink);
  box-shadow: 0 20px 100px #16293c40;
}
dialog::backdrop { background: #102a4355; }
dialog form > label { margin-bottom: 12px; }
#ask { width: min(440px, calc(100vw - 32px)); }
#ask .ask-card { display: flex; flex-direction: column; gap: 12px; padding: 0; border: 0; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }
#term-management { width: min(850px, calc(100vw - 32px)); }
.notice {
  background: #eef5f3;
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  margin: 16px 0;
}
.term-tree { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin: 14px 0; }
.term-list { padding-left: 0; margin: 0; list-style: none; }
.term-branch > .term-list { border-left: 2px solid #d9e5e3; padding-left: 18px; margin-left: 10px; }
.term-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #edf1f4; }
.term-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.term-caption small { width: 100%; margin: 0; }
.tagbox { border: 1px solid #d8e4e6; border-radius: 10px; padding: 14px; margin: 14px 0; background: #f8fbfa; }
.tagbox h3 { margin: 0; }
.tagbox h4 { margin: 12px 0 4px; }
.taggroup { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 10px 0 12px; }
.tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #dfe8ea;
  border-radius: 7px;
  padding: 8px;
  margin: 0;
  background: white;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.tag-option:has(:checked) { border-color: var(--accent); background: #eef5f3; }
.tag-option:has(:disabled) { opacity: .55; cursor: default; }
.tag-option input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--accent); }
.tag-provenance > .row { margin: 6px 0; }
.tag-provenance :is(select,input) { width: auto; }
.term-edit-modes { border: 0; padding: 0; margin: 12px 0; }

#case-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(500px, 100vw);
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  box-shadow: -20px 0 60px #182d4630;
}
#case-pages .row { margin: 8px 0; }
#case-comparison { width: min(1160px, calc(100vw - 32px)); }
#case-comparison input[type="range"] { max-width: 300px; vertical-align: middle; }
.case-comparison-scroll { overflow-x: auto; max-width: 100%; }
.case-comparison-row { display: grid; gap: 16px; align-items: start; }
.comparison-card .case-image-viewport { height: min(40vh, 350px); aspect-ratio: auto; }
#page-preview { width: auto; max-width: 94vw; }
#page-preview img { display: block; max-width: 88vw; max-height: 78vh; object-fit: contain; }
#report-title { margin-top: 12px; }
#reports-list, #trash-list { margin-top: 10px; }
#report-pages { margin-top: 16px; }
.report-summary { min-width: 0; overflow-wrap: anywhere; }
.list-search { gap: 8px; }
.list-search input { width: min(15rem,100%); }
.list-search :is(input,button), :is(#reports-browser,#trash-view,#import-view) .pager button { font-size: .9em; padding: 5px 10px; }
.page-picker { padding: 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
#report-pages .page-card:has(input:checked) { outline: 2px solid var(--accent); }
#report-pages .page-card { padding: 0; }
#report-pages button { width: 100%; padding: 0 0 7px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
#report-pages .thumb { width: 100%; height: auto; }
#selection-bar {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: 0 8px 30px #20324430;
}
.mapping-row { display: flex; gap: 10px; align-items: center; }
.mapping-row input { width: 90px; }
#import-view .import-row { overflow-wrap: anywhere; }
#import-form .field, #case-form .field { display: block; margin: 0 0 16px; color: var(--ink); font-size: inherit; font-weight: 400; }
.field b { color: #a43c38; }
#import-form .field :is(input,select) { display: inline-block; width: auto; margin: 0; vertical-align: middle; }
#import-form .field input { width: min(334px,100%); }
#import-form .field select { width: min(175px,100%); }
#case-form .field :is(input,select,textarea) { display: block; }
.import-actions { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
#import-advanced { flex: 0 1 min(420px,100%); color: var(--muted); }
#import-advanced summary { padding: 9px 0; }
#queue-tools:has(+ #upload-queue:empty), #upload-selection:empty, #import-progress:empty { display: none; }
#app31-status { overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .topbar { padding: 16px; align-items: flex-start; flex-direction: column; }
  main { padding: 16px; }
  .panel, .card, dialog { padding: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-wall-filters, .taggroup { grid-template-columns: 1fr; }
  .row button { padding: 7px 10px; }
  .workspace-heading, .term-row { align-items: flex-start; flex-wrap: wrap; }
  .block-card-actions button { padding: 9px 16px; }
  .review-row { flex-direction: column; }
}
@media (max-width: 450px) {
  .row > label { max-width: 100%; }
  #case-comparison { width: calc(100vw - 20px); }
}
@media (max-width: 360px) {
  .workspace-grid, .case-wall-grid { grid-template-columns: 1fr; }
}
