:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: #28241f;
  background: #f7f4ee;
  font-synthesis: none;
  --paper: #fffdf8;
  --ink: #28241f;
  --muted: #62594f;
  --line: #e4dbce;
  --red: #9a352e;
  --red-dark: #802923;
  --serif: Georgia, "Times New Roman", serif;
  --ja: "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans CJK JP", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #5b753d;
  outline-offset: 3px;
}
h1:focus { outline: none; }
p, h1, h2 { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
h1 { font-size: clamp(2.1rem, 5.6vw, 3.6rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { font-size: clamp(1.43rem, 3.25vw, 2rem); letter-spacing: -.035em; }
p { line-height: 1.57; }
[lang="ja"] { font-family: var(--ja); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.shell { width: min(100% - 72px, 1040px); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wordmark { border: 0; background: none; padding: 0; display: flex; gap: 9px; align-items: center; font-weight: 750; font-size: 1.23rem; letter-spacing: -.045em; white-space: nowrap; }
.brand-accent { color: var(--red); }
.brand-seal { display: inline-grid; place-items: center; width: 36px; aspect-ratio: 1; background: var(--red); color: #fff7eb; border-radius: 9px; font-size: 1.15rem; font-weight: 650; }
nav { align-self: stretch; display: flex; gap: 18px; }
nav button { min-height: 44px; padding: 0 5px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: .9rem; font-weight: 650; }
nav button[aria-current], nav button:hover { color: var(--red); border-bottom-color: var(--red); }
#app { min-height: 55vh; padding-block: 32px 18px; }
.hero {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  background: #963a32;
  color: #fff9ee;
  border-radius: 25px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 36px;
  padding: 44px clamp(35px, 6vw, 71px);
}
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 87% 55%, #c86350 0%, #a84036 36%, transparent 70%), linear-gradient(117deg, #91352e, #a5453b);
}
.hero::after {
  content: "";
  pointer-events: none;
  position: absolute;
  z-index: -1;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  right: -186px;
  top: -144px;
  border: 1px solid #ffdab340;
  box-shadow: 0 0 0 38px #ffdab316, 0 0 0 97px #ffdab317, 0 0 0 152px #ffdab30d;
}
.hero-copy { max-width: 455px; }
.hero-duration { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 16px; font-size: .74rem; letter-spacing: .13em; font-weight: 750; }
.hero-duration span { font-size: 1.2rem; line-height: 1; }
.hero h1 { font-size: clamp(3.4rem, 8vw, 5.6rem); line-height: .92; letter-spacing: -.065em; }
.hero p { max-width: 32ch; margin: 18px 0 23px; color: #fff0e5; }
.hero-button, .primary, .secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  line-height: 1.25;
  font-weight: 700;
  font-size: .93rem;
}
.hero-button { background: #fff7e8; color: #75271e; }
.hero-button:hover { background: #fff; }
.hero-button:focus-visible, .trace-card:focus-visible { outline-color: #fff1ba; }
.primary { background: var(--red); color: #fff9ee; }
.primary:not(:disabled):hover { background: var(--red-dark); }
.primary:disabled { opacity: .55; }
.secondary { color: var(--red-dark); background: var(--paper); border-color: #d7c2b2; }
.secondary:hover { background: #f6eae0; }
.text-button { color: var(--red-dark); background: none; border: 0; min-height: 44px; padding: 5px 0; font-size: .88rem; font-weight: 700; text-align: left; }
.text-button:not(:disabled):hover { text-decoration: underline; }
.text-button:disabled { color: var(--muted); opacity: .6; }
.trace-card {
  width: clamp(165px, 23vw, 235px);
  padding: 17px 18px 13px;
  border: 1px solid #ead3b5;
  border-radius: 15px;
  background: #faedda;
  color: #6d392f;
  display: grid;
  gap: 9px;
  box-shadow: 0 12px 32px #641f263d;
  transform: rotate(4deg);
  transition: transform .2s ease;
  text-align: left;
}
.trace-card:hover { transform: rotate(0); }
.trace-label { font-size: .67rem; letter-spacing: .13em; font-weight: 750; }
.trace-grid, .draw-grid {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #cfae94;
  background: linear-gradient(90deg, transparent 49.75%, #d7b6a1 49.75%, #d7b6a1 50.25%, transparent 50.25%),
    linear-gradient(transparent 49.75%, #d7b6a1 49.75%, #d7b6a1 50.25%, transparent 50.25%);
}
.trace-grid { color: #984032; }
.trace-grid span { font-size: clamp(3.5rem, 10vw, 7rem); line-height: 1; }
.trace-caption { font-size: .82rem; font-weight: 650; }
.trace-caption [aria-hidden] { float: right; }
.practice-section { margin-top: 27px; }
.section-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
.topic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 12px; }
.topic-card { display: flex; flex-direction: column; gap: 9px; min-width: 0; text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 17px; background: var(--paper); transition: border-color .18s ease, background .18s ease; }
.topic-card:hover { border-color: #bca79b; background: #fff; }
.topic-top { display: flex; justify-content: space-between; align-items: center; color: var(--red); }
.topic-mark { display: inline-grid; place-items: center; width: 41px; aspect-ratio: 1; border-radius: 9px; font-size: 1.35rem; font-weight: 600; }
.mark-vocabulary { background: #eaf0de; color: #3c5c30; }
.mark-grammar { background: #f6e6ce; color: #734c19; }
.mark-kanji { background: #f6ded9; color: #913d31; }
.topic-card strong { font-size: 1.14rem; letter-spacing: -.026em; }
.topic-description { flex: 1; color: var(--muted); font-size: .87rem; line-height: 1.48; }
.topic-count { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.review-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f0ebe2; padding: 10px 15px; color: var(--muted); font-size: .88rem; }
.review-strip strong { color: var(--ink); font-size: 1rem; margin-right: 3px; }
.review-strip button { margin-left: auto; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 0 6px; padding-bottom: max(14px, env(safe-area-inset-bottom)); font-size: .76rem; color: var(--muted); }
.site-footer .text-button { font-size: inherit; }
.offline-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #8e8175; }
.offline-ready::before { background: #577442; }

.panel { max-width: 740px; margin-inline: auto; padding: clamp(17px, 4vw, 33px); border-radius: 18px; border: 1px solid var(--line); background: var(--paper); }
.panel h1 { margin: 10px 0; }
.back { display: block; margin: -8px 0 8px; }
.setup form { display: grid; gap: 15px; margin-top: 24px; }
.setup label { display: grid; gap: 7px; font-size: .95rem; font-weight: 650; }
.setup .primary { justify-self: start; margin-top: 5px; }
select, .answer-form input { padding: 10px 12px; border: 1px solid #cabead; border-radius: 8px; background: #fff; min-width: 0; min-height: 46px; font-size: 1rem; }
.practice-top { display: flex; justify-content: space-between; align-items: center; }
.timer { color: var(--red-dark); background: #f4e4da; border-radius: 20px; font-weight: 750; padding: 7px 12px; font-variant-numeric: tabular-nums; }
progress { appearance: none; width: 100%; height: 7px; border: 0; border-radius: 8px; background: #e7ded2; overflow: hidden; }
progress::-webkit-progress-bar { background: #e7ded2; }
progress::-webkit-progress-value { background: var(--red); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--red); }
.question-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .84rem; margin: 13px 0 17px; }
.practice-panel .question-heading { font-family: inherit; font-size: 1.05rem; font-weight: 650; letter-spacing: 0; line-height: 1.3; }
.question-prompt { overflow-wrap: anywhere; margin: 7px 0 11px; font-size: clamp(1.55rem, 5.8vw, 2.65rem); font-weight: 650; line-height: 1.34; }
.glyph-prompt { font-size: clamp(2.8rem, 10vw, 4.5rem); }
.question-clue { margin-bottom: 12px; color: var(--muted); }
.practice-panel:not(.show-furigana) rt { display: none; }
.practice-panel rt { font-size: .5em; font-weight: 500; }
.question-help { margin-top: 8px; }
.hint-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.hint-buttons button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--red-dark);
  padding: 6px 12px;
  font-size: .85rem;
  font-weight: 650;
}
.hint-buttons button[aria-pressed="true"] { background: #f4e4da; border-color: #c78e81; }
.question-glossary {
  display: grid;
  gap: 5px;
  background: #f7f1e8;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 0;
}
.question-glossary div { display: grid; grid-template-columns: minmax(75px, max-content) 1fr; align-items: baseline; gap: 10px; }
.question-glossary dt { font-weight: 650; }
.question-glossary dd { margin: 0; color: var(--muted); font-size: .88rem; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 19px; }
.answer-option { display: flex; align-items: center; justify-content: space-between; gap: 4px; background: #fff; border: 1px solid #d9cdbf; padding: 11px 13px; min-height: 48px; border-radius: 9px; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
.answer-option:not(:disabled):hover { background: #f6ede1; }
.answer-option.option-right, .feedback-right { background: #eaf0de; border-color: #adbea0; color: #304e2a; }
.answer-option.option-wrong, .feedback-wrong { background: #f6e3db; border-color: #ddaca0; color: #762e22; }
.answer-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 19px; }
.answer-form input { flex: 1 0 min(100%, 180px); }
.feedback { border-radius: 9px; border: 1px solid; margin-top: 14px; padding: 11px 13px; outline: none; }
.feedback p { margin-top: 4px; font-size: .9rem; }
.question-actions, .inline-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.question-actions { margin-top: 13px; }
.draw-wrap { margin-top: 16px; width: min(100%, 266px); }
.draw-grid { background-color: #fcf6ec; }
.draw-grid canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; border-radius: inherit; cursor: crosshair; }
.draw-grid canvas[data-locked] { cursor: default; }
.model-glyph { color: #ad554b69; font-size: clamp(7.7rem, 37vw, 13rem); line-height: 1; }
.draw-tools { display: flex; justify-content: space-between; gap: 9px; }
.draw-wrap .muted { margin-top: 8px; }
.page-heading { margin: 10px auto 18px; max-width: 740px; }
.page-heading p, .progress-panel p { margin-top: 7px; }
.progress-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; max-width: 740px; margin: 0 auto 14px; }
.progress-metrics div { border: 1px solid var(--line); background: var(--paper); padding: clamp(9px, 3vw, 16px); border-radius: 11px; display: grid; gap: 4px; }
.progress-metrics strong { font-family: var(--serif); color: var(--red); font-size: clamp(1.6rem, 5vw, 2.3rem); font-weight: 500; }
.progress-metrics span { color: var(--muted); font-size: .83rem; }
.progress-panel { margin-bottom: 14px; }
.progress-panel .inline-actions { margin-top: 12px; }
#backup-status:empty { display: none; }
.pending-list { padding: 0; margin: 12px 0 0; list-style: none; }
.pending-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-block: 10px; border-top: 1px solid var(--line); }
.pending-list small { color: var(--muted); }
.summary p { margin: 12px 0; }
.storage-warning { padding: 10px 0; color: #762e22; }
dialog { max-width: min(92vw, 430px); border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #29242190; }
.dialog-inner { padding: 21px; }
.dialog-inner ol { padding-left: 22px; line-height: 1.55; }
.dialog-inner form { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 720px) {
  .shell { width: min(100% - 36px, 1040px); }
  .hero { gap: 19px; padding: 30px; }
  .topic-grid { gap: 10px; }
  .topic-card { padding: 13px; }
}

@media (max-width: 510px) {
  .shell { width: calc(100% - 28px); }
  .header-inner { min-height: 62px; }
  nav { gap: 9px; }
  .wordmark { font-size: 1.06rem; }
  .brand-seal { width: 31px; }
  #app { padding-top: 15px; }
  .hero { display: block; min-height: 300px; border-radius: 18px; padding: 24px 18px; }
  .hero-duration { margin-bottom: 12px; }
  .hero h1 { font-size: clamp(2.85rem, 12vw, 3.9rem); }
  .hero p { margin: 14px 0 16px; }
  .hero-copy { position: relative; z-index: 1; }
  .trace-card { display: flex; align-items: center; gap: 10px; width: auto; margin-top: 16px; padding: 5px 9px; transform: none; box-shadow: none; border-radius: 8px; min-height: 44px; }
  .trace-label { display: none; }
  .trace-grid { width: auto; border: 0; background: none; }
  .trace-grid span { font-size: 1.25rem; }
  .trace-caption [aria-hidden] { margin-left: 8px; float: none; }
  .hero::after { right: -450px; }
  .practice-section { margin-top: 20px; }
  .topic-grid { grid-template-columns: 1fr; gap: 8px; }
  .topic-card { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
  .topic-top { grid-column: 1; grid-row: 1 / 4; align-self: start; }
  .topic-top .arrow { display: none; }
  .topic-description, .topic-count { grid-column: 2; }
  .topic-count { margin-top: 0; }
  .review-strip button { margin-left: 0; }
  .answer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
