:root {
  --ink: #171613;
  --muted: #77736a;
  --paper: #f5f0e6;
  --surface: #fffdf8;
  --line: #d8d0c2;
  --accent: #b64232;
  --accent-soft: #f1d6cd;
  --green: #315f4c;
  --shadow: 0 24px 70px rgba(51, 43, 31, 0.12);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(85, 70, 48, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 70, 48, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "DM Sans", "Noto Sans JP", system-ui, sans-serif;
  min-height: 100vh;
}

button, input, audio { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--surface);
  background: var(--ink);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-meta { display: flex; align-items: center; gap: 20px; }
.level-badge {
  padding: 8px 12px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.today-count { color: var(--muted); font-size: 13px; }
.today-count b { color: var(--ink); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 60px;
  padding: 56px 0 42px;
}

.practice-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(32px, 4vw, 54px);
  font-weight: 600;
  letter-spacing: -0.055em;
}

.quiet-button, .text-button, .reset-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}
.quiet-button:hover, .text-button:hover, .reset-button:hover { color: var(--ink); }

.filter-bar {
  display: flex;
  gap: 8px;
  margin: 36px 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  transition: 180ms ease;
}
.filter:hover { color: var(--ink); border-color: var(--line); }
.filter.is-active { color: var(--surface); background: var(--ink); }

.progress-track {
  height: 2px;
  overflow: hidden;
  background: var(--line);
}
.progress-track span {
  display: block;
  width: 10%;
  height: 100%;
  background: var(--accent);
  transition: width 400ms ease;
}

.question-stage {
  min-height: 580px;
  padding: 34px 0 0;
  animation: rise 420ms cubic-bezier(.2,.7,.2,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.question-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-text {
  max-width: 800px;
  margin: 30px 0 28px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(20px, 2.15vw, 28px);
  font-weight: 500;
  line-height: 1.75;
  letter-spacing: -0.02em;
}

.question-text u {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.passage {
  margin: 26px 0 0;
  padding: 22px 24px;
  border-left: 3px solid var(--accent);
  color: #3f3b34;
  background: rgba(255, 253, 248, 0.58);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.9;
}

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option {
  position: relative;
  min-height: 68px;
  padding: 16px 48px 16px 54px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.6);
  text-align: left;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.option:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--surface);
  transform: translateY(-1px);
}
.option-key {
  position: absolute;
  left: 18px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--green); background: #e5efe9; }
.option.is-wrong { border-color: var(--accent); background: #f4dfd9; }
.option.is-correct::after, .option.is-wrong::after {
  position: absolute;
  right: 18px;
  top: 50%;
  translate: 0 -50%;
  font-weight: 700;
}
.option.is-correct::after { content: "✓"; color: var(--green); }
.option.is-wrong::after { content: "×"; color: var(--accent); }

.listening-prompt {
  display: flex;
  align-items: center;
  gap: 26px;
  margin: 26px 0 4px;
  padding: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.54);
}
.play-button {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.play-button b { display: block; font-size: 14px; }
.play-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.play-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding-left: 2px;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(182, 66, 50, 0.24);
}
.sound-bars { display: flex; align-items: center; gap: 5px; height: 34px; }
.sound-bars i { width: 3px; height: 10px; background: var(--line); border-radius: 2px; }
.sound-bars i:nth-child(2), .sound-bars i:nth-child(7) { height: 18px; }
.sound-bars i:nth-child(3), .sound-bars i:nth-child(6) { height: 26px; }
.sound-bars i:nth-child(4), .sound-bars i:nth-child(5) { height: 34px; }
.listening-prompt.is-playing .sound-bars i {
  background: var(--accent);
  animation: wave 700ms ease-in-out infinite alternate;
}
.listening-prompt.is-playing .sound-bars i:nth-child(2n) { animation-delay: -260ms; }
@keyframes wave { to { scale: 1 0.35; } }

.result-panel {
  margin-top: 24px;
  padding: 22px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.46);
  animation: rise 280ms ease both;
}
.result-heading { display: flex; align-items: center; gap: 14px; }
.result-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  background: var(--green);
}
.result-panel.is-wrong .result-mark { background: var(--accent); }
.result-heading p { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.result-heading strong { font-family: "Noto Sans JP", sans-serif; font-size: 15px; }
.explanation, .transcript {
  margin: 16px 0 0 48px;
  color: #504b43;
  font-size: 14px;
  line-height: 1.75;
}
.transcript {
  padding: 12px 14px;
  background: #eee9df;
  font-family: "Noto Sans JP", sans-serif;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
}
.next-button {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 13px 17px;
  border: 0;
  border-radius: 4px;
  color: white;
  background: var(--ink);
  font-size: 13px;
}
.next-button:hover { background: var(--accent); }

.side-panel {
  padding-left: 30px;
  border-left: 1px solid var(--line);
}
.side-panel section { padding: 0 0 28px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.section-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 22px; }
.score-row strong { display: block; font-size: 26px; font-weight: 600; letter-spacing: -0.05em; }
.score-row span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.muse-note {
  margin: 24px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
  color: #5f5a51;
  font-size: 13px;
  line-height: 1.7;
}
.official-block h2 { margin: 24px 0 8px; font-family: "Noto Sans JP", sans-serif; font-size: 19px; }
.official-block p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.official-block audio { width: 100%; height: 38px; }
.official-links { display: grid; gap: 9px; margin-top: 16px; }
.official-links a { color: var(--ink); font-size: 12px; text-decoration-color: var(--line); text-underline-offset: 4px; }
.official-links a:hover { color: var(--accent); }

.wrong-block button:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 17px;
  border: 0;
  border-radius: 4px;
  color: white;
  background: var(--accent);
  text-align: left;
}
.wrong-block small, .wrong-block b { display: block; }
.wrong-block small { opacity: 0.72; font-size: 10px; }
.wrong-block b { margin-top: 4px; font-size: 13px; }
.reset-button { width: 100%; margin-top: 12px; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 24px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
footer a { color: inherit; text-underline-offset: 3px; }
footer a:hover { color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  translate: -50% 12px;
  padding: 11px 16px;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 200ms ease;
}
.toast.is-visible { opacity: 1; translate: -50% 0; }
.is-hidden { display: none !important; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; gap: 24px; padding-top: 38px; }
  .side-panel { padding: 28px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
  .side-panel section { margin: 0; }
  .wrong-block { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 28px, 1280px); }
  .topbar { height: 74px; }
  .today-count { display: none; }
  .workspace { padding-top: 28px; }
  .practice-head { align-items: center; }
  h1 { font-size: 32px; }
  .filter-bar { margin-top: 26px; }
  .question-stage { min-height: 560px; padding-top: 24px; }
  .options { grid-template-columns: 1fr; }
  .option { min-height: 60px; }
  .question-text { margin-top: 24px; font-size: 20px; line-height: 1.7; }
  .passage { padding: 18px; font-size: 14px; max-height: 230px; overflow-y: auto; }
  .listening-prompt { gap: 16px; }
  .sound-bars { margin-left: auto; }
  .result-panel { padding: 18px 16px; }
  .explanation, .transcript { margin-left: 0; }
  .side-panel { grid-template-columns: 1fr; }
  .wrong-block { grid-column: auto; }
  footer { display: grid; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
