/* 练字反馈台 —— 纸质暖色调，长时间看不累 */

:root {
  --paper:      #fbf9f5;
  --paper-2:    #f4f1ea;
  --paper-3:    #ece7dd;
  --ink:        #23201c;
  --ink-2:      #5c554c;
  --ink-3:      #928a80;
  --line:       #e4dfd5;
  --line-2:     #d3ccbf;
  --grid:       #ded7ca;
  --grid-strong:#c0b6a4;
  --accent:     #b23a2f;
  --accent-2:   #8e2b22;
  --accent-soft:#f7e9e6;
  --good:       #2f7a52;
  --warn:       #b07519;
  --bad:        #c0413a;
  --shadow:     0 1px 2px rgba(50,40,25,.05), 0 6px 20px rgba(50,40,25,.06);
  --radius:     10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

body[data-paper="cool"] {
  --paper:      #f8f9fa;
  --paper-2:    #eef1f3;
  --paper-3:    #e3e7ea;
  --line:       #e0e4e7;
  --line-2:     #cdd4d9;
  --grid:       #d8dee2;
  --grid-strong:#b6bfc6;
}
body[data-paper="dark"] {
  --paper:      #1c1b19;
  --paper-2:    #242320;
  --paper-3:    #2d2b27;
  --ink:        #ece7de;
  --ink-2:      #b3aaa0;
  --ink-3:      #7d766c;
  --line:       #34322e;
  --line-2:     #403d38;
  --grid:       #3a3733;
  --grid-strong:#55504a;
  --accent:     #e0715f;
  --accent-2:   #ef8574;
  --accent-soft:#3a2a27;
  --good:       #5fb185;
  --warn:       #d3a24e;
  --bad:        #e0705f;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper-2);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
h2, h3 { margin: 0; font-weight: 600; }

/* ─────────── 顶栏 ─────────── */
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .02em; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.topnav { display: flex; gap: 8px; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line-2);
  padding: 5px 12px; border-radius: 999px; color: var(--ink-2); font-size: 13px;
}
.ghost-btn:hover { background: var(--paper-2); color: var(--ink); }

/* ─────────── 三栏布局 ─────────── */
.layout {
  display: grid;
  grid-template-columns: 268px minmax(360px, 1fr) minmax(360px, 440px);
  gap: 14px;
  padding: 14px 18px 18px;
  align-items: start;
  max-width: 1560px;
  margin: 0 auto;
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px 1fr; }
  .panel-right { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .panel-left { order: 2; }
  .stage { order: 1; }
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 88px);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 14px 8px;
}
.panel-head h2 { font-size: 14px; }
.muted { color: var(--ink-3); font-size: 12px; }

/* ─────────── 选字面板 ─────────── */
.search { padding: 0 12px 8px; display: block; }
.search input {
  width: 100%; padding: 7px 10px; font: inherit;
  border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--paper-2); color: var(--ink);
}
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 10px; }
.chip {
  border: 1px solid var(--line-2); background: transparent;
  color: var(--ink-2); border-radius: 999px;
  padding: 2.5px 9px; font-size: 12px;
}
.chip:hover { background: var(--paper-2); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.charlist {
  flex: 1; overflow-y: auto; padding: 0 8px 8px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px; align-content: start;
}
.charlist button {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 7px;
  background: transparent; font-size: 20px; line-height: 1;
  display: grid; place-items: center; position: relative; padding: 0;
}
.charlist button:hover { background: var(--paper-3); }
.charlist button[aria-current="true"] { background: var(--accent); color: #fff; }
.charlist button.no-name::after {
  content: ""; position: absolute; right: 4px; top: 4px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--ink-3);
}
.charlist button.practiced::before {
  content: ""; position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  width: 14px; height: 2px; border-radius: 1px; background: var(--good);
}
.charlist button[aria-current="true"].practiced::before { background: rgba(255,255,255,.75); }

.panel-foot { border-top: 1px solid var(--line); padding: 10px 14px; font-size: 12px; }
.foot-row { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); }
.foot-row b { font-family: var(--mono); }

/* ─────────── 书写区 ─────────── */
.stage {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.big-char { font-size: 30px; line-height: 1; font-weight: 500; }
.char-meta { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-hint { font-size: 12.5px; color: var(--ink-3); text-align: right; }

.board-wrap {
  position: relative;
  display: grid; place-items: center;
  flex: 1; min-height: 0;
  padding: 4px 0;
}
.board-clip {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-2), 0 2px 10px rgba(50,40,25,.06);
  background: var(--paper);
}
.board-clip canvas { display: block; touch-action: none; cursor: crosshair; }
.board-clip.overlay canvas { cursor: default; }
.board-tag {
  position: absolute; left: 8px; top: 8px;
  font-size: 11.5px; color: var(--ink-3);
  background: var(--paper); border: 1px solid var(--line);
  padding: 1px 7px; border-radius: 999px; pointer-events: none;
}

.stroke-strip {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 26px; padding: 2px 0;
}
.pip {
  min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--paper-2); color: var(--ink-2);
  font-size: 11.5px; font-family: var(--mono);
  display: inline-flex; align-items: center; gap: 4px;
}
.pip.now { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pip.done { border-color: var(--line-2); }
.pip.good { border-color: var(--good); color: var(--good); }
.pip.mid  { border-color: var(--warn); color: var(--warn); }
.pip.bad  { border-color: var(--bad);  color: var(--bad); }
.pip.ghost { opacity: .45; }

.stage-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tool {
  border: 1px solid var(--line-2); background: var(--paper);
  color: var(--ink-2); border-radius: 7px; padding: 6px 13px; font-size: 13px;
}
.tool:hover { background: var(--paper-2); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--paper-3); border-color: var(--grid-strong); color: var(--ink); }
.tool.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool.primary:hover { background: var(--accent-2); }
.tool:disabled { opacity: .4; cursor: not-allowed; }

/* ─────────── 诊断面板 ─────────── */
.panel-right { overflow-y: auto; }
.report-empty {
  padding: 34px 24px; text-align: center; color: var(--ink-2);
}
.empty-art {
  width: 68px; height: 68px; margin: 0 auto 14px;
  border: 1.5px dashed var(--grid-strong); border-radius: 8px;
  display: grid; place-items: center;
  font-size: 34px; color: var(--line-2);
}
.report-empty p { margin: 6px 0; font-size: 13px; }
.report-empty .muted { font-size: 12px; line-height: 1.7; }

.report { padding: 14px 16px 20px; }

.score-hero {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.score-num {
  font-family: var(--mono); font-size: 44px; line-height: 1;
  font-weight: 600; letter-spacing: -.02em;
}
.score-num.s-good { color: var(--good); }
.score-num.s-mid  { color: var(--warn); }
.score-num.s-bad  { color: var(--bad); }
.score-meta { flex: 1; min-width: 0; }
.verdict { font-size: 13.5px; margin-bottom: 8px; line-height: 1.55; }
.bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.bar span { width: 30px; color: var(--ink-3); flex: none; }
.bar .track { flex: 1; height: 5px; border-radius: 3px; background: var(--paper-3); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 3px; }
.bar b { width: 26px; text-align: right; font-family: var(--mono); font-weight: 500; }

.tabs { display: flex; gap: 2px; margin: 14px 0 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; padding: 6px 11px;
  color: var(--ink-3); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

.tabbody { padding-top: 10px; }

.issue {
  border: 1px solid var(--line); border-left: 3px solid var(--line-2);
  border-radius: 0 7px 7px 0;
  padding: 9px 12px; margin-bottom: 8px; background: var(--paper);
}
.issue.sev-bad  { border-left-color: var(--bad);  background: color-mix(in srgb, var(--bad) 5%, var(--paper)); }
.issue.sev-warn { border-left-color: var(--warn); }
.issue.sev-good { border-left-color: var(--good); }
.issue-head { display: flex; align-items: baseline; gap: 8px; }
.issue-title { font-size: 13.5px; font-weight: 500; }
.issue-where { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }
.issue-score { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.issue-body { font-size: 12.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.7; }
.issue-fix { font-size: 12.5px; margin-top: 5px; color: var(--ink); }
.issue-fix::before { content: "→ "; color: var(--accent); font-weight: 600; }
.num { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.num.bad { color: var(--bad); }
.num.good { color: var(--good); }

.strokelist { border-collapse: collapse; width: 100%; font-size: 12px; }
.strokelist th {
  text-align: left; font-weight: 500; color: var(--ink-3);
  padding: 4px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper);
}
.strokelist td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.strokelist td.n { font-family: var(--mono); color: var(--ink-3); text-align: right; width: 30px; }
.strokelist td.exp, .strokelist td.got { min-width: 52px; }
.strokelist td.exp { white-space: nowrap; }
.strokelist td.got.wrong { color: var(--bad); font-weight: 500; }
.strokelist td.sc { font-family: var(--mono); text-align: right; width: 34px; }
.strokelist .why { color: var(--ink-2); font-size: 11.5px; }
.tagline { color: var(--ink-3); font-size: 11.5px; margin: 8px 0 4px; }

.cmp-wrap { display: grid; gap: 10px; justify-items: center; }
.cmp-row { display: flex; gap: 12px; align-items: flex-start; justify-content: center; }
.cmp-cell { text-align: center; }
.cmp-cell canvas { display: block; margin: 0 auto; border-radius: 6px; box-shadow: 0 0 0 1px var(--line-2); background: var(--paper); }
.cmp-cell span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--ink-3); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--ink-2); justify-content: center; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.empty-note { color: var(--ink-3); font-size: 12.5px; padding: 16px 4px; }

/* ─────────── 小元件 ─────────── */
.modal {
  border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px;
  max-width: 560px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(30,25,18,.35); }
.modal h3 { margin: 14px 0 6px; font-size: 14px; }
.modal h3:first-child { margin-top: 0; }
.modal ol, .modal ul { padding-left: 20px; margin: 6px 0; font-size: 13px; color: var(--ink-2); }
.modal li { margin: 4px 0; }
.modal p { font-size: 13px; color: var(--ink-2); }
.modal form { margin: 16px 0 0; text-align: right; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; border: 2px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }
