@font-face {
  font-family: 'Pretendard'; font-style: normal; font-weight: 45 920; font-display: swap;
  src: url('vendor/fonts/PretendardVariable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'NanumSquareNeo'; font-style: normal; font-weight: 600 749; font-display: swap;
  src: url('vendor/fonts/NanumSquareNeo-cBd.woff2') format('woff2');
}
@font-face {
  font-family: 'NanumSquareNeo'; font-style: normal; font-weight: 750 900; font-display: swap;
  src: url('vendor/fonts/NanumSquareNeo-dEb.woff2') format('woff2');
}

:root {
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #f1ece2;
  --ink: #2a2622;
  --ink-soft: #6c655b;
  --ink-faint: #9b9388;
  --line: #e7e0d3;
  --line-soft: #efe9dd;
  --accent: #2f6b5e;
  --accent-soft: #e4efe9;
  --accent-ink: #1f4a40;
  --blue: #3a6ea5;
  --amber: #b3791f;
  --amber-bg: #f7eccf;
  --green: #3c8a5a;
  --green-bg: #dcefe1;
  --red: #bf4630;
  --red-bg: #f6ddd5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(40,34,28,.04), 0 6px 18px rgba(40,34,28,.06);
  --font-body: "Pretendard", "맑은 고딕", "Malgun Gothic", system-ui, sans-serif;
  --font-head: "NanumSquareNeo", var(--font-body);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.upd-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--accent); color: #fbf7ef; box-shadow: 0 2px 12px rgba(40,34,28,.25);
  font-size: 13px; font-weight: 600;
}
.upd-banner .upd-track { flex: 0 1 280px; height: 8px; background: rgba(255,255,255,.28); border-radius: 99px; overflow: hidden; }
#updFill { height: 100%; width: 0; background: #fbf7ef; border-radius: 99px; transition: width .2s; }
.upd-btn { padding: 5px 14px; border-radius: 7px; border: none; background: #fbf7ef; color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.upd-btn:hover { filter: brightness(.96); }
.upd-x { margin-left: auto; background: none; border: none; color: #fbf7ef; cursor: pointer; font-size: 14px; opacity: .8; }
.upd-x:hover { opacity: 1; }

.listbar { display: flex; gap: 6px; padding: 0 14px 10px; align-items: center; }
.listbar #stuSearch { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); outline: none; }
.listbar #stuSearch:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.listbar #sortToggle { padding: 7px 10px !important; font-size: 12px; white-space: nowrap; }

#emptyState { display: grid; place-items: center; min-height: 60vh; }
.empty-card { text-align: center; max-width: 420px; }
.empty-mark {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--accent); color: #fbf7ef; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 32px;
  box-shadow: 0 8px 24px rgba(47,107,94,.28);
}
.empty-card h2 { margin: 0 0 8px; }
.empty-card p { line-height: 1.6; }

.neis-guide { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--ink-faint); }
.neis-guide b { color: var(--accent-ink); font-weight: 700; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; height: 100vh; overflow: hidden;
  font-family: var(--font-body); color: var(--ink);
  background: var(--paper);
  font-size: 14px; line-height: 1.6; letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}
h2, h3 { font-family: var(--font-head); letter-spacing: -.02em; color: var(--ink); }
h2 { font-size: 18px; margin: 0 0 14px; font-weight: 800; }
h3 { font-size: 13px; margin: 0 0 10px; font-weight: 700; color: var(--ink-soft); }
button, select, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { white-space: nowrap; }

/* ===== Sidebar ===== */
#sidebar {
  width: 272px; flex: 0 0 272px; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, #fffefb, #f3eee4);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.help-btn { margin-left: auto; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; font-weight: 700; font-size: 14px; line-height: 1; }
.help-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
  background: var(--accent); color: #fbf7ef; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 800; font-size: 20px;
  box-shadow: 0 4px 12px rgba(47,107,94,.32);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.25; }
.brand-txt strong { font-family: var(--font-head); font-size: 15px; font-weight: 800; }
.brand-txt small { color: var(--ink-faint); font-size: 11.5px; }

.bar { display: flex; gap: 8px; padding: 4px 14px 10px; }
.bar select { flex: 1; min-width: 0; }
select, input[type="number"] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.viewbar { display: flex; gap: 4px; padding: 0 12px 12px; }
.viewbar button {
  flex: 1; padding: 7px 4px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 12.5px; font-weight: 600;
  transition: background .15s, color .15s;
}
.viewbar button:hover { background: var(--surface-2); color: var(--ink); }
.viewbar button.sel { background: var(--accent); color: #fbf7ef; box-shadow: var(--shadow); }

#groupTree { padding: 2px 8px 24px; overflow-y: auto; flex: 1; min-height: 0; }
.side-foot { margin-top: auto; padding: 10px 18px 14px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 11.5px; font-weight: 600; line-height: 1.5; }
.quit-btn { width: 100%; margin-bottom: 10px; padding: 8px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-soft); transition: background .12s, border-color .12s, color .12s; }
.quit-btn:hover { background: #fbece8; border-color: var(--red, #bf4630); color: var(--red, #bf4630); }
.side-copy { font-size: 10.5px; font-weight: 500; color: var(--ink-faint); opacity: 0.8; }
.grp { margin-bottom: 2px; }
.grp-head {
  display: flex; align-items: center; gap: 7px; padding: 9px 10px; border-radius: 9px;
  cursor: pointer; font-family: var(--font-head); font-weight: 700; font-size: 13px;
  color: var(--ink); transition: background .12s; user-select: none; border: 1px solid transparent;
}
.grp-head:hover { background: var(--surface-2); }
.grp-head.active { background: var(--accent-soft); border-color: #cfe4dc; }
.grp-head .caret { color: var(--ink-faint); font-size: 10px; width: 10px; }
.grp-head .grp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-head .grp-cat { color: var(--accent); font-weight: 800; }
.grp-head .grp-n { font-size: 11px; color: var(--ink-faint); font-weight: 600; background: var(--surface-2); padding: 1px 7px; border-radius: 999px; }
.grp-head .grp-add {
  border: none; background: none; color: var(--ink-faint); font-size: 16px; line-height: 1;
  cursor: pointer; padding: 0 2px; border-radius: 6px;
}
.grp-head .grp-add:hover { color: var(--accent); background: var(--surface); }
.grp-students { list-style: none; margin: 0 0 4px; padding: 2px 0 2px 12px; }
.grp-students li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--ink); transition: background .12s; border: 1px solid transparent;
}
.grp-students li:hover { background: var(--surface-2); }
.grp-students li.sel { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); font-weight: 600; }
.grp-students li.empty, .grp-students li.loading { color: var(--ink-faint); cursor: default; font-size: 12px; }

/* ===== Badges ===== */
.badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-faint); white-space: nowrap; letter-spacing: 0;
}
.badge.미작성 { background: var(--surface-2); color: var(--ink-faint); }
.prog-chip { cursor: pointer; }
.settabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.settab { padding: 9px 16px; border: none; background: none; color: var(--ink-soft); font-size: 14px; font-weight: 700; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.settab:hover { color: var(--accent-ink); }
.settab.sel { color: var(--accent-ink); border-bottom-color: var(--accent); }
.bak-sec { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.bak-h { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.bak-sec .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bak-sec input[type="password"] { min-width: 200px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
.bak-sec input[type="file"] { font-size: 12px; }
.status-chip { border: none; cursor: pointer; font-size: 12.5px; padding: 5px 14px; }
.status-chip:hover { filter: brightness(0.96); box-shadow: 0 0 0 2px var(--accent-soft); }
.badge.초안 { background: #e6eef6; color: var(--blue); }
.badge.검증 { background: var(--amber-bg); color: var(--amber); }
.badge.완료 { background: var(--green-bg); color: var(--green); }

/* ===== Main ===== */
#main { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; padding: 22px 26px 60px; }

#head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 2px 16px; border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
#headInfo { font-family: var(--font-head); font-size: 15.5px; font-weight: 700; color: var(--ink); }

#tabs { display: flex; gap: 6px; margin-bottom: 16px; }
#tabs button {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--ink-soft); cursor: pointer; font-weight: 600; font-size: 13px; transition: all .14s;
}
#tabs button:hover { border-color: var(--accent); color: var(--accent-ink); }
#tabs button.sel { background: var(--accent); border-color: var(--accent); color: #fbf7ef; box-shadow: var(--shadow); }

/* ===== Editor layout ===== */
#editor { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 18px; align-items: start; }
.col-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}

/* ===== Byte gauge ===== */
.gauge { margin-bottom: 12px; }
.glabel { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
#gaugeArea { font-family: var(--font-head); font-weight: 700; font-size: 13.5px; color: var(--ink); }
.gnum { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.track { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
#gaugeFill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .25s ease, background .2s; }
.gauge.low #gaugeFill { background: var(--amber); }
.gauge.full #gaugeFill { background: var(--green); }
.gauge.over #gaugeFill { background: var(--red); }
.gauge.over .gnum { color: var(--red); }

textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px; resize: vertical; line-height: 1.7; outline: none; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
#body { min-height: 340px; font-size: 15px; }
.row { display: flex; gap: 12px; }
.row label { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.row textarea { min-height: 70px; font-size: 13.5px; }

/* ===== Quality ===== */
.quality-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quality-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-soft); font-weight: 600; text-align: center; }
.quality-grid input { text-align: center; }
.accept-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.accept-row input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ===== Actions ===== */
.actions { display: flex; align-items: center; gap: 8px; }
.actions .spacer { flex: 1; }
button.btn-primary, button.btn-green, button.btn-ghost, #addBtn, #lgSave {
  border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; transition: transform .08s, filter .15s, background .15s, border-color .15s;
}
button:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fbf7ef; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-green { background: var(--green-bg); color: var(--green); border-color: #c4e2cd; }
.btn-green:hover { background: #d0e9d7; }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost.danger { color: var(--red, #bf4630); border-color: #e6c4bc; }
.btn-ghost.danger:hover { background: #fbece8; border-color: var(--red, #bf4630); color: var(--red, #bf4630); }

/* common phrases */
.phrase-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ph-quick { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; }
.ph-quick .ph-q-t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ph-quick .kbd { font-size: 10.5px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid #cfe4dc; border-radius: 5px; padding: 0 5px; line-height: 1.5; }
.phrase-row .ph-all { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.fb-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 2px; }
.fb-body input, .fb-body textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; }
.fb-body p { margin: 0; }
.phrase-row { margin-bottom: 12px; }
.phrase-row .ph-group { min-width: 150px; }
.phrase-row .ph-title { flex: 1; min-width: 160px; }
.phrase-row .ph-text { width: 100%; margin-top: 8px; resize: vertical; font: inherit; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#addBtn { background: var(--accent-soft); color: var(--accent-ink); border-color: #cfe4dc; padding: 8px 12px; }
#addBtn:hover { background: #d7eae3; }

.legacy { border-color: #ddd2bf; background: linear-gradient(180deg,#fffdf6,#faf4e6); }
.legacy label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.legacy textarea { min-height: 48px; font-size: 13px; }

/* ===== Side panel ===== */
.col-side .card h3 { display: flex; align-items: center; gap: 6px; }
.warnings:empty::after, .books-list:empty::after, .edits:empty::after {
  content: "—"; color: var(--ink-faint); font-size: 13px;
}
.warnings .warn {
  display: flex; gap: 7px; padding: 7px 10px; margin: 5px 0; border-radius: 8px;
  background: var(--red-bg); color: var(--red); font-size: 12.5px; font-weight: 600;
}
.warnings .warn.ok { background: var(--green-bg); color: var(--green); }
.books-list { font-size: 13px; color: var(--ink-soft); }
.books-list .book { padding: 4px 0; border-bottom: 1px dashed var(--line-soft); }
.edits { font-size: 12px; color: var(--ink-soft); max-height: 320px; overflow-y: auto; }
.edits .edit { padding: 8px; margin: 6px 0; border-radius: 8px; background: var(--surface-2); }
.edits .t { color: var(--ink-faint); font-size: 11px; }
.edits .b { color: var(--red); margin-top: 4px; }
.edits .a { color: var(--green); }

/* ===== Dashboard / Overlap ===== */
#dashView h2, #overlapView h2 { margin-top: 6px; }
.dash-head { margin-bottom: 14px; }
.progbar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.progbar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 99px; transition: width .4s; }
.summary { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.dash-areas { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.dash-area-lab { color: var(--ink-soft); font-size: 13px; font-weight: 600; margin-right: 4px; }
.dash-area-btn { padding: 6px 14px; font-size: 13px; font-weight: 700; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); transition: background .12s, color .12s, border-color .12s; }
.dash-area-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.dash-area-btn.sel { background: var(--accent); border-color: var(--accent); color: #fbf7ef; }
.dashfilter { margin: 8px 0 14px; color: var(--ink-soft); font-size: 13px; display: flex; align-items: center; gap: 8px; }
#dashTable table, #overlapEvents table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
#dashTable th, #dashTable td, #overlapEvents th, #overlapEvents td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
#dashTable th, #overlapEvents th { background: var(--surface-2); font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--ink-soft); }
#dashTable tr:last-child td { border-bottom: none; }
.cell { display: flex; flex-direction: column; gap: 2px; }
.cell .st { font-weight: 700; font-size: 12px; }
.cell .by { color: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.st-미작성 { color: var(--ink-faint); }
.st-초안 { color: var(--blue); }
.st-검증 { color: var(--amber); }
.st-완료 { color: var(--green); }
.cell-copy {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 6px 14px;
  font-size: 13px; font-weight: 800; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fbf7ef; cursor: pointer;
  box-shadow: 0 2px 6px rgba(47,107,79,.28); transition: filter .12s, transform .08s, box-shadow .12s;
}
.cell-copy::before { content: "📋"; font-size: 12px; }
.cell-copy:hover { filter: brightness(1.07); box-shadow: 0 4px 10px rgba(47,107,79,.34); }
.cell-copy:active { transform: translateY(1px); }
#dashTable td.cell { vertical-align: top; }
#dashTable td.copycol { text-align: center; padding: 6px 8px; }
.row-copy {
  padding: 7px 18px; font-size: 13px; font-weight: 700; border-radius: 8px;
  border: 1px solid transparent; background: var(--accent); color: #fbf7ef;
  cursor: pointer; box-shadow: var(--shadow); transition: filter .12s, transform .08s;
}
.row-copy:hover { filter: brightness(1.08); }
.row-copy:active { transform: translateY(1px); }
.row-copy-empty { color: var(--ink-faint); }

/* flat dashboard: every column header aligns with its cell */
#dashTable table.flat td, #dashTable table.flat th { padding: 9px 12px; vertical-align: middle; }
#dashTable table.flat th:nth-child(1) { width: 64px; }
#dashTable table.flat th:nth-child(2) { width: 70px; }
#dashTable table.flat th:nth-child(3) { width: 80px; }
#dashTable table.flat th:nth-child(4) { width: 64px; }
#dashTable table.flat th:nth-child(6) { width: 112px; }
#dashTable table.flat th:nth-child(7) { width: 112px; }
#dashTable td.hakbun, #dashTable td.sname { border-left: 1px solid var(--line-soft); }
#dashTable td.hakbun { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 12.5px; }
#dashTable td.sname { font-weight: 600; }
#dashTable tr.stu-first td { border-top: 2px solid var(--line); }
#dashTable tr.arow-tr:not(.stu-first) td { border-top: 1px dashed var(--line-soft); }
#dashTable tr.arow-tr.dim { opacity: .4; }
#dashTable td.alabel { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
#dashTable td.abytes { font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.arow-tr.over td.abytes { color: var(--red); font-weight: 700; }
.arow-tr.none td.abytes { color: var(--ink-faint); }
#dashTable td.writecol { text-align: right; }
.dbar { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 90px; }
.dfill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .3s; }
.arow-tr.low .dfill { background: var(--amber); }
.arow-tr.ok .dfill { background: var(--accent); }
.arow-tr.full .dfill { background: var(--green); }
.arow-tr.over .dfill { background: var(--red); }
.arow-tr.none .dbar { background: var(--line-soft); }
.gowrite {
  padding: 5px 12px; font-size: 12px; font-weight: 700; border-radius: 7px; white-space: nowrap;
  border: 1px solid #cfe4dc; background: var(--accent-soft); color: var(--accent-ink); cursor: pointer;
  transition: background .12s;
}
.gowrite:hover { background: #d7eae3; }
#overlapPairs .pair { padding: 9px 12px; margin: 6px 0; border-radius: 9px; background: var(--amber-bg); color: var(--amber); font-size: 13px; }

/* ===== Shared small ===== */
.muted { color: var(--ink-faint); font-size: 12.5px; }
.empty { color: var(--ink-faint); font-size: 12.5px; padding: 2px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; margin: 3px 4px 0 0; padding: 3px 9px;
  border-radius: 99px; background: var(--surface-2); color: var(--ink-soft);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip.hot { background: var(--red-bg); color: var(--red); }
.chip.clickable { cursor: pointer; transition: filter .12s, box-shadow .12s; }
.chip.clickable:hover { box-shadow: 0 0 0 2px var(--accent-soft); filter: brightness(.97); }
mark.hl { background: #fff07a; color: inherit; border-radius: 3px; padding: 0; box-shadow: 0 0 0 1px #f4d03f55; }
mark.space-err { background: #ffd5d5; color: #c0392b; font-weight: 700; letter-spacing: 2px; box-shadow: 0 0 0 1px #e7505066; }
.hl-head { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; padding: 6px 8px; background: var(--surface-2); border-radius: 7px; }
.hlview { white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: 15px; color: var(--ink); padding: 9px 10px; cursor: pointer; }
.hlview:hover { background: var(--surface-2); border-radius: 7px; }
.warn-item { display: flex; gap: 7px; align-items: flex-start; padding: 6px 0; font-size: 12.8px; color: var(--ink-soft); }
.warn-item .ico { flex: 0 0 auto; }
.warn-item.err { color: var(--red); font-weight: 600; }
.warn-item.ok { color: var(--green); }
.warn-item.warn { color: var(--amber); }

/* ===== Edit toolbar + sentence view ===== */
.editbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.editbar #sentToggle { margin-left: auto; }
.editbar .sel { background: var(--accent); color: #fbf7ef; border-color: var(--accent); }
.hl-head .hl-clear, .hl-head .hl-tosent { font-size: 11.5px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.hl-head .hl-clear:hover, .hl-head .hl-tosent:hover { border-color: var(--accent); color: var(--accent-ink); }
.mg-byte { padding: 2px 6px; font-size: 12px; border-radius: 6px; }
.sent-view {
  min-height: 340px; max-height: 60vh; overflow-y: auto; padding: 4px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.sent {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: baseline;
  padding: 8px 10px; border-bottom: 1px dashed var(--line-soft); font-size: 14px; line-height: 1.65;
}
.sent:last-child { border-bottom: none; }
.sent .sno { color: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.sent .slen { color: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sent.long { background: var(--amber-bg); border-radius: 6px; }
.sent.long .slen { color: var(--amber); font-weight: 700; }
.sent.vlong { background: var(--red-bg); border-radius: 6px; }
.sent.vlong .slen { color: var(--red); font-weight: 700; }
.sent .stx { white-space: pre-wrap; word-break: break-word; outline: none; border-radius: 5px; padding: 1px 3px; transition: box-shadow .12s, background .12s; }
.sent .stx:hover { background: var(--surface-2); cursor: text; }
.sent .stx:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }

/* ===== Freq panel ===== */
.freq-grp { margin-bottom: 10px; }
.freq-grp:last-child { margin-bottom: 0; }
.freq-grp .ft { font-size: 11px; font-weight: 700; color: var(--ink-faint); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }

/* ===== Spell check ===== */
.spell-item { padding: 7px 4px; border-bottom: 1px dashed var(--line-soft); border-radius: 6px; cursor: pointer; }
.spell-item:last-child { border-bottom: none; }
.spell-item:hover { background: var(--surface-2); }
.spell-item.sel { background: var(--red-bg); }
.sp-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.sp-orig { color: var(--red); font-weight: 700; text-decoration: line-through; }
.sp-arrow { color: var(--ink-faint); }
.sp-sug { color: var(--green); font-weight: 700; }
.sp-cand { font-size: 12px; padding: 1px 4px; border-radius: 6px; color: var(--green); font-weight: 700; }
.sp-help { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; line-height: 1.45; }
.sp-more { font-size: 11px; padding: 0 6px; margin-left: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.sp-more:hover { border-color: var(--accent); color: var(--accent-ink); }
.sp-actions { display: flex; gap: 6px; margin-top: 6px; }
.sp-actions button { font-size: 11.5px; padding: 2px 10px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.sp-apply { background: var(--green-bg, #e3f3e8); color: var(--green); border-color: var(--green) !important; font-weight: 700; }
.sp-apply:hover { background: var(--green); color: #fff; }
.sp-dismiss { background: var(--surface); color: var(--ink-soft); }
.sp-dismiss:hover { border-color: var(--red); color: var(--red); }
mark.hl.spell-err { background: var(--red-bg); color: var(--red); box-shadow: none; text-decoration: underline wavy var(--red); text-underline-offset: 2px; }
mark.hl.spell-fixed { background: var(--green-bg); color: var(--green); box-shadow: none; text-decoration: underline; text-underline-offset: 2px; }

/* ===== History modal ===== */
.modal { position: fixed; inset: 0; background: rgba(40,34,28,.42); display: grid; place-items: center; z-index: 1000; padding: 24px; }
.modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(40,34,28,.32); width: min(720px, 100%); max-height: 84vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.notes-body { overflow-y: auto; padding: 8px 18px 16px; max-height: 70vh; }
.notes-rel { padding: 12px 0; border-bottom: 1px dashed var(--line-soft); }
.notes-rel:last-child { border-bottom: none; }
.notes-rel-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.notes-rel-head b { font-size: 15px; color: var(--accent-ink); }
.notes-date { color: var(--ink-faint); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }
.notes-md h4 { margin: 8px 0 4px; font-size: 13.5px; }
.notes-md ul { margin: 4px 0; padding-left: 18px; }
.notes-md li { font-size: 13.5px; line-height: 1.7; }
.notes-md p { font-size: 13.5px; line-height: 1.7; margin: 4px 0; color: var(--ink-soft); }
.notes-md code { background: var(--surface-2); padding: 0 3px; border-radius: 4px; font-size: 12.5px; }
.help-box { width: min(640px, 100%); }
.help-body { overflow-y: auto; padding: 20px 24px; line-height: 1.85; font-size: 15.5px; min-height: 320px; max-height: 62vh; }
.help-page h4 { margin: 0 0 14px; font-size: 20px; color: var(--accent-ink); }
.help-page p { margin: 0 0 11px; font-size: 15.5px; }
.help-page ul, .help-page ol { padding-left: 22px; margin: 6px 0 12px; }
.help-page li { margin-bottom: 10px; font-size: 15.5px; }
.help-lead { font-size: 16.5px; font-weight: 600; }
.help-note { background: var(--surface-2); border-radius: 8px; padding: 11px 13px; font-size: 14.5px; }
.help-tip { color: var(--ink-faint); font-size: 14px; }
.help-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 22px 16px; border-top: 1px solid var(--line); }
.help-nav .btn-primary, .help-nav .btn-ghost { padding: 8px 18px; font-size: 14px; }
.help-dots { display: flex; gap: 8px; }
.help-navbtns { display: flex; gap: 8px; }
.help-hide { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.help-hide input { cursor: pointer; }
.help-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); cursor: pointer; transition: background .15s; }
.help-dot.on { background: var(--accent); }
.prompt-box { width: min(420px, 100%); }
.prompt-body { padding: 18px 20px; }
.prompt-body #promptInput { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14.5px; outline: none; }
.prompt-body #promptInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prompt-btns { display: flex; gap: 8px; }
.hist-body { padding: 8px 18px 18px; overflow-y: auto; }
.ver-item { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.ver-item:last-child { border-bottom: none; }
.ver-item.current { background: var(--accent-soft); border-radius: 9px; padding: 12px; margin: 4px 0; border-bottom: none; }
.ver-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.ver-date { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-weight: 600; }
.ver-badge { font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--surface); padding: 2px 9px; border-radius: 999px; border: 1px solid #cfe4dc; }
.ver-restore { padding: 4px 12px; font-size: 12px; font-weight: 700; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--accent-ink); cursor: pointer; }
.ver-restore:hover { border-color: var(--accent); background: var(--accent-soft); }
.ver-diff { font-size: 14px; line-height: 1.7; color: var(--ink); word-break: break-word; }
.ver-diff del { color: var(--red); text-decoration: line-through; background: var(--red-bg); border-radius: 3px; padding: 0 1px; }
.ver-diff ins { color: var(--green); text-decoration: none; background: var(--green-bg); border-radius: 3px; padding: 0 1px; }

/* ===== Settings ===== */
#settingsView h2 { margin-top: 22px; }
#settingsView h2:first-child { margin-top: 6px; }
#cfgCards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.cfg-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.cfg-card h3 { font-size: 14px; color: var(--accent-ink); margin-bottom: 12px; }
.cfg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cfg-check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); cursor: pointer; flex: 1; min-width: 0; }
.cfg-check small { color: var(--ink-faint); font-weight: 600; }
.cfg-check input { width: 15px; height: 15px; accent-color: var(--accent); }
.cfg-byte-wrap { display: flex; align-items: center; gap: 6px; }
.cfg-byte { padding: 5px 8px; }
.cfg-custom { width: 78px; padding: 5px 8px; }
.cfg-row.custom .cfg-name { flex: 1; min-width: 90px; padding: 6px 9px; }
.cfg-del { padding: 5px 9px !important; font-size: 12px; }
.cfg-add { margin-top: 6px; padding: 6px 12px !important; font-size: 12px; }
.cfg-actions { display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; }
.upload-form .row { margin-bottom: 12px; align-items: center; }
.upload-form .row:last-child { margin-bottom: 0; }
.upload-form input[type="file"] { flex: 1; font-size: 13px; }
.dropzone {
  margin: 12px 0; padding: 28px 16px; border: 2px dashed var(--line); border-radius: 12px;
  text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 26px; color: var(--accent); }
.dz-text { font-size: 14px; color: var(--ink); margin: 6px 0 2px; }
.tmpl-cats { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.tmpl-cats label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.tmpl-cats input { accent-color: var(--accent); }
.tmpl-cats #tmplLink { margin-left: auto; }
.upload-cols { display: grid; grid-template-columns: 1fr 1.1fr; gap: 16px; margin: 12px 0; align-items: stretch; }
.upload-left { display: flex; flex-direction: column; gap: 12px; }
.upload-left .dropzone { margin: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.upload-right { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.up-actions { display: flex; align-items: center; gap: 8px; }
.up-actions .spacer { flex: 1; }
.up-tbl.edit td { padding: 2px 4px; }
.up-in { width: 100%; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; outline: none; }
.up-in:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.up-rm { border: none; background: none; color: var(--ink-faint); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.up-rm:hover { color: #c0392b; background: var(--surface-2); }
.up-prev-head { font-family: var(--font-head); font-weight: 700; font-size: 13px; color: var(--ink); }
.up-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.up-tab { padding: 5px 11px; font-size: 12.5px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.up-tab.sel { background: var(--accent); color: #fbf7ef; border-color: var(--accent); }
.up-tab-n { font-variant-numeric: tabular-nums; opacity: .8; }
.up-prev-list { flex: 1; min-height: 240px; max-height: 52vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.up-list-head { font-size: 13px; margin-bottom: 6px; }
.up-list-head .up-cat { color: var(--accent); font-weight: 800; }
.up-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.up-tbl th { text-align: left; color: var(--ink-faint); font-weight: 700; font-size: 11.5px; border-bottom: 1px solid var(--line); padding: 4px 6px; position: sticky; top: 0; background: var(--surface); }
.up-tbl td { padding: 4px 6px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
#upRegisterBtn { align-self: stretch; padding: 10px; font-size: 14px; }
.mg-sum { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin-bottom: 8px; }
.mg-cat-h { font-family: var(--font-head); font-weight: 800; font-size: 12px; color: var(--accent); margin: 12px 0 4px; }
.mg-grp { border-bottom: 1px solid var(--line-soft); }
.mg-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.mg-row .spacer { flex: 1; }
.mg-caret { background: none; border: none; cursor: pointer; color: var(--ink-faint); width: 16px; }
.mg-name { font-weight: 600; font-size: 13.5px; }
.mg-n { font-size: 11.5px; color: var(--ink-faint); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.mg-rename, .mg-del, .mg-remove { padding: 4px 10px !important; font-size: 12px; }
.mg-del:hover { border-color: var(--red) !important; color: var(--red) !important; }
.mg-students { padding: 2px 0 8px 24px; }
.mg-stu { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; color: var(--ink-soft); }
.mg-stu-btns { display: flex; gap: 6px; flex: 0 0 auto; }
.mg-addstu { padding: 6px 0 2px; }
.mg-addstu .mg-add { font-size: 12.5px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); }
.up-grp { padding: 10px 0; border-bottom: 1px dashed var(--line-soft); }
.up-grp:last-child { border-bottom: none; }
.up-grp-head { font-size: 14px; margin-bottom: 4px; }
.up-students { font-size: 12.5px; line-height: 1.6; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8d0c2; border-radius: 99px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: #c7bdac; }
