:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f4eee5;
  --text: #221c17;
  --muted: #6f655b;
  --line: #e6ddd0;
  --primary: #b3261e;
  --primary-ink: #ffffff;
  --primary-soft: #fbe3df;
  --accent: #e0a100;
  --accent-soft: #fff3cc;
  --ok: #1e7a46;
  --ok-soft: #dff3e6;
  --ng: #b3261e;
  --ng-soft: #fbe3df;
  --warn: #9a6a00;
  --warn-soft: #fff3cc;
  --ipa: #3d5a99;
  --male: #2f63b8;
  --female: #c0397a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 14px;
  --font: "Noto Sans", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  --font-ipa: "Noto Sans", "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", "Arial Unicode MS", sans-serif;
  --font-display: "Fraunces", Georgia, "Hiragino Mincho ProN", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f; --surface: #221d18; --surface-2: #2b251f; --text: #f3ece3; --muted: #b0a597; --line: #3a322a;
    --primary: #ef6b5f; --primary-ink: #1a0f0d; --primary-soft: #3d1f1b; --accent: #ffc94a; --accent-soft: #3a2f12;
    --ok: #5bd18f; --ok-soft: #173325; --ng: #ff8a80; --ng-soft: #3d1f1b; --warn: #ffd166; --warn-soft: #3a2f12;
    --ipa: #9db7ff; --male: #8fb4ff; --female: #ff9bc8; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f; --surface: #221d18; --surface-2: #2b251f; --text: #f3ece3; --muted: #b0a597; --line: #3a322a;
  --primary: #ef6b5f; --primary-ink: #1a0f0d; --primary-soft: #3d1f1b; --accent: #ffc94a; --accent-soft: #3a2f12;
  --ok: #5bd18f; --ok-soft: #173325; --ng: #ff8a80; --ng-soft: #3d1f1b; --warn: #ffd166; --warn-soft: #3a2f12;
  --ipa: #9db7ff; --male: #8fb4ff; --female: #ff9bc8; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.65; font-size: 16px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
h2 { font-size: 1.2rem; }
p { margin: .4em 0; }
small { font-size: .7em; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: .9rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- レイアウト ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #ffc400; display: grid; place-items: center; font-size: 1.4rem; line-height: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; }

.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; gap: 24px; padding: 0 16px; }
.main { padding: 24px 0 96px; min-width: 0; }
.nav.side { position: sticky; top: 70px; align-self: start; display: flex; flex-direction: column; gap: 2px; padding-top: 24px; }
.nav.side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav.side a:hover { background: var(--surface-2); color: var(--text); }
.nav.side a.active { background: var(--primary-soft); color: var(--primary); }
.nav.bottom { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav.side { display: none; }
  .nav.bottom { display: grid; grid-template-columns: repeat(7, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
  .nav.bottom a { display: flex; flex-direction: column; align-items: center; padding: 4px 0; color: var(--muted); font-size: .62rem; font-weight: 600; border-radius: 8px; }
  .nav.bottom a .ni { font-size: 1.25rem; line-height: 1.3; }
  .nav.bottom a.active { color: var(--primary); background: var(--primary-soft); }
  .main { padding-top: 16px; }
  .variety button { padding: 6px 8px; font-size: .78rem; }
  .brand > span:last-child { display: none; }
}

/* ---------- 共通部品 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; min-height: 40px; transition: transform .08s ease, background .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ng { background: var(--surface); color: var(--ng); border-color: var(--ng); }
.btn.danger { color: var(--ng); border-color: var(--ng); }
.btn.big { padding: 14px 24px; font-size: 1.1rem; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.spk { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent-soft); font-size: 1rem; display: inline-grid; place-items: center; }
.spk:hover { border-color: var(--accent); }
.cell-spk { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; border-bottom: 1px dashed var(--muted); text-align: left; }
.cell-spk:hover { color: var(--primary); border-color: var(--primary); }
.ipa { font-family: var(--font-ipa); color: var(--ipa); letter-spacing: .01em; }
.ipa.sm { font-size: .82rem; }
.es { font-weight: 600; font-size: 1.08rem; }
.ja { color: var(--muted); }
.note { font-size: .85rem; background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.irr { background: var(--primary-soft); color: var(--primary); }
.lv { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.lv1 { background: var(--ok-soft); color: var(--ok); }
.lv2 { background: var(--accent-soft); color: var(--warn); }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .3s; }
.grid { display: grid; gap: 14px; }
.section-title { margin: 32px 0 12px; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.page-head { margin-bottom: 16px; }
.page-head p { color: var(--muted); }
.back { display: inline-block; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.back:hover { color: var(--primary); }
.center { text-align: center; }
.info { margin-bottom: 14px; font-size: .92rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.letter { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; white-space: nowrap; }
td.sym { font-size: 1.15rem; white-space: nowrap; }
input[type=text], input[type=search], select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px; }
input:focus, select:focus, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 220px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: thin; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: .88rem; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.choice { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px; margin: 6px 0; font-weight: 600; }
.choice:hover { border-color: var(--primary); }
.choice.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.choice.wrong { background: var(--ng-soft); border-color: var(--ng); color: var(--ng); }
.fb { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb.ok { background: var(--ok-soft); color: var(--ok); }
.fb.ng { background: var(--ng-soft); color: var(--ng); }
.fb.warn { background: var(--warn-soft); color: var(--warn); }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 22px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.field { display: block; font-weight: 600; margin-bottom: 12px; }
.field input { width: 100%; margin-top: 6px; }
.field select { width: 100%; margin-top: 6px; }
.gender-seg { display: flex; margin-top: 6px; }
.gender-seg button { flex: 1; padding: 8px 12px; }
.voice-note { white-space: pre-line; margin-top: -4px; }
#gender-btn { font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- ホーム ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; margin-bottom: 20px; }
.eyebrow { color: var(--primary); font-weight: 700; letter-spacing: .04em; margin: 0 0 6px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4.2vw, 2.7rem); }
.lead { color: var(--muted); }
.hero-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.today { border-top: 4px solid var(--accent); }
.today .label { font-size: .8rem; font-weight: 700; color: var(--warn); }
.today-es { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; margin: 6px 0 2px; }
.today-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat .num { font-size: 1.6rem; font-weight: 700; font-family: var(--font-display); }
.stat .cap { color: var(--muted); font-size: .82rem; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { display: flex; gap: 12px; align-items: flex-start; transition: border-color .15s, transform .15s; }
.step:hover { border-color: var(--primary); transform: translateY(-2px); }
.step-n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; }
.step-t { font-weight: 700; }
.step-d { color: var(--muted); font-size: .85rem; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat:first-child { grid-column: span 2; }
  .steps { grid-template-columns: 1fr; }
}

/* ---------- 発音 ---------- */
.tool h2 { margin-bottom: 4px; }
.tool-row { display: flex; gap: 8px; margin: 10px 0; }
.tool-row input { flex: 1; min-width: 0; font-size: 1.05rem; }
.ipa-big { font-family: var(--font-ipa); color: var(--ipa); font-size: 1.5rem; margin: 4px 0; word-break: break-word; }
.vowels { grid-template-columns: repeat(5, 1fr); }
.vowel { text-align: center; }
.vowel p { font-size: .82rem; color: var(--muted); text-align: left; }
.vowel .ex { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.big-letter { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; border: 0; background: none; color: var(--primary); line-height: 1.1; }
.combos { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.combo-h { font-size: 1.15rem; margin-bottom: 6px; }
.combos .ex { line-height: 2.4; }
.combos p { font-size: .85rem; color: var(--muted); }
.rules { grid-template-columns: repeat(3, 1fr); }
.rule { position: relative; }
.rule h3 { font-size: 1rem; margin-bottom: 0; }
.rule p { color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.rule > div { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.rule-n { position: absolute; top: 12px; right: 14px; font-family: var(--font-display); font-size: 2rem; color: var(--line); font-weight: 700; }
.pair-play { margin: 8px 0; }
.pair-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-choices .choice { text-align: center; display: flex; flex-direction: column; font-size: 1.2rem; }
.pair-res { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .vowels { grid-template-columns: repeat(2, 1fr); }
  .rules { grid-template-columns: 1fr; }
}

/* ---------- 文法 ---------- */
.lesson-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.lesson-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; transition: border-color .15s; }
.lesson-card:hover { border-color: var(--primary); }
.lesson-n { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.lesson-card.done .lesson-n { background: var(--ok-soft); color: var(--ok); }
.lesson-t { font-weight: 700; }
.lesson-s { font-size: .82rem; color: var(--muted); }
.lesson-card > div { flex: 1; min-width: 0; }
.lesson-st { font-weight: 700; color: var(--ok); }
.lesson-sec { margin-bottom: 14px; }
.lesson-sec h2 { font-size: 1.1rem; border-left: 4px solid var(--primary); padding-left: 10px; }
.examples { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.examples li { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.ex-main { display: flex; gap: 12px; align-items: flex-start; }
.quiz-box .q { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.quiz-box .q:last-of-type { border-bottom: 0; }
.q-t { font-weight: 700; }
.q-c { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 8px; }
.q-e { font-size: .9rem; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- フレーズ・単語 ---------- */
.phrase-list { display: grid; gap: 10px; }
.phrase { display: flex; gap: 14px; align-items: flex-start; }
.phrase-body { flex: 1; min-width: 0; }
.phrase-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.phrase.learned, .word.learned { border-color: var(--accent); }
.star { border: 0; background: none; font-size: 1.4rem; color: var(--accent); line-height: 1; padding: 4px; }
.hide-ja .ja, .hide-ja .note { filter: blur(6px); transition: filter .2s; }
.hide-ja .phrase:hover .ja, .hide-ja .phrase:hover .note, .hide-ja .phrase:focus-within .ja { filter: none; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.word { padding: 12px 14px; }
.word-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.word .es { font-size: 1.05rem; }
.word.g-mb { border-left: 4px solid var(--male); }
.word.g-fb { border-left: 4px solid var(--female); }
.g { font-weight: 700; padding: 0 6px; border-radius: 6px; }
.g-m { color: var(--male); background: color-mix(in srgb, var(--male) 14%, transparent); }
.g-f { color: var(--female); background: color-mix(in srgb, var(--female) 14%, transparent); }

/* ---------- 覚えること ---------- */
.tips { display: grid; gap: 8px; }
.tip { padding: 0; }
.tip summary { padding: 14px 18px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.tip summary::-webkit-details-marker { display: none; }
.tip summary::after { content: '＋'; color: var(--primary); font-weight: 700; }
.tip[open] summary::after { content: '－'; }
.tip p { padding: 0 18px 16px; margin: 0; color: var(--text); }

/* ---------- 練習 ---------- */
.practice-menu { grid-template-columns: repeat(3, 1fr); }
.pm { transition: border-color .15s, transform .15s; }
.pm:hover { border-color: var(--primary); transform: translateY(-2px); }
.pm-i { font-size: 2rem; }
.pm p { color: var(--muted); font-size: .9rem; }
@media (max-width: 860px) { .practice-menu { grid-template-columns: 1fr; } }
.fl-progress { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.flashcard { min-height: 220px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; cursor: pointer; padding: 28px 20px; }
.flashcard hr { width: 60%; }
.fc-es { font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 600; }
.fc-ja { font-size: 1.25rem; font-weight: 600; }
.fc-hint { margin-top: 18px; }
.fl-actions { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; }
.fl-actions .btn { min-width: 110px; }
.qz-card { text-align: center; padding: 26px 18px; margin-bottom: 8px; }
.qz-prompt { font-size: 1.4rem; font-weight: 600; }
.qz-prompt.es { font-family: var(--font-display); }
.big-score { font-family: var(--font-display); font-size: 2.6rem; font-weight: 700; margin: 6px 0 14px; }
.conj-card { max-width: 560px; }
.conj-q { margin-bottom: 14px; }
.conj-verb { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin: 6px 0 0; }
.conj-verb small { font-family: var(--font); font-size: .9rem; }
.conj-person { font-size: 1.15rem; font-weight: 600; color: var(--primary); }
.conj-form { display: flex; gap: 8px; }
.conj-form input { flex: 1; min-width: 0; font-size: 1.15rem; }
.accent-keys { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.accent-keys button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.05rem; font-weight: 600; }
.conj-table tr.hl td { background: var(--accent-soft); font-weight: 700; }
