/* 语文老师工作台 · 墨香课堂
   浅色「宣纸」备课主题 / 深色「课堂」投屏主题 */
:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --bg-2: #efe9dc;
  --panel: #fffdf8;
  --panel-2: #fbf7ef;
  --ink: #2b2620;
  --ink-2: #4c453b;
  --muted: #8b8172;
  --line: #e3dac9;
  --line-2: #d2c6b1;
  --accent: #a53f2b;
  --accent-2: #c25c40;
  --accent-soft: #f6e9e2;
  --gold: #ac8a4c;
  --green: #3f7355;
  --shadow: 0 8px 30px rgba(70, 55, 35, .09);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
body[data-theme="night"] {
  color-scheme: dark;
  --bg: #141a20;
  --bg-2: #10161b;
  --panel: #1b232b;
  --panel-2: #202932;
  --ink: #f2eee6;
  --ink-2: #d5d0c6;
  --muted: #94a0aa;
  --line: #2d3842;
  --line-2: #3c4854;
  --accent: #e08462;
  --accent-2: #f09978;
  --accent-soft: #3a2a27;
  --gold: #d2ad6b;
  --green: #78b394;
  --shadow: 0 10px 34px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle at 12% 18%, rgba(165,63,43,.035) 0, transparent 42%),
                    radial-gradient(circle at 88% 82%, rgba(172,138,76,.045) 0, transparent 40%);
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
select, input, textarea { outline: none; }
select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 26px 7px 10px; color: var(--ink); min-height: 34px;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
select option { background: var(--panel); color: var(--ink); }
input[type="text"], input:not([type]), input[type="password"], textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; line-height: 1.7; }

.app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 20px; min-height: 68px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(70,55,35,.03);
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; flex: 0 0 auto; }
.seal {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border-radius: 5px;
  font-family: var(--serif); font-size: 23px; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.22);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.35; }
.brand-txt strong { font-family: var(--serif); font-size: 18px; letter-spacing: .08em; }
.brand-txt small { color: var(--muted); font-size: 11px; letter-spacing: .05em; }
.selectors { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1 1 auto; }
.sel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sel select { max-width: 240px; }
#bookSelect { width: 140px; }
#unitSelect { width: 190px; }
#lessonSelect { width: 220px; }
#modeSelect { width: 118px; }
.user-area { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--ink-2); border-radius: 6px; display: grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.user-tag {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 20px;
  padding: 7px 14px; font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.user-tag:hover { border-color: var(--accent); }

/* ---------- 布局 ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 268px minmax(0,1fr); min-height: 0; }
.layout.side-closed { grid-template-columns: 44px minmax(0,1fr); }
.layout.side-closed .side-title, .layout.side-closed .side-sub,
.layout.side-closed .side-body, .layout.side-closed .side-foot { display: none; }
.layout.side-closed .side-head { padding: 12px 4px; justify-content: center; border-bottom: 0; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel-2); border-right: 1px solid var(--line);
}
.side-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.side-title { font-family: var(--serif); font-size: 17px; letter-spacing: .06em; }
.side-sub { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.5; }
.side-body { flex: 1; overflow: auto; padding: 8px 10px 16px; }
.side-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.mini-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  border-radius: 5px; padding: 6px 11px; font-size: 12px; white-space: nowrap;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.toc-unit { margin-bottom: 6px; }
.toc-unit-head {
  display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 9px 8px; color: var(--ink);
  font-family: var(--serif); font-size: 14px; letter-spacing: .03em; border-radius: 5px;
}
.toc-unit-head:hover { background: var(--accent-soft); }
.toc-unit-head .caret { color: var(--muted); font-size: 10px; transition: transform .18s; }
.toc-unit.open .caret { transform: rotate(90deg); }
.toc-unit-head .u-count { margin-left: auto; color: var(--muted); font: 11px var(--sans); }
.toc-items { display: none; padding: 2px 0 8px 8px; border-left: 1px solid var(--line); margin-left: 14px; }
.toc-unit.open .toc-items { display: block; }
.toc-item {
  display: flex; align-items: baseline; gap: 7px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 6px 8px; border-radius: 5px;
  color: var(--ink-2); font-size: 13px; line-height: 1.5;
}
.toc-item:hover { background: var(--accent-soft); color: var(--accent); }
.toc-item.active { background: var(--accent); color: #fff; }
.toc-item .no { font-size: 11px; color: var(--muted); min-width: 18px; }
.toc-item.active .no { color: rgba(255,255,255,.75); }
.toc-item .tag { font-size: 10px; border: 1px solid var(--line-2); border-radius: 3px; padding: 0 4px; color: var(--muted); flex: 0 0 auto; }
.toc-item.active .tag { border-color: rgba(255,255,255,.5); color: #fff; }
.toc-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); margin-left: auto; flex: 0 0 auto; }

/* ---------- 舞台 ---------- */
.stage-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 22px 8px; min-height: 46px;
}
.crumb { font-family: var(--serif); font-size: 15px; color: var(--ink-2); letter-spacing: .04em; }
.crumb b { color: var(--accent); font-weight: 600; }
.stage-tools { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; white-space: nowrap; }
.stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 8px 24px; overflow: hidden;
}
.view { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* 字词卡 */
.card-scene { flex: 1; width: 100%; display: grid; place-items: center; perspective: 1000px; }
.word-card {
  width: min(620px, 88%); min-height: 290px; padding: 28px 30px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; transition: transform .28s ease, opacity .28s ease;
}
.word-card::before, .word-card::after {
  content: ""; position: absolute; width: 26px; height: 26px; border: 1px solid var(--line-2);
}
.word-card::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.word-card::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.word-card.pop { animation: cardPop .38s cubic-bezier(.2,1.2,.4,1); }
@keyframes cardPop { from { transform: translateY(18px) scale(.97); opacity: .35; } to { transform: none; opacity: 1; } }
.card-pinyin { font-size: 18px; letter-spacing: .16em; color: var(--gold); min-height: 26px; font-family: var(--serif); }
.card-word {
  font-family: var(--serif); font-size: clamp(52px, 9vw, 116px); line-height: 1.25;
  letter-spacing: .12em; color: var(--ink); text-align: center; word-break: break-all;
}
.card-hint { color: var(--muted); font-size: 12px; margin-top: 10px; min-height: 18px; letter-spacing: .05em; }
.card-meta { color: var(--muted); font-size: 12px; padding: 10px 0 4px; letter-spacing: .05em; }

/* 听写 */
.dict-top { width: min(760px, 92%); display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.dict-label { font-family: var(--serif); font-size: 15px; color: var(--muted); white-space: nowrap; }
.dict-progress { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.dict-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.dict-word {
  font-family: var(--serif); font-size: clamp(34px, 5vw, 62px); letter-spacing: .18em;
  color: var(--ink); text-align: center; line-height: 1.5; min-height: 90px;
}
.dict-word.masked { color: var(--muted); letter-spacing: .4em; }
.dict-answer { font-family: var(--serif); font-size: clamp(38px, 6vw, 78px); color: var(--accent); letter-spacing: .14em; margin-top: 4px; }
.dict-tip { color: var(--muted); font-size: 12px; margin-top: 26px; text-align: center; max-width: 620px; line-height: 1.8; }

/* 背诵 */
.view-recite { justify-content: flex-start; padding-top: 6px; }
.poem-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.poem-bar select { max-width: 240px; }
.poem-title { font-family: var(--serif); font-size: 30px; letter-spacing: .14em; color: var(--ink); }
.poem-author { color: var(--muted); font-size: 12px; margin: 6px 0 20px; letter-spacing: .1em; }
.poem-body {
  width: min(760px, 94%); flex: 1; overflow: auto; display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding-bottom: 12px;
}
.poem-line {
  font-family: var(--serif); font-size: clamp(20px, 2.6vw, 30px); letter-spacing: .1em;
  line-height: 1.9; text-align: center; color: var(--ink);
}
.poem-line .blank {
  display: inline-block; min-width: 5.5em; border-bottom: 1px solid var(--accent);
  color: transparent; background: var(--accent-soft); border-radius: 2px;
}
.poem-line .blank input {
  width: 5.5em; border: 0; border-bottom: 1px solid var(--accent); background: transparent;
  text-align: center; font-family: var(--serif); font-size: .9em; color: var(--ink); padding: 0 2px;
}
.poem-line .blank input.right { color: var(--green); }
.poem-line .blank input.wrong { color: var(--accent); text-decoration: underline wavy; }
.poem-line.covered { color: transparent; background: var(--bg-2); border-radius: 4px; }
.poem-line.covered.revealed { color: var(--ink); background: transparent; }

/* 点读 */
.view-read { justify-content: flex-start; padding-top: 10px; }
.read-title { font-family: var(--serif); font-size: clamp(30px, 4vw, 52px); letter-spacing: .1em; text-align: center; }
.read-tag { color: var(--muted); margin: 8px 0 20px; font-size: 12px; letter-spacing: .1em; }
.read-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.big-btn {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 5px; padding: 10px 24px; letter-spacing: .1em; font-size: 14px;
}
.big-btn:hover { background: var(--accent-2); }
.big-btn.ghost { background: transparent; color: var(--accent); }
.big-btn.ghost:hover { background: var(--accent-soft); }
.read-text { width: min(760px, 94%); }
.read-text label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.6; }
.read-text textarea { min-height: 130px; font-family: var(--serif); font-size: 17px; }
.read-text-actions { display: flex; gap: 8px; margin-top: 8px; }

/* 备课 */
.view-plan { justify-content: flex-start; align-items: stretch; padding-top: 4px; }
.plan-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: min(900px, 96%); margin-bottom: 12px;
}
.plan-head strong { font-family: var(--serif); font-size: 19px; letter-spacing: .08em; }
.plan-head small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.plan-list { width: min(900px, 96%); flex: 1; overflow: auto; padding-bottom: 14px; }
.plan-row {
  display: grid; grid-template-columns: minmax(0,1fr) 240px 150px; gap: 10px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.plan-row:hover { background: var(--panel-2); }
.plan-row .p-name { font-family: var(--serif); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-row .p-name small { color: var(--muted); font-family: var(--sans); font-size: 11px; margin-left: 8px; }
.plan-row input.p-note { padding: 6px 9px; font-size: 12px; }
.plan-states { display: flex; gap: 4px; }
.plan-states button { flex: 1; font-size: 11px; padding: 5px 2px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 4px; color: var(--muted); }
.plan-states button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-states button.on.s-done { background: var(--green); border-color: var(--green); }

/* ---------- 控制条 ---------- */
.controls {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px; border-top: 1px solid var(--line); background: var(--panel); min-height: 58px;
}
.transport { display: flex; gap: 8px; flex-wrap: wrap; }
.ctrl-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
  border-radius: 5px; padding: 8px 16px; font-size: 13px; letter-spacing: .04em;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); }
.ctrl-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 104px; }
.ctrl-btn.primary:hover { background: var(--accent-2); color: #fff; }
.opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.opt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.opt select { padding: 5px 24px 5px 8px; min-height: 30px; font-size: 12px; }
.opt.check { cursor: pointer; }
.opt.check input { accent-color: var(--accent); }

/* ---------- 全屏浮层 ---------- */
.fs-overlay {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: none; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  max-width: 96vw; padding: 10px 14px; z-index: 60;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line-2); border-radius: 40px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .25s;
}
body.is-fs .fs-overlay { display: flex; }
.fs-overlay.show { opacity: 1; }
.fs-sel { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.fs-sel select { min-height: 30px; padding: 4px 22px 4px 8px; font-size: 12px; border-radius: 20px; }
#fsBook { width: 130px; } #fsUnit { width: 170px; } #fsLesson { width: 190px; } #fsMode { width: 100px; }
.fs-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.fs-btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); border-radius: 20px; padding: 7px 14px; font-size: 12px; }
.fs-btn:hover { border-color: var(--accent); color: var(--accent); }
body.is-fs .topbar, body.is-fs .sidebar, body.is-fs .stage-head, body.is-fs .controls { display: none; }
body.is-fs .layout { grid-template-columns: minmax(0,1fr); }
body.is-fs .stage { padding: 20px 4vw 90px; }

/* ---------- 弹层 ---------- */
.mask { position: fixed; inset: 0; background: rgba(30,24,18,.45); z-index: 80; backdrop-filter: blur(2px); }
.modal {
  position: fixed; z-index: 90; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(440px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.modal.wide { width: min(720px, 94vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head strong { font-family: var(--serif); font-size: 18px; letter-spacing: .08em; }
.modal-body { padding: 18px; overflow: auto; }
.modal-body > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-body > label input { margin-top: 6px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.8; }
.err { color: var(--accent); font-size: 12px; margin: 8px 0; }
.help-body p { font-size: 13px; line-height: 1.9; color: var(--ink-2); }
.help-body b { color: var(--accent); }
.data-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.word-list { display: flex; flex-wrap: wrap; gap: 7px; max-height: 300px; overflow: auto; padding: 4px 0 10px; }
.word-pill {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--panel-2); border-radius: 20px; padding: 5px 8px 5px 12px; font-size: 13px;
}
.word-pill.removed { opacity: .45; text-decoration: line-through; border-style: dashed; }
.word-pill.custom { border-color: var(--gold); }
.word-pill button { border: 0; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 2px; }
.word-pill button:hover { color: var(--accent); }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; }
#importText { min-height: 130px; }
.import-result { color: var(--green); font-size: 12px; margin-top: 10px; min-height: 18px; }
.books-info-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
.books-info-row span:last-child { color: var(--muted); text-align: right; }
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 88px; transform: translateX(-50%);
  background: var(--ink); color: var(--panel); padding: 10px 20px; border-radius: 24px;
  font-size: 13px; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 220px minmax(0,1fr); }
  #bookSelect { width: 120px; } #unitSelect { width: 150px; } #lessonSelect { width: 170px; }
  .plan-row { grid-template-columns: minmax(0,1fr) 180px 130px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-txt small { display: none; }
  .selectors { order: 3; width: 100%; }
  .sel select { flex: 1; min-width: 0; }
  .layout { grid-template-columns: minmax(0,1fr); }
  .sidebar { display: none; }
  .stage { min-height: 420px; padding: 8px 12px; }
  .controls { padding: 10px 12px; }
  .stage-head { padding: 10px 12px 4px; }
  .plan-row { grid-template-columns: minmax(0,1fr); }
  .fs-overlay { bottom: 10px; }
}
