:root {
  --ink: #1f2a1f;
  --paper: #faf7f0;
  --accent: #6b4423;
  --line: #ddd3c0;
  --ortho: #cfe3ff;
  --morph: #e3d3f7;
  --lex: #ffd6c2;
  --omit: #e5e5e5;
  --marked-ring: #1f7a3f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Serif", Georgia, "Times New Roman", serif;
  background: var(--paper);
  color: var(--ink);
}
header {
  padding: 18px 24px 10px;
  border-bottom: 2px solid var(--accent);
  background: #fff;
}
header h1 { margin: 0 0 4px; font-size: 22px; color: var(--accent); }
header .sub { font-size: 13px; color: #555; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-family: system-ui, sans-serif;
  font-size: 13px;
}
.toolbar fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.toolbar legend { font-size: 11px; color: #777; padding: 0 4px; }
.toolbar label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.btn {
  font-family: system-ui, sans-serif;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.spacer { flex: 1; }

.legend {
  display: flex;
  gap: 14px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  padding: 8px 24px;
  flex-wrap: wrap;
}
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

main { padding: 16px 24px 60px; max-width: 1200px; margin: 0 auto; }

.segment {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 14px;
  overflow: hidden;
}
.segment .seg-head {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: #888;
  padding: 6px 14px;
  background: #f4efe4;
  border-bottom: 1px solid var(--line);
}
.seg-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  padding: 8px 14px;
  border-top: 1px dotted var(--line);
  font-size: 17px;
  line-height: 1.7;
}
.seg-row:first-of-type { border-top: none; }
.seg-row .src-tag {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  padding-top: 3px;
}
.seg-row .txt-page {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  color: #999;
  display: block;
  line-height: 1.35;
  margin-top: 2px;
}

.w { padding: 1px 2px; border-radius: 3px; cursor: default; }
.w.orthographic { background: var(--ortho); }
.w.morphological { background: var(--morph); }
.w.lexical { background: var(--lex); }
.w.omission { background: var(--omit); text-decoration: line-through; color: #999; }
.w.marked { box-shadow: inset 0 -3px 0 var(--marked-ring); }
.w:hover { outline: 1px solid #333; }

#tooltip {
  position: fixed;
  max-width: 340px;
  background: #1f2a1f;
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  pointer-events: none;
  display: none;
  z-index: 20;
  line-height: 1.5;
}
#tooltip b { color: #ffd6c2; }
#tooltip .fn { color: #cde7d0; font-style: italic; margin-top: 6px; display: block; }

footer {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: #999;
  text-align: center;
  padding: 20px;
}
