:root {
  --surface: #18181b;
  --card: #131316;
  --plane: #0c0c0e;
  --ink: rgba(240, 239, 236, 0.95);
  --ink-2: rgba(240, 239, 236, 0.65);
  --muted: rgba(240, 239, 236, 0.42);
  --grid: #202023;
  --axis: #2e2e32;
  --accent: #d96c4f;
  /* state identity (validated on #131316, dark) */
  --known: #4f9e78;
  --learning: #d96c4f;
  --new: #a89a7e;
  --ignored: #55555c;
  /* terracotta sequential ramp (ordinal, light -> deep) */
  --seq-1: #f3d5c9; --seq-2: #e8b2a0; --seq-3: #de8f77; --seq-4: #d96c4f; --seq-5: #b6533a; --seq-6: #8e3f2c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--plane);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 32px 20px 64px;
  line-height: 1.5;
}

.wrap { max-width: 1080px; margin: 0 auto; }

.head h1 {
  font-size: 22px; font-weight: 700;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
.head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* stat tiles */
.tiles {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px;
  margin: 24px 0;
}
.tile {
  background: var(--card); border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; padding: 16px 14px;
}
.tile .val { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.tile .lab { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.tile .val.known { color: var(--known); }
.tile .val.learning { color: var(--learning); }
.tile .val.accent { color: var(--accent); }

/* chart grid */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
}
.card {
  background: var(--card); border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px; padding: 18px 18px 12px;
}
.card.wide { grid-column: 1 / -1; }
figcaption { margin-bottom: 12px; }
figcaption h2, .list-head h2 { font-size: 14px; font-weight: 600; }
.cap-note { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
#chart-cal svg { width: auto; max-width: 100%; }

.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.legend { list-style: none; font-size: 12px; display: grid; gap: 7px; }
.legend li { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* svg text roles */
.ax { fill: var(--muted); font-size: 11px; }
.ax-val { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.dlabel { fill: var(--ink); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* word list */
.list-card { }
.list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.list-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#word-search {
  background: var(--surface); border: 1px solid var(--axis); color: var(--ink);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; min-width: 220px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent; border: 1px solid var(--axis); color: var(--ink-2);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--plane); }
.list-note { font-size: 11px; color: var(--muted); margin-bottom: 8px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.05); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
td.romaji { font-weight: 600; }
td.jp { font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }
td.meaning { white-space: normal; color: var(--ink-2); max-width: 280px; }
.state-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.state-tag.known { background: rgba(79,158,120,.16); color: var(--known); }
.state-tag.learning { background: rgba(217,108,79,.16); color: var(--learning); }
.state-tag.new { background: rgba(168,154,126,.14); color: var(--new); }
.state-tag.ignored { background: rgba(255,255,255,.06); color: var(--muted); }

/* Chrome Web Store review prompt (idle dashboard only) */
.rp-host { margin: 0 0 16px; }
.rp-host[hidden] { display: none; }
.rp-card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}
.rp-copy { font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.rp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-btn {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  color: var(--ink);
}
.rp-btn-primary { background: var(--accent); border-color: var(--accent); color: #fffdf6; }
.rp-btn-ghost { border-color: rgba(255,255,255,.18); color: var(--ink-2); }
.rp-btn-quiet { color: var(--muted); border-color: transparent; }
.rp-btn:hover { opacity: 0.9; }

.empty { text-align: center; color: var(--muted); padding: 40px; font-size: 14px; }

/* tooltip */
.tooltip {
  position: fixed; pointer-events: none; z-index: 100;
  background: #0d0d12; border: 1px solid var(--axis); color: var(--ink);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: 240px;
}
.tooltip .t-jp { font-family: "Hiragino Sans","Yu Gothic","Noto Sans JP",sans-serif; }
.tooltip b { color: var(--accent); }

@media (max-width: 720px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
