:root {
  color-scheme: light;
  --ink: #172027;
  --muted: #62707d;
  --line: #d8dee4;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --green: #176f53;
  --green-soft: #edf7f2;
  --red: #b43b34;
  --red-soft: #fff0ef;
  --yellow: #f0c35a;
  --yellow-soft: #fff8e5;
  --blue: #2f68a8;
  --blue-soft: #eef5fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(47, 104, 168, 0.18);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 19px;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green);
  font-weight: 800;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 8px;
  min-width: 290px;
}

.scoreboard span {
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: center;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr) minmax(270px, 330px);
  gap: 22px;
  padding: 24px clamp(16px, 4vw, 42px);
}

.study-nav,
.support-panel section {
  align-self: start;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
}

.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-head h2 {
  margin-bottom: 0;
}

.nav-head button,
.actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.nav-head button {
  padding: 0 12px;
  white-space: nowrap;
}

.unit-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.unit-btn {
  width: 100%;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.unit-btn strong,
.unit-btn span {
  display: block;
}

.unit-btn strong {
  margin-bottom: 4px;
  font-size: 15px;
}

.unit-btn span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.unit-btn.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.practice-area {
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.toolbar p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.toolbar-controls {
  display: grid;
  gap: 10px;
  min-width: 258px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented[aria-label="学習モード"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.segmented button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.question-surface {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: clamp(16px, 3vw, 28px);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 16px;
}

#question {
  min-height: 82px;
  font-size: clamp(20px, 2.5vw, 29px);
  font-weight: 800;
  line-height: 1.45;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.choice {
  min-height: 66px;
  padding: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  line-height: 1.35;
  cursor: pointer;
}

.choice:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.choice.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.choice.incorrect {
  border-color: var(--red);
  background: var(--red-soft);
}

.choice:disabled {
  cursor: default;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  min-width: 112px;
  padding: 0 16px;
}

.actions .primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 800;
}

.feedback {
  min-height: 58px;
  margin-top: 16px;
  padding: 12px;
  border-left: 5px solid var(--line);
  background: #f6f7f8;
  line-height: 1.65;
}

.feedback.good {
  border-color: var(--green);
  background: var(--green-soft);
}

.feedback.bad {
  border-color: var(--red);
  background: var(--red-soft);
}

.feedback.reveal {
  border-color: var(--yellow);
  background: var(--yellow-soft);
}

.support-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.focus-notes {
  display: grid;
  gap: 10px;
}

.focus-notes article,
.weak-list article,
.quick-grid article {
  border: 1px solid var(--line);
  background: #fff;
}

.focus-notes article {
  padding: 12px;
}

.focus-notes h3,
.quick-grid h3 {
  margin-bottom: 6px;
  color: var(--green);
}

.focus-notes p,
.quick-grid p,
.weak-list p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.weak-list {
  display: grid;
  gap: 10px;
}

.weak-list article {
  padding: 10px;
}

.weak-list span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.weak-list strong {
  display: block;
  margin-top: 6px;
}

.summary-band {
  padding: 4px clamp(16px, 4vw, 42px) 38px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quick-grid article {
  min-height: 130px;
  padding: 14px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: minmax(230px, 290px) minmax(0, 1fr);
  }

  .support-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .topbar,
  .toolbar,
  .support-panel {
    display: grid;
  }

  .scoreboard {
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbar-controls {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-top: 20px;
  }

  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .choices,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .actions button {
    flex: 1 1 100%;
  }
}
