:root {
  --bg: #fafaf9;
  --pane: #ffffff;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #0f766e;
  --accent-soft: #f0fdfa;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #991b1b;
  --bad-soft: #fee2e2;
  --good: #166534;
  --good-soft: #ecfdf5;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  font: 15.5px/1.55 -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--text); background: var(--bg);
}
body {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar workbench";
}

/* topbar */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--pane);
  border-bottom: 1px solid var(--border);
}
.topbar .brand strong { font-size: 18px; }
.topbar .brand .title { color: var(--muted); margin-left: 8px; font-size: 14px; }
.topbar .progress {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
  color: var(--muted);
}
.topbar .dot { opacity: 0.4; }
.score.good { color: var(--good); }
.score.warn { color: var(--warn); }
.score.bad  { color: var(--bad); }

.actions { display: flex; gap: 8px; margin-left: 16px; }
button {
  font: inherit;
  background: var(--pane); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--bg); }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover { filter: brightness(0.95); }
button.ghost { border: none; background: transparent; color: var(--muted); padding: 2px 6px; font-size: 13px; }
button.ghost:hover { color: var(--text); }

/* sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--pane);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 0;
}
#filter {
  display: block; width: calc(100% - 16px); margin: 8px;
  padding: 6px 8px; font: inherit;
  border: 1px solid var(--border-strong); border-radius: 6px;
}
#segList { list-style: none; margin: 0; padding: 0; }
#segList li {
  padding: 8px 14px; cursor: pointer; font-size: 13.5px;
  border-left: 3px solid transparent;
  display: flex; gap: 8px; align-items: center;
}
#segList li:hover { background: var(--bg); }
#segList li.active {
  background: var(--accent-soft); border-left-color: var(--accent);
  color: var(--text);
}
#segList li .num { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; min-width: 28px; }
#segList li .preview { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#segList li.flagged .num::after { content: "●"; color: var(--warn); margin-left: 4px; }
#segList li.edited::before { content: "✎"; color: var(--accent); }
#segList li .chapter-h { color: var(--muted); font-size: 11px; padding: 6px 0 2px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* workbench */
.workbench {
  grid-area: workbench;
  display: grid;
  grid-template-columns: 1fr 1fr 380px;
  gap: 0;
  overflow: hidden;
}
.pane {
  padding: 16px 20px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.pane:last-child { border-right: none; }
.pane h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 0 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.pane .body { font-size: 16px; line-height: 1.65; }
.pane.source .body { color: #44403c; }
.pane.target .body.editable {
  background: var(--pane);
  border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 12px 14px;
  min-height: 220px; outline: none;
  white-space: pre-wrap;
}
.pane.target .body.editable:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* flag highlights inline in the editor view */
mark.flag {
  background: var(--warn-soft);
  border-bottom: 2px solid var(--warn);
  padding: 0 2px; border-radius: 2px;
}
mark.flag.bad { background: var(--bad-soft); border-bottom-color: var(--bad); }
mark.flag.weak { background: #f5f5f4; border-bottom: 2px dotted var(--muted); }

/* flag pane */
#flagList { display: flex; flex-direction: column; gap: 8px; }
.flag-card {
  background: var(--pane);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  padding: 10px 12px;
}
.flag-card.bad { border-left-color: var(--bad); }
.flag-card.weak { border-left-color: var(--muted); }
.flag-card .head {
  display: flex; gap: 8px; align-items: center; font-size: 12px;
  margin-bottom: 4px;
}
.flag-card .code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px; padding: 1px 5px; border-radius: 3px;
  background: var(--warn-soft); color: var(--warn);
}
.flag-card.bad .code { background: var(--bad-soft); color: var(--bad); }
.flag-card.weak .code { background: #f5f5f4; color: var(--muted); }
.flag-card .word { font-weight: 600; }
.flag-card .msg { color: #57534e; font-size: 13.5px; }
.flag-card .suggestions {
  margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap;
}
.flag-card .suggestions button {
  padding: 2px 8px; font-size: 12px;
  border-radius: 999px; background: var(--bg);
}
.flag-card .suggestions button:hover { background: var(--accent-soft); border-color: var(--accent); }
.muted { color: var(--muted); font-weight: normal; }

/* Word lookup card */
.lookup-card {
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.lookup-head { display: flex; gap: 10px; align-items: baseline; }
.lookup-form { font-weight: 600; font-size: 16px; color: var(--text); }
.lookup-pos { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.lookup-lemma { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lookup-lemma .label { text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; }
.lookup-lemma b { color: var(--text); font-style: italic; }
.lookup-analyses {
  margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap;
}
.lookup-analyses .reading {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  background: white; border: 1px solid #ccfbf1;
  padding: 2px 6px; border-radius: 3px; color: var(--muted);
}
.lookup-explanation {
  margin-top: 8px; font-size: 13.5px; color: #44403c; line-height: 1.55;
}
.lookup-explanation em { font-style: italic; color: var(--muted); }

/* Paradigm grid */
.paradigm-box { margin-top: 10px; }
.paradigm-box .ptitle {
  font-size: 11px; text-transform: uppercase;
  color: var(--muted); letter-spacing: 0.04em; margin: 8px 0 4px;
}
.paradigm-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
  background: white; border: 1px solid #ccfbf1; border-radius: 4px;
  overflow: hidden;
}
.paradigm-table th, .paradigm-table td {
  padding: 3px 6px; text-align: left;
  border-top: 1px solid #f5f5f4;
}
.paradigm-table th {
  background: #f0fdfa; color: var(--muted);
  font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.paradigm-table td {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}
.paradigm-table td.cur { background: var(--warn-soft); font-weight: 600; }
.paradigm-table td.empty { color: var(--muted); font-family: inherit; }
.paradigm-table tr td:first-child, .paradigm-table tr th:first-child {
  color: var(--muted); font-family: inherit; font-size: 11.5px;
}

/* Alternative meanings (homographs) stacked beneath the primary card */
.alt-meaning {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed #ccfbf1;
}
.alt-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.alt-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); font-weight: 600;
}

/* Verb non-finite forms: labelled chip rows */
.verb-line {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 6px;
}
.verb-lab {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); min-width: 130px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 1000; box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
