/* 青卷 · 命题工坊 UI */
:root {
  --ink: #161310;
  --ink-2: #2a2521;
  --panel: #201c19;
  --panel-2: #2b2622;
  --line: #3a342e;
  --mist: #9a9186;
  --paper: #f3eee4;
  --paper-2: #e8e1d4;
  --celadon: #3f746c;
  --celadon-2: #cfe4de;
  --cinnabar: #c45c4a;
  --cinnabar-2: #f3d4ce;
  --gold: #c4a574;
  --ok: #6b9e78;
  --shadow: 0 18px 50px rgba(22, 19, 16, 0.22);
  --sans: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: #1a1714;
  color: var(--paper);
  overflow: hidden;
}

#app {
  height: 100%;
  display: grid;
  grid-template-rows: 56px 3px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 12px;
  background: linear-gradient(180deg, #241f1b, #1c1916);
  border-bottom: 1px solid #3a322b;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}
.seal {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--cinnabar);
  outline: 1px solid var(--cinnabar);
  outline-offset: 2px;
  color: var(--cinnabar);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  transform: rotate(-8deg);
  background: rgba(196, 92, 74, 0.08);
}
.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.18em;
  font-family: var(--serif);
}
.brand small {
  display: block;
  color: var(--mist);
  font-size: 10px;
  letter-spacing: 0.22em;
  margin-top: 1px;
  font-weight: 400;
}

.view-switch {
  display: flex;
  background: #14110f;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.view-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--mist);
  font: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.06em;
}
.view-switch button.on {
  background: var(--celadon);
  color: #f4fff9;
}

.top-status {
  flex: 1;
  font-size: 12px;
  color: var(--mist);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-status.busy { color: var(--gold); }

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

button {
  font-family: inherit;
  cursor: pointer;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--paper);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.btn:hover { border-color: var(--gold); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: #f0b8af; border-color: #6a3a32; }
.btn.primary {
  background: var(--cinnabar);
  border-color: #9a4034;
  color: #fffaf7;
  padding: 8px 16px;
  font-weight: 650;
  letter-spacing: 0.12em;
  box-shadow: 0 6px 18px rgba(196, 92, 74, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled {
  opacity: 0.55;
  cursor: wait;
  filter: grayscale(0.3);
}
.btn .k {
  opacity: 0.55;
  font-size: 10px;
  margin-left: 6px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  min-height: 0;
}
.workspace.no-inspector {
  grid-template-columns: 320px 1fr;
}
.workspace.no-inspector .inspector { display: none; }

.rail, .inspector {
  background: var(--panel);
  border-right: 1px solid #322c27;
  overflow: auto;
  min-height: 0;
}
.inspector {
  border-right: 0;
  border-left: 1px solid #322c27;
}
.rail-h, .inspector > .ins-h {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px 10px;
  background: linear-gradient(180deg, #26211d, #201c19 80%);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 12px 12px 4px;
}
.preset {
  text-align: left;
  background: #181512;
  border: 1px solid #3a332d;
  color: var(--paper);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
}
.preset:hover { border-color: var(--celadon); }
.preset b { display: block; font-weight: 650; }
.preset span { color: var(--mist); font-size: 10.5px; }

details.acc {
  border-bottom: 1px solid #2e2925;
}
details.acc > summary {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: #ddd4c8;
  display: flex;
  justify-content: space-between;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after {
  content: "＋";
  color: var(--mist);
  font-size: 11px;
}
details.acc[open] > summary::after { content: "－"; }
.acc-body { padding: 4px 14px 14px; display: grid; gap: 8px; }

label.f {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--mist);
  letter-spacing: 0.06em;
}
label.f > span.row {
  display: flex;
  justify-content: space-between;
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  background: #14110f;
  border: 1px solid #3d362f;
  color: var(--paper);
  border-radius: 7px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  border-color: var(--celadon);
  box-shadow: 0 0 0 3px rgba(63, 116, 108, 0.2);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: #d7cfc4;
}
.checks label { display: flex; gap: 6px; align-items: center; cursor: pointer; }

.seg {
  background: #181512;
  border: 1px solid #3a332d;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
}
.seg-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #e6ddd2;
}
.seg-h b { letter-spacing: 0.04em; }
.tiny { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
#section-list { display: grid; gap: 8px; }
.add-sec {
  width: 100%;
  border-style: dashed;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid #3a332d;
  background: #181512;
  color: #d7cfc4;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.chip.on { border-color: var(--celadon); color: #dff3ee; background: #1a2a27; }

.stage {
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.12) 1px, transparent 0) 0 0 / 4px 4px,
    linear-gradient(180deg, #c8cfc3, #b7bfb2);
  position: relative;
  overflow: auto;
}
.stage-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(26,23,20,0.55), transparent);
  color: #243028;
  font-size: 12px;
  pointer-events: none;
}
.stage-bar > * { pointer-events: auto; }
.zoom {
  display: flex;
  gap: 4px;
  background: rgba(255,252,247,0.72);
  padding: 3px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}
.zoom button {
  border: 0;
  background: transparent;
  width: 28px;
  height: 24px;
  border-radius: 6px;
  color: #243028;
}
.zoom button.on, .zoom button:hover { background: #fff; }

#pages {
  padding: 18px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  transform-origin: top center;
}
.a4-page {
  box-shadow: var(--shadow), 0 0 0 1px rgba(40, 30, 20, 0.08);
}

.empty {
  margin: 12vh auto;
  width: min(420px, 90%);
  text-align: center;
  color: #314039;
  background: rgba(255,252,247,0.55);
  border: 1px dashed #7d8a80;
  border-radius: 16px;
  padding: 36px 24px;
}
.empty h2 {
  font-family: var(--serif);
  letter-spacing: 0.2em;
  margin: 0 0 8px;
}
.empty p { margin: 0 0 16px; opacity: 0.8; font-size: 13px; }

.inspector .box { padding: 12px 14px; display: grid; gap: 8px; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: #181512;
  border: 1px solid #3a332d;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stat b { display: block; font-size: 18px; font-family: var(--serif); }
.stat span { font-size: 10px; color: var(--mist); letter-spacing: 0.08em; }
.k-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.k-tags span {
  font-size: 11px;
  background: #1a2a27;
  color: #cfe4de;
  padding: 3px 8px;
  border-radius: 999px;
}

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: #2b2622;
  border: 1px solid #4a4038;
  color: var(--paper);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 320px;
}
.toast.err { border-color: #8a3d34; background: #3a221f; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 8, 0.55);
  display: none;
  place-items: center;
  z-index: 40;
}
.modal-mask.show { display: grid; }
.modal {
  width: min(480px, 92vw);
  background: #241f1b;
  border: 1px solid #3e372f;
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal h3 {
  margin: 0 0 12px;
  font-family: var(--serif);
  letter-spacing: 0.12em;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.progress {
  height: 3px;
  background: #14110f;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: slide 1.1s infinite;
}
@keyframes slide {
  from { transform: translateX(-120%); }
  to { transform: translateX(400%); }
}
.progress.off { visibility: hidden; }

.drop-hint {
  border: 1px dashed #4a4038;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: var(--mist);
  font-size: 12px;
}
.fig-prev {
  background: #fffef9;
  border-radius: 8px;
  padding: 8px;
  min-height: 48px;
}
.fig-prev svg, .fig-prev img { max-width: 100%; height: auto; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 280px 1fr; }
  .inspector { position: fixed; right: 0; top: 56px; bottom: 0; width: min(320px, 92vw); z-index: 15; }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    left: 0; top: 56px; bottom: 0;
    width: min(320px, 92vw);
    z-index: 16;
    transform: translateX(-105%);
    transition: transform .2s;
  }
  .rail.open { transform: none; }
}

.batch-note { color:var(--mist); font-size:12px; line-height:1.6; margin:0; }
.editor-tools { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
#batch-results { display:grid; gap:6px; }

[hidden] { display:none !important; }

.is-locked .workspace { opacity:.35; user-select:none; }
.settings-state { color:var(--celadon); margin-bottom:16px; font-size:13px; }
.settings-error { color:#ed9b8c; font-size:13px; min-height:1em; }
.settings-facts { display:grid; grid-template-columns:90px 1fr; gap:10px; font-size:13px; }
.settings-facts dt { color:var(--mist); }
.settings-facts dd { margin:0; overflow-wrap:anywhere; }
.settings-dialog { max-height:85vh; overflow:auto; }

#learning-topics { display:grid; gap:8px; max-height:260px; overflow:auto; font-size:12px; line-height:1.6; }
.learning-topic { display:flex; gap:7px; align-items:baseline; overflow-wrap:anywhere; }
#learning-preview { display:grid; gap:8px; padding:10px; border:1px solid var(--line); border-radius:8px; }
.practice-overlay { position:fixed; inset:0; z-index:45; overflow:auto; background:#191613; color:var(--paper); }
.practice-shell { max-width:1000px; margin:auto; padding:0 20px 50px; }
.practice-header { position:sticky; top:0; z-index:2; display:flex; gap:15px; align-items:center; justify-content:space-between; background:#211c18; padding:14px 0; border-bottom:1px solid var(--line); }
.practice-header h2 { font:22px var(--serif); margin:0 0 7px; }.practice-header p { color:var(--celadon); font-size:13px; margin:0; line-height:1.5; }
.practice-actions { display:flex; gap:7px; flex-wrap:wrap; }.practice-notice { font-size:12px; color:var(--mist); line-height:1.8; }
.practice-question { background:#fff; color:#111; border-radius:9px; padding:22px; margin:16px 0; line-height:1.85; overflow-wrap:anywhere; }
.practice-question-meta { color:#666; font-size:12px; border-bottom:1px solid #ddd; padding-bottom:9px; margin-bottom:12px; }.practice-stem { font-weight:600; white-space:pre-wrap; }
.practice-context,.practice-passage>div { white-space:pre-wrap; }.practice-passage { background:#f7f7f7; padding:12px; margin-bottom:12px; }.practice-passage summary { cursor:pointer; }
.practice-options { display:grid; gap:10px; margin:14px 0; }.practice-option { display:flex; gap:12px; align-items:baseline; padding:10px; border:1px solid #ddd; border-radius:6px; cursor:pointer; }.practice-option input { flex:none; accent-color:#47675e; }
.practice-question .practice-text { display:block; width:100%; box-sizing:border-box; margin-top:16px; padding:14px; background:#fff; color:#111; border:1px solid #aaa; border-radius:6px; font-family:inherit; font-size:16px; line-height:1.8; resize:vertical; }.practice-text:disabled { background:#fafafa; opacity:1; }
.practice-ink-tools { display:flex; gap:6px; flex-wrap:wrap; margin:12px 0; }.practice-canvas { display:block; width:100%; aspect-ratio:1024/480; background:#fff; border:1px solid #888; border-radius:5px; touch-action:none; cursor:crosshair; }.practice-upload-preview { max-width:100%; max-height:500px; border:1px solid #ccc; background:#fff; }
.practice-hint { font-size:12px; color:#666; }.practice-upload-label { display:flex; gap:5px; flex-wrap:wrap; align-items:center; font-size:12px; }.practice-upload-label input { max-width:230px; }.practice-feedback { margin-top:20px; padding:15px; background:#f1f6f3; border-left:3px solid #547466; white-space:pre-wrap; }.practice-feedback.needs-review { background:#fff7e8; border-color:#a57a31; }
.practice-result { padding:18px; background:#263e35; border:1px solid #57766a; border-radius:8px; font-size:20px; }.practice-figure { max-width:600px; margin:15px auto; }.practice-figure svg { max-width:100%; max-height:350px; }.practice-history-item { display:block; width:100%; padding:18px; margin:12px 0; text-align:left; background:#29231e; color:var(--paper); border:1px solid var(--line); border-radius:8px; cursor:pointer; font:inherit; }.practice-empty { padding:40px 0; color:var(--mist); }
@media(max-width:700px) { .practice-header { flex-direction:column; align-items:stretch; }.practice-shell { padding:0 10px 30px; }.practice-question { padding:15px; }.top-actions { gap:4px; flex-wrap:wrap; } }

.practice-question .btn.ghost { color:#333; border-color:#aaa; background:#f5f5f5; }
.practice-question .btn.on { outline:2px solid #47675e; }

.practice-header p { color:var(--celadon-2); }
.blueprint-toggle { display:none; }
@media(max-width:820px) {
  #app { grid-template-rows:auto 3px minmax(0,1fr); }
  .topbar { flex-wrap:wrap; gap:8px; padding:8px 10px; }
  .brand { min-width:0; flex:1; }.brand small { display:none; }
  .top-status { display:none; }.top-actions { width:100%; overflow-x:auto; flex-wrap:nowrap; padding-bottom:3px; }
  .top-actions .btn { flex:none; }.blueprint-toggle { display:inline-flex; }
  .rail,.inspector { top:110px; }
}

.practice-question .practice-blank { display:inline-block; width:clamp(95px,12ch,230px); max-width:90%; margin:3px 5px; padding:5px 9px; border:1px solid #888; border-radius:4px; background:#fff; color:#111; font:inherit; font-weight:400; vertical-align:baseline; }
.practice-question .practice-blank:focus { outline:2px solid #547466; outline-offset:1px; }
