/* ── Dialogue pages — shared styles ── */

main { padding-top: 72px; }

.lesson-header { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #fff; padding: 3rem 1.5rem 2rem; text-align: center; margin-bottom: 2rem; }
.lesson-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: clamp(1.6rem,4vw,2.4rem); font-weight: 700; margin-bottom: 0.3rem; }
.lesson-header .title-jp { font-family: 'Space Grotesk', sans-serif; font-size: clamp(1.1rem,2.5vw,1.5rem); font-weight: 600; opacity: 0.9; margin: 0.1rem 0 0.6rem; }
.lesson-header p { opacity: 0.75; font-size: 0.95rem; }
.lang-badge { display: inline-block; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); border-radius: 20px; padding: 0.2rem 0.9rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 0.75rem; }

.lesson-container { max-width: 860px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.ex-card { background: #fff; border-radius: 16px; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); border-left: 4px solid #1e40af; }
.ex-card h2 { font-family: 'Space Grotesk', sans-serif; color: #1e3a8a; font-size: 1.15rem; margin-bottom: 0.4rem; }
.ex-subtitle { color: #6b7280; font-size: 0.9rem; margin-bottom: 1.5rem; }

.progress-wrap { background: #f3f4f6; border-radius: 12px; padding: 1rem 1.5rem; margin-bottom: 2rem; }
.progress-label { font-size: 0.88rem; color: #6b7280; margin-bottom: 0.5rem; }
.progress-bar-outer { height: 8px; background: #e5e7eb; border-radius: 4px; }
.progress-bar-inner { height: 8px; background: linear-gradient(90deg, #1e40af, #3b82f6); border-radius: 4px; transition: width 0.4s; }

.audio-btn { background: #1e40af; color: #fff; border: none; border-radius: 20px; padding: 0.3rem 0.85rem; font-size: 0.82rem; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; transition: background 0.2s; flex-shrink: 0; }
.audio-btn:hover { background: #1e3a8a; }
.audio-btn.sm { padding: 0.15rem 0.6rem; font-size: 0.76rem; }

/* Expression Reference */
.ref-card { border-left: 4px solid #0891b2; }
.ref-card h2 { color: #0e7490; }
.ref-section-label { font-family: 'Space Grotesk', sans-serif; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; padding: 0.3rem 0.8rem; border-radius: 20px; margin: 1.2rem 0 0.6rem; display: inline-block; }
.ref-section-label:first-of-type { margin-top: 0; }
.ref-formal   { background: #fef3c7; color: #92400e; }
.ref-standard { background: #dbeafe; color: #1e40af; }
.ref-casual   { background: #dcfce7; color: #15803d; }
.ref-slang    { background: #ede9fe; color: #5b21b6; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.5rem; }
.ref-table th { background: #f8fafc; color: #374151; font-weight: 700; padding: 0.5rem 0.7rem; text-align: left; border-bottom: 2px solid #e2e8f0; }
.ref-table td { padding: 0.6rem 0.7rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.ref-table tr:last-child td { border-bottom: none; }
.ref-jp { font-size: 1rem; color: #1e3a8a; font-weight: 600; }
.ref-rom { font-size: 0.78rem; color: #6b7280; font-style: italic; margin-top: 0.1rem; display: block; }
.ref-resp-jp { font-size: 0.9rem; color: #374151; }
.ref-resp-rom { font-size: 0.75rem; color: #9ca3af; font-style: italic; display: block; margin-top: 0.1rem; }
.ref-ctx { font-size: 0.82rem; color: #6b7280; }

/* Dialogue script */
.dialogue-section { margin-bottom: 1.5rem; }
.dialogue-label { font-family: 'Space Grotesk', sans-serif; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; padding: 0.25rem 0.8rem; border-radius: 20px; margin-bottom: 0.75rem; display: inline-block; }
.dlabel-formal   { background: #fef3c7; color: #92400e; }
.dlabel-standard { background: #dbeafe; color: #1e40af; }
.dlabel-casual   { background: #dcfce7; color: #15803d; }
.script-card { background: #f8fafc; border-radius: 12px; padding: 1.25rem; }
.script-line { display: grid; grid-template-columns: 3.5rem 1fr; gap: 0.8rem; margin-bottom: 1.2rem; align-items: start; }
.script-line:last-child { margin-bottom: 0; }
.speaker-a { background: #1e40af; color: #fff; border-radius: 8px; padding: 0.2rem 0.45rem; font-size: 0.78rem; font-weight: 700; text-align: center; margin-top: 0.2rem; }
.speaker-b { background: #7c3aed; color: #fff; border-radius: 8px; padding: 0.2rem 0.45rem; font-size: 0.78rem; font-weight: 700; text-align: center; margin-top: 0.2rem; }
.script-ja { font-size: 1.05rem; color: #111827; margin-bottom: 0.12rem; }
.script-romaji { font-size: 0.8rem; color: #6b7280; font-style: italic; margin-bottom: 0.12rem; }
.script-en { font-size: 0.83rem; color: #374151; }

/* Formula blocks */
.formula-block { background: #f0f9ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 1rem 1.2rem; margin: 0.75rem 0 0; overflow-x: auto; }
.formula-row { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.25rem; align-items: baseline; }
.f-jp   { font-size: 1rem; color: #1e3a8a; font-weight: 600; min-width: 4.5rem; }
.f-slot { font-size: 1rem; color: #7c3aed; font-weight: 700; font-style: italic; background: #ede9fe; border-radius: 4px; padding: 0 0.3rem; min-width: 4.5rem; }
.f-rom  { font-size: 0.8rem; color: #6b7280; font-style: italic; min-width: 4.5rem; }
.f-lit  { font-size: 0.75rem; color: #9ca3af; min-width: 4.5rem; }
.formula-natural { font-size: 0.87rem; color: #374151; margin-top: 0.4rem; font-weight: 500; }

/* Cheatsheet */
.cheatsheet-card { border-left: 4px solid #0891b2; }
.cheatsheet-card .accordion-btn { color: #0e7490; }
.cs-pattern { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid #e0f2fe; }
.cs-pattern:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cs-pattern-title { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 700; color: #0e7490; margin-bottom: 1rem; }
.cs-variant { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.75rem; }
.cs-variant:last-child { margin-bottom: 0; }
.reg-badge { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; border-radius: 4px; padding: 0.2rem 0.5rem; white-space: nowrap; margin-top: 0.2rem; flex-shrink: 0; }
.reg-formal   { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.reg-standard { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.reg-casual   { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.reg-slang    { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.cs-formula { margin: 0; flex: 1; }
.cs-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.cs-box { background: #f8fafc; border-radius: 10px; padding: 0.9rem 1rem; border: 1px solid #e2e8f0; }
.cs-box-title { font-family: 'Space Grotesk', sans-serif; font-size: 0.82rem; font-weight: 700; color: #374151; margin-bottom: 0.5rem; }
.cs-jp { font-size: 1rem; color: #1e3a8a; font-weight: 600; }
.cs-rom { font-size: 0.78rem; color: #6b7280; font-style: italic; margin-top: 0.1rem; }
.cs-en { font-size: 0.82rem; color: #374151; margin-top: 0.25rem; }
.cs-note { font-size: 0.78rem; color: #6b7280; margin-top: 0.4rem; font-style: italic; }

/* Flashcards */
.fc-scene { perspective: 900px; width: 100%; max-width: 400px; margin: 0 auto 1rem; }
.fc-card { width: 100%; aspect-ratio: 5/3; position: relative; transform-style: preserve-3d; transition: transform 0.55s; cursor: pointer; }
.fc-card.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; padding: 1.5rem; }
.fc-front { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #fff; }
.fc-back  { background: #eff6ff; border: 2px solid #1e40af; transform: rotateY(180deg); }
.fc-ja  { font-size: 1.2rem; text-align: center; line-height: 1.5; margin-bottom: 0.4rem; }
.fc-tap { font-size: 0.75rem; opacity: 0.55; margin-top: 0.7rem; }
.fc-romaji { font-size: 0.95rem; color: #1e40af; font-weight: 600; margin-bottom: 0.4rem; text-align: center; }
.fc-en { font-size: 0.9rem; color: #374151; text-align: center; }
.fc-speak-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }
.fc-speak-wrap .audio-btn { font-size: 1rem; padding: 0.5rem 1.5rem; }
.fc-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; padding: 0 0.5rem; }
.fc-btn { background: #1e3a8a; color: #fff; border: none; border-radius: 8px; padding: 0.5rem 1.2rem; cursor: pointer; font-size: 0.9rem; transition: background 0.2s; min-width: 5rem; text-align: center; }
.fc-btn:hover { background: #1e40af; }
.fc-btn:disabled { opacity: 0.4; cursor: default; }
.fc-counter { color: #6b7280; font-size: 0.9rem; white-space: nowrap; min-width: 3.5rem; text-align: center; }

/* Multiple choice */
.mc-item { margin-bottom: 1.8rem; padding-bottom: 1.8rem; border-bottom: 1px solid #f3f4f6; }
.mc-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.mc-prompt-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.mc-num { color: #9ca3af; font-size: 0.85rem; min-width: 1.4rem; flex-shrink: 0; }
.mc-prompt-text { display: flex; flex-direction: column; }
.mc-ja { font-size: 1.1rem; color: #111827; font-weight: 500; }
.mc-prompt-rom { font-size: 0.78rem; color: #6b7280; font-style: italic; margin-top: 0.12rem; }
.mc-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.mc-opts-single { grid-template-columns: 1fr; }
.mc-opt { background: #f9fafb; border: 2px solid #e5e7eb; border-radius: 10px; padding: 0.6rem 0.9rem; cursor: pointer; font-size: 0.92rem; transition: border-color 0.2s, background 0.2s; }
.mc-opts-single .mc-opt { text-align: left; }
.mc-opts:not(.mc-opts-single) .mc-opt { text-align: center; }
.mc-opt:hover:not(.mc-locked) { border-color: #1e40af; background: #eff6ff; }
.mc-opt.selected { border-color: #3b82f6; background: #eff6ff; }
.mc-opt.correct  { border-color: #16a34a; background: #dcfce7; color: #15803d; }
.mc-opt.wrong    { border-color: #dc2626; background: #fee2e2; color: #dc2626; }
.mc-opt.mc-locked { cursor: default; }
.mc-opt-rom { font-size: 0.78rem; color: #6b7280; font-style: italic; margin-top: 0.2rem; }

/* Romaji exercise */
.rom-tip { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; padding: 0.7rem 1rem; font-size: 0.83rem; color: #92400e; margin-bottom: 1.5rem; }
.rom-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 0; border-bottom: 1px solid #f3f4f6; flex-wrap: wrap; }
.rom-item:last-child { border-bottom: none; }
.rom-num { color: #9ca3af; font-size: 0.85rem; min-width: 1.4rem; text-align: right; flex-shrink: 0; }
.rom-input { flex: 1; min-width: 200px; border: none; border-bottom: 2px solid #1e40af; background: transparent; font-size: 1rem; padding: 0.2rem 0.5rem; outline: none; color: #1e3a8a; font-family: 'Inter', sans-serif; }
.rom-input::placeholder { color: #9ca3af; font-size: 0.88rem; }
.rom-input.correct   { border-color: #16a34a; color: #15803d; }
.rom-input.incorrect { border-color: #dc2626; color: #dc2626; }

/* Shared actions & feedback */
.ex-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.btn-check { background: #1e40af; color: #fff; border: none; border-radius: 8px; padding: 0.55rem 1.3rem; font-size: 0.92rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; transition: background 0.2s; }
.btn-check:hover { background: #1e3a8a; }
.btn-reset { background: #f3f4f6; color: #374151; }
.btn-reset:hover { background: #e5e7eb; }
.ex-feedback { margin-top: 1rem; font-size: 0.92rem; padding: 0.75rem 1rem; border-radius: 8px; display: none; }
.ex-feedback.ok  { background: #dcfce7; color: #15803d; display: block; }
.ex-feedback.bad { background: #fee2e2; color: #dc2626; display: block; }

/* Shadowing */
.sh-group-label { font-family: 'Space Grotesk', sans-serif; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: #6b7280; margin: 1.2rem 0 0.4rem; border-top: 1px solid #f3f4f6; padding-top: 1rem; }
.sh-group-label:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.sh-item { display: grid; grid-template-columns: 1.4rem 1fr auto; align-items: start; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid #f3f4f6; }
.sh-item:last-child { border-bottom: none; }
.sh-num { color: #9ca3af; font-size: 0.85rem; text-align: right; padding-top: 0.3rem; }
.sh-ja { font-size: 1.02rem; color: #111827; margin-top: 0.3rem; }
.sh-romaji { font-size: 0.79rem; color: #6b7280; font-style: italic; margin-top: 0.1rem; }
.sh-btn { background: #f3f4f6; border: 2px solid #d1d5db; border-radius: 8px; padding: 0.4rem 0.85rem; font-size: 0.82rem; color: #6b7280; cursor: pointer; white-space: nowrap; transition: all 0.2s; margin-top: 0.1rem; }
.sh-btn.done { background: #dcfce7; border-color: #16a34a; color: #15803d; font-weight: 600; }
.sh-summary { text-align: center; font-size: 0.9rem; color: #6b7280; margin-top: 1rem; }

/* Accordions */
.accordion-btn { width: 100%; background: none; border: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 0; font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 600; }
.accordion-icon { font-size: 1.1rem; transition: transform 0.25s; }
.accordion-icon.open { transform: rotate(180deg); }
.accordion-body { display: none; margin-top: 1.2rem; }
.accordion-body.open { display: block; }

/* Grammar & Vocab */
.grammar-card { border-left: 4px solid #f59e0b; }
.grammar-card .accordion-btn { color: #b45309; }
.vocab-card { border-left: 4px solid #7c3aed; }
.vocab-card .accordion-btn { color: #5b21b6; }
.grammar-item { margin-bottom: 1.3rem; padding-bottom: 1.3rem; border-bottom: 1px solid #fde68a; }
.grammar-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.grammar-item h3 { font-family: 'Space Grotesk', sans-serif; color: #1e3a8a; font-size: 1rem; margin-bottom: 0.5rem; }
.grammar-box { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; padding: 0.9rem 1rem; font-size: 0.9rem; line-height: 1.75; }
.grammar-ex { background: #eff6ff; border-left: 3px solid #1e40af; padding: 0.6rem 1rem; border-radius: 0 8px 8px 0; margin-top: 0.6rem; }
.grammar-ex .g-ja { font-size: 1rem; color: #111827; }
.grammar-ex .g-romaji { font-size: 0.8rem; color: #6b7280; font-style: italic; }
.grammar-ex .g-en { font-size: 0.83rem; color: #374151; }
.vocab-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.vocab-table th { background: #1e40af; color: #fff; padding: 0.5rem 0.8rem; text-align: left; }
.vocab-table td { border-bottom: 1px solid #e5e7eb; padding: 0.45rem 0.8rem; }
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table .v-ja { font-size: 1.05rem; color: #1e3a8a; font-weight: 600; }

/* Country table (dialogue_06) */
.country-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.5rem; }
.country-table th { background: #f8fafc; color: #374151; font-weight: 700; padding: 0.5rem 0.7rem; text-align: left; border-bottom: 2px solid #e2e8f0; }
.country-table td { padding: 0.6rem 0.7rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.country-table tr:last-child td { border-bottom: none; }
.ct-jp { font-weight: 600; color: #1e3a8a; }
.ct-rom { color: #6b7280; font-style: italic; }
.ct-note { color: #6b7280; font-size: 0.82rem; }
.cr-region { background: #eff6ff; font-weight: 600; color: #1e40af; }

/* Verb table (dialogue_07) */
.verb-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.5rem; }
.verb-table th { background: #f8fafc; color: #374151; font-weight: 700; padding: 0.5rem 0.7rem; text-align: left; border-bottom: 2px solid #e2e8f0; }
.verb-table td { padding: 0.6rem 0.7rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.verb-table tr:last-child td { border-bottom: none; }

/* Misc */
.back-link { display: inline-flex; align-items: center; gap: 0.5rem; color: #1e40af; font-size: 0.9rem; font-weight: 600; text-decoration: none; margin-bottom: 1.5rem; }
.back-link:hover { color: #1e3a8a; }
.complete-banner { display: none; background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; border-radius: 12px; padding: 1.2rem 1.5rem; text-align: center; font-weight: 600; font-size: 1rem; margin-bottom: 1.5rem; }

/* ── Mobile ≤ 768px ── */
@media (max-width: 768px) {

  /* Fix 1 + 2 — Table horizontal scroll for ALL tables */
  .ref-table, .country-table, .verb-table, .vocab-table {
    font-size: 0.82rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Fix 4 — Japanese text line breaking in dialogue bubbles */
  .script-line {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
  .speaker-a, .speaker-b {
    width: fit-content;
    margin-bottom: 0.15rem;
  }
  .script-ja, .script-romaji, .script-en {
    word-break: keep-all;
    overflow-wrap: break-word;
    line-break: strict;
    white-space: normal;
  }

  /* Fix 5 — Slim progress bar on mobile */
  .progress-wrap { padding: 0.75rem 1rem; }
  .progress-bar-outer { height: 6px; }
  .progress-bar-inner { height: 6px; }
  .progress-label { font-size: 0.8rem; }

  /* Fix 6 — Consistent horizontal padding */
  .lesson-container { padding: 0 1rem 2rem; }
  .ex-card { padding: 1.25rem; }
  .script-card { padding: 1rem; }
  .grammar-box { padding: 0.75rem 0.9rem; }
  .formula-block { padding: 0.75rem 1rem; }
  .cs-box { padding: 0.75rem 0.85rem; }

  /* Fix 7 — Touch targets ≥ 44–48px */
  .audio-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .audio-btn.sm { min-width: 40px; min-height: 40px; padding: 0.25rem 0.55rem; }
  .mc-opt { min-height: 48px; padding: 0.75rem 1rem; margin-bottom: 0.35rem; font-size: 0.95rem; display: flex; align-items: center; }
  .btn-check { min-height: 48px; padding: 0.65rem 1.5rem; font-size: 0.95rem; }
  .fc-btn { min-height: 44px; }
  .accordion-btn { min-height: 48px; padding: 0.5rem 0; }
}

/* ── Small mobile ≤ 600px ── */
@media (max-width: 600px) {
  .mc-opts { grid-template-columns: 1fr; }
  .sh-item { grid-template-columns: 1.4rem 1fr; }
  .sh-btn { grid-column: 2; justify-self: start; }
  .formula-row { gap: 0.6rem; }
  .f-jp, .f-slot, .f-rom, .f-lit { min-width: 3rem; font-size: 0.88rem; }
  .cs-compare { grid-template-columns: 1fr; }
  .rom-input { min-width: 140px; }
  .fc-nav { gap: 0.6rem; padding: 0 0.25rem; }
  .fc-btn { padding: 0.45rem 0.8rem; font-size: 0.82rem; min-width: 4rem; }
  .fc-counter { font-size: 0.82rem; }
  .fc-scene { max-width: 100%; }
  .lesson-header { padding: 2rem 1rem 1.5rem; }
  .lesson-header h1 { font-size: 1.3rem; }
}
