:root {
  --ink: #1c2430;
  --muted: #5d6878;
  --paper: #f4efe4;
  --card: #fffdf8;
  --line: #e0d6c6;
  --navy: #1e3a5f;
  --navy-deep: #14283f;
  --gold: #8d6418;
  --seal: #8f2d2d;
  --good: #1d6b45;
  --good-bg: #e7f4ec;
  --bad: #8d2f2f;
  --bad-bg: #f8e8e6;
  --shadow: 0 14px 34px rgba(28, 36, 48, 0.08);
  --sans: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top right, rgba(141, 100, 24, 0.12), transparent 26rem),
    linear-gradient(180deg, #efe6d4 0%, var(--paper) 16rem);
  line-height: 1.7;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.35; margin: 0 0 0.6rem; }
p { margin: 0 0 0.8rem; }
.skip {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--navy); color: white; padding: 0.5rem 0.8rem; z-index: 5;
}
.skip:focus { top: 1rem; }
.wrap { width: min(980px, calc(100% - 1.5rem)); margin: 0 auto; }
.topbar, .nav, .row, .actions, .quizbar, .quiztools, .stats {
  display: flex; gap: 0.8rem; align-items: center;
}
.topbar { justify-content: space-between; padding: 1.1rem 0 0.4rem; }
.brand { display: flex; gap: 0.75rem; align-items: center; color: inherit; text-decoration: none; }
.seal {
  width: 3rem; height: 3rem; display: grid; place-items: center;
  border: 2px solid var(--seal); color: var(--seal); border-radius: 50%;
  font-family: var(--serif); background: rgba(143, 45, 45, 0.06); transform: rotate(-8deg);
}
.brand small { display: block; color: var(--muted); letter-spacing: 0.08em; font-size: 0.72rem; }
.brand strong { font-family: var(--serif); font-size: 1.2rem; }
.nav { flex-wrap: wrap; }
.ghost, .solid, .choice, .file {
  border-radius: 999px; border: 1px solid var(--line); background: transparent; padding: 0.55rem 0.95rem;
}
.solid { background: var(--navy); color: white; border-color: var(--navy); }
.solid.gold { background: var(--gold); border-color: var(--gold); }
.solid.danger { background: var(--bad); border-color: var(--bad); }
.solid span, .ghost span { display: block; font-size: 0.75rem; font-weight: 500; opacity: 0.85; }
.actions .solid, .actions .ghost { min-width: 9.5rem; }
.hero, .panel, .card, .passage, .feedback {
  background: var(--card); border: 1px solid var(--line); border-radius: 1.2rem;
  box-shadow: var(--shadow); padding: 1.15rem 1.2rem; margin: 0.9rem 0;
}
.hero h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); }
.eyebrow { margin: 0; color: var(--gold); letter-spacing: 0.08em; font-size: 0.78rem; }
.fine, footer, .pct { color: var(--muted); }
.stats { align-items: stretch; padding: 0; margin: 0; }
.stats div { flex: 1; background: rgba(30, 58, 95, 0.05); border-radius: 0.9rem; padding: 0.7rem 0.8rem; }
.stats dt { color: var(--muted); font-size: 0.78rem; }
.stats dd { margin: 0; font-family: var(--serif); font-size: 1.4rem; }
.row, .actions, .grid3 { flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.grid3 .card { margin: 0; display: flex; flex-direction: column; gap: 0.7rem; }
label { display: grid; gap: 0.25rem; font-size: 0.92rem; }
select, input[type="text"], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 0.8rem; background: white; padding: 0.55rem 0.7rem;
}
textarea { min-height: 12rem; line-height: 1.8; font-family: var(--serif); }
.switch { display: flex; align-items: center; gap: 0.45rem; }
.switch input { width: 1.05rem; height: 1.05rem; }
.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: white; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 0.45rem 0.85rem; white-space: nowrap; }
.quiztools { flex-wrap: wrap; }
.seg button[aria-pressed="true"] { background: var(--navy); color: white; }
.voice-box {
  display: grid; gap: 0.35rem; margin: 0.8rem 0; padding: 0.85rem 0.9rem;
  background: #f7f1e4; border-radius: 0.9rem;
}
.mic.live { background: var(--seal); color: white; border-color: var(--seal); }
.quizbar { justify-content: space-between; align-items: flex-end; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.4rem; color: var(--navy); }
.timer.warn { color: var(--bad); }
.palette { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0 0.8rem; }
.dot {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 1px solid var(--line); background: white;
}
.dot.now { border-color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.dot.done { background: #e7eef8; }
.dot.good { background: var(--good-bg); color: var(--good); }
.dot.bad { background: var(--bad-bg); color: var(--bad); }
.passage { font-family: var(--serif); font-size: 1.05rem; }
.passage h2, .stem h2 { font-size: 1.05rem; }
.material {
  white-space: pre-wrap; background: #f7f1e4; border-radius: 0.8rem; padding: 0.8rem;
  font-family: "Yu Gothic UI", sans-serif; line-height: 1.55; overflow-x: auto;
}
.choices { display: grid; gap: 0.55rem; margin-top: 0.8rem; }
.choice {
  width: 100%; text-align: left; border-radius: 0.9rem; display: flex; gap: 0.7rem; align-items: flex-start;
  background: white;
}
.choice span {
  flex: 0 0 auto; width: 1.8rem; height: 1.8rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--paper); font-family: var(--serif);
}
.choice.on { border-color: var(--navy); background: #f3f7fc; }
.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback ul { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
.stack { display: grid; gap: 0.2rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bar { display: inline-block; width: 7rem; height: 0.55rem; background: #efe6d4; border-radius: 99px; vertical-align: middle; margin-right: 0.35rem; }
.bar span { display: block; width: var(--w); height: 100%; background: var(--navy); border-radius: inherit; }
.notice, .warn-list, .confirm {
  background: #fff6df; border: 1px solid #ead7a4; border-radius: 0.9rem; padding: 0.8rem 1rem; margin-top: 0.8rem;
}
.warn-list { background: var(--bad-bg); border-color: #efc7c2; }
.danger-zone { margin-top: 1rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.file { display: inline-flex; align-items: center; gap: 0.5rem; background: white; }
.file input { width: 14rem; }
.footer { padding: 0.4rem 0 2.4rem; font-size: 0.82rem; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(30, 58, 95, 0.35); outline-offset: 2px;
}
@media (max-width: 800px) {
  .grid3, .quizbar, .topbar { display: block; }
  .quiztools, .nav, .actions { margin-top: 0.6rem; }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); }
  .file input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
@media print {
  .topbar, .actions, .palette, .footer, .switch { display: none !important; }
  body { background: white; }
  .card, .hero, .passage { box-shadow: none; }
}
