/* ===== css/style.css ===== */
/* =========================================================================
   にほんご · เรียนภาษาญี่ปุ่น — สไตล์หลัก
   โทนสี: กระดาษวาชิ + แดงชาด (朱色) + คราม (藍色)
   ========================================================================= */

/* ตัวแปรสี — ทุกสีในแอปต้องมาจากตัวแปรเหล่านี้ (รองรับโหมดสว่าง/มืด)
   --accent        สีหลัก ใช้เป็นข้อความ/เส้นขอบ/ไอคอน และพื้นปุ่มหลัก (คู่กับ --accent-ink เป็นสีตัวอักษรบนพื้น accent)
   --accent-soft   พื้นอ่อนสำหรับสถานะที่เลือก (ข้อความ accent บนพื้นนี้ ≥ 4.5:1)
   --ok/--bad/--warn  สีสถานะ (ข้อความ) · --*-soft พื้นอ่อน · --ok-ink/--bad-ink ตัวอักษรบนพื้น --ok/--bad เต็ม
   --faint         ใช้ตกแต่งเท่านั้น (ไอคอน เส้น ลายน้ำ) — ข้อความที่ต้องอ่านใช้ --muted
   --focus         วงแหวนโฟกัสคีย์บอร์ด · --sel-bg พื้นตัวเลือกที่ถูกเลือก · --seg-on พื้นปุ่มที่เลือกใน .seg
   --chart-1/--chart-1-muted/--chart-2/--chart-grid สีกราฟ · --heat-0…--heat-4 ตารางกิจกรรม (แต่ละขั้นต่างกัน ≥ 1.4:1)
   --stroke-ghost  เส้นจางของลำดับขีด (≥ 2:1 บน --surface-2)
   ใส่คลาส .theme-light / .theme-dark ที่กล่องใดก็ได้เพื่อแสดงตัวอย่างธีมนั้นเฉพาะกล่อง */
:root, .theme-light {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f2ede4;
  --surface-3: #e8e1d5;
  --text: #1f1c19;
  --ink: #1f1c19;
  --muted: #645d54;
  --faint: #8a8277;
  --border: #e2dace;
  --border-strong: #cbc1b1;
  --accent: #c8342b;
  --accent-hover: #ab2a22;
  --accent-soft: #fdf1ef;
  --accent-ink: #ffffff;
  --indigo: #2d4a7a;
  --indigo-soft: #e7edf7;
  --ok: #2b7a4b;
  --ok-soft: #e2f2e8;
  --ok-ink: #ffffff;
  --bad: #b8352a;
  --bad-soft: #fbe5e2;
  --bad-ink: #ffffff;
  --warn: #8a5a0e;
  --warn-soft: #fbf0db;
  --focus: #2d4a7a;
  --sel-bg: var(--accent-soft);
  --seg-on: #ffffff;
  --chart-1: #c8342b;
  --chart-1-muted: #e7a39b;
  --chart-2: #2d4a7a;
  --chart-grid: #e2dace;
  --heat-0: #e8e1d5;
  --heat-1: #e8968a;
  --heat-2: #d4604f;
  --heat-3: #b23a2e;
  --heat-4: #7f221b;
  --stroke-ghost: color-mix(in srgb, #1f1c19 38%, transparent);
  --guide: rgba(31, 28, 25, 0.12);
  --scrim: rgba(15, 12, 10, 0.45);
  --shadow: 0 1px 2px rgba(50, 35, 20, 0.05), 0 6px 20px rgba(50, 35, 20, 0.06);
  --shadow-lg: 0 10px 40px rgba(30, 20, 10, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Noto Sans Thai", "Leelawadee UI", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-jp: "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Hiragino Sans", "Noto Sans Thai", "Leelawadee UI", sans-serif;
  --font-display: "Klee One", "UD Digi Kyokasho N-R", "UD デジタル 教科書体 N-R", "Noto Sans JP", "Yu Gothic", serif;
  color-scheme: light;
}

/* โหมดมืด: พื้นผิวไล่ระดับให้การ์ดแยกจากพื้นหลัง, สีหลักสว่างขึ้นสำหรับข้อความ และใช้ตัวอักษรเข้มบนพื้นสีหลัก (≥ 4.5:1) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101113;
    --surface: #1c1e22;
    --surface-2: #25282d;
    --surface-3: #33373d;
    --text: #ecebe6;
    --ink: #f3f1ec;
    --muted: #aaa49b;
    --faint: #8c867d;
    --border: #3a3e45;
    --border-strong: #50555d;
    --accent: #ec7a63;
    --accent-hover: #f4917c;
    --accent-soft: #33292a;
    --accent-ink: #1f0f0b;
    --indigo: #9db9ee;
    --indigo-soft: #1f2a3d;
    --ok: #6fcf97;
    --ok-soft: #173322;
    --ok-ink: #0b1a11;
    --bad: #ff7b72;
    --bad-soft: #3a1f1d;
    --bad-ink: #1f0b09;
    --warn: #e8b25c;
    --warn-soft: #362a12;
    --focus: #9db9ee;
    --sel-bg: color-mix(in srgb, var(--accent) 10%, var(--surface));
    --seg-on: #3d4249;
    --chart-1: #ec7a63;
    --chart-1-muted: #b5605a;
    --chart-2: #9db9ee;
    --chart-grid: #3a3e45;
    --heat-0: #2a2d32;
    --heat-1: #6b3530;
    --heat-2: #a2493f;
    --heat-3: #dc6352;
    --heat-4: #ff9a7c;
    --stroke-ghost: color-mix(in srgb, #f3f1ec 30%, transparent);
    --guide: rgba(241, 239, 233, 0.14);
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"], .theme-dark {
  --bg: #101113;
  --surface: #1c1e22;
  --surface-2: #25282d;
  --surface-3: #33373d;
  --text: #ecebe6;
  --ink: #f3f1ec;
  --muted: #aaa49b;
  --faint: #8c867d;
  --border: #3a3e45;
  --border-strong: #50555d;
  --accent: #ec7a63;
  --accent-hover: #f4917c;
  --accent-soft: #33292a;
  --accent-ink: #1f0f0b;
  --indigo: #9db9ee;
  --indigo-soft: #1f2a3d;
  --ok: #6fcf97;
  --ok-soft: #173322;
  --ok-ink: #0b1a11;
  --bad: #ff7b72;
  --bad-soft: #3a1f1d;
  --bad-ink: #1f0b09;
  --warn: #e8b25c;
  --warn-soft: #362a12;
  --focus: #9db9ee;
  --sel-bg: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --seg-on: #3d4249;
  --chart-1: #ec7a63;
  --chart-1-muted: #b5605a;
  --chart-2: #9db9ee;
  --chart-grid: #3a3e45;
  --heat-0: #2a2d32;
  --heat-1: #6b3530;
  --heat-2: #a2493f;
  --heat-3: #dc6352;
  --heat-4: #ff9a7c;
  --stroke-ghost: color-mix(in srgb, #f3f1ec 30%, transparent);
  --guide: rgba(241, 239, 233, 0.14);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
.theme-light, .theme-dark { background: var(--bg); color: var(--text); }
/* เปลี่ยนธีมแบบนุ่มนวล (ใส่คลาสชั่วคราวตอนผู้ใช้กดเปลี่ยน — ไม่มีผลตอนโหลดหน้า) */
@media (prefers-reduced-motion: no-preference) {
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, fill 0.25s ease, stroke 0.25s ease !important;
}
}

/* ---------- พื้นฐาน ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* ขนาดตัวอักษร (ตั้งค่า "ขนาดตัวอักษร"): --th-scale คูณทั้งหน้า (rem/em ตามทั้งหมด) · ค่าเริ่มต้น 1 */
html { -webkit-text-size-adjust: 100%; font-size: calc(100% * var(--th-scale, 1)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: calc(16px * var(--th-scale, 1));
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.2rem; margin-top: 1.8em; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.8em; }
a { color: var(--indigo); }
button, input, select { font: inherit; color: inherit; }
kbd {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75em;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}
/* วงแหวนโฟกัส: เส้นทึบสีคราม (≥ 3:1 ทั้งสองธีม) + ขอบพื้นหลังด้านใน ให้เห็นได้บนทุกพื้นผิว */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

[lang="ja"], .jp { font-family: var(--font-jp); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.eyebrow { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ok-text { color: var(--ok); font-weight: 600; }
.romaji { font-family: ui-sans-serif, "Segoe UI", system-ui, sans-serif; color: var(--muted); font-size: 0.9em; letter-spacing: 0.01em; }
.hide-romaji .romaji, .hide-romaji .kana-romaji { display: none; }
.hide-thai .kana-th { display: none; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 28px 80px; outline: none; }

/* ---------- โครงหน้า: เมนูด้านข้าง + เนื้อหา ---------- */
:root { --sidebar-w: 256px; --tabbar-h: 0px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column; gap: 12px; padding: 16px 12px 14px;
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; scrollbar-width: thin;
}
.main-col { margin-left: var(--sidebar-w); min-height: 100vh; }
.sidebar-head { display: flex; align-items: center; gap: 4px; }
.sidebar-head .brand { flex: 1; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-size: 24px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-weight: 700; font-size: 1.05rem; }
.brand-text small { font-weight: 500; font-size: 0.72rem; color: var(--muted); }
.sidebar-head .nav-close { display: none; }

/* ปุ่มสลับธีม (สว่าง / มืด / ตามระบบ) — ใช้ทั้งแถบบนและเมนูด้านข้าง */
.theme-btn { width: 40px; height: 40px; border-radius: 12px; color: var(--text); border: 1px solid var(--border); background: var(--surface-2); }
.theme-btn:hover { color: var(--text); background: var(--surface-3); }
.theme-btn svg { width: 20px; height: 20px; }

/* ช่องค้นหาในเมนู */
.side-search { position: relative; margin: 0; }
.side-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.side-search input[type="search"] { width: 100%; padding: 8px 10px 8px 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 0.92rem; }
.side-search input::placeholder { color: var(--muted); }

.level-switch { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.level-switch button, .seg[data-level-switch] button {
  border: none; background: transparent; border-radius: 9px; padding: 8px 0; min-height: 36px; font-weight: 700; font-size: 0.86rem;
  color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums;
}
.seg[data-level-switch] button { padding: 7px 12px; }
.level-switch button.on, .seg[data-level-switch] button.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.level-switch-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; padding: 0 6px; margin-bottom: -6px; }

/* เมนูหลัก: กลุ่มพับได้ (จำสถานะไว้ในการตั้งค่า navClosed) */
.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 6px; }
.nav-group-head { display: flex; align-items: center; gap: 4px; }
.nav-label {
  flex: 1; display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; padding: 6px 10px; min-height: 36px;
  border: none; background: transparent; border-radius: 8px; cursor: pointer; text-align: left;
}
.nav-label:hover { color: var(--text); background: var(--surface-2); }
.nav-label .chev { transition: transform 0.18s ease; color: var(--muted); display: inline-flex; }
.nav-label[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-label .nav-count { font-weight: 600; font-size: 0.74rem; color: var(--muted); margin-left: auto; }
.nav-label[aria-expanded="true"] .nav-count { display: none; }
.nav-hub { font-size: 0.78rem; font-weight: 600; color: var(--indigo); text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.nav-hub:hover { background: var(--indigo-soft); }
.nav-items { display: flex; flex-direction: column; gap: 1px; }
.nav a.nav-link {
  position: relative; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  padding: 6px 10px; border-radius: 10px; font-size: 0.94rem; font-weight: 500; min-height: 40px;
}
.nav a.nav-link:hover { background: var(--surface-2); }
.nav a.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.nav a.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav-glyph {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; background: var(--surface-2); color: var(--text);
}
.nav-glyph svg { width: 17px; height: 17px; }
.nav a.active .nav-glyph { background: var(--accent); color: var(--accent-ink); }
.nav-text { flex: 1; min-width: 0; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; line-height: 20px; text-align: center; font-weight: 700;
}
.badge[hidden] { display: none; }
.sidebar-foot { display: flex; gap: 6px; padding: 0 4px; flex-wrap: wrap; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 0.88rem;
  font-variant-numeric: tabular-nums; color: var(--text);
}

/* แถบบนและแถบล่างสำหรับจอเล็ก */
.topbar { display: none; }
.tabbar { display: none; }
.scrim { display: none; }
.icon-btn.menu-btn { width: 44px; height: 44px; color: var(--text); border-radius: 12px; }

@media (max-width: 1023px) {
  :root { --tabbar-h: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s; width: min(320px, 88vw); z-index: 40; padding-top: 10px; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform 0.22s ease, visibility 0s; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); }
  body.nav-open { overflow: hidden; }
  .sidebar-head .nav-close { display: inline-grid; width: 44px; height: 44px; color: var(--text); border-radius: 12px; }
  .sidebar-head .theme-btn { display: none; }
  .side-search { display: none; }
  .nav a.nav-link { min-height: 44px; }
  .main-col { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 20; padding: 6px 10px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0 4px; }
  .topbar .brand-text small { display: none; }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: 20px; border-radius: 9px; }
  .topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 4px; }
  .topbar-tools .icon-btn { width: 44px; height: 44px; border-radius: 12px; color: var(--text); }
  .level-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-height: 44px; min-width: 64px; padding: 0 10px; border-radius: 12px;
    border: none; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 0.95rem; cursor: pointer;
    font-variant-numeric: tabular-nums;
  }
  .level-btn svg { width: 16px; height: 16px; }
  .container { padding: 20px 16px calc(40px + var(--tabbar-h)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 22;
    height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 95%, transparent); border-top: 1px solid var(--border);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
    border: none; background: transparent; color: var(--muted); text-decoration: none; font-size: 0.74rem; font-weight: 600; cursor: pointer; min-height: 44px;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .on { color: var(--accent); }
  .tabbar .on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .badge { position: absolute; top: 4px; left: 54%; margin: 0; min-width: 18px; line-height: 18px; font-size: 0.68rem; padding: 0 5px; }
  .toast-root { bottom: calc(14px + var(--tabbar-h)) !important; }
}
@media (max-width: 420px) {
  .topbar .brand-text { display: none; }
}

/* แผ่นเลือกระดับ (ปุ่มระดับบนแถบบนของมือถือ) */
.level-sheet { display: grid; gap: 8px; margin-top: 12px; }
.level-sheet button {
  display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 8px 14px; border-radius: 14px; text-align: left;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.level-sheet button:hover { background: var(--surface-2); }
.level-sheet button.on { border-color: var(--accent); background: var(--sel-bg); }
.level-sheet b { width: 48px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.05rem; flex-shrink: 0; }
.level-sheet button.on b { background: var(--accent); color: var(--accent-ink); }
.level-sheet span { display: grid; line-height: 1.3; }
.level-sheet small { color: var(--muted); }

/* ---------- ส่วนประกอบทั่วไป ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface-2); border-color: var(--border); border-style: dashed; color: var(--muted); cursor: not-allowed; opacity: 1; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: 6px 12px; font-size: 0.88rem; border-radius: 10px; }
.btn-lg { padding: 13px 22px; font-size: 1.02rem; }
.btn kbd { background: color-mix(in srgb, var(--accent-ink) 14%, transparent); border-color: color-mix(in srgb, var(--accent-ink) 35%, transparent); color: inherit; }
.btn:not(.btn-primary) kbd { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.center { justify-content: center; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted); cursor: pointer; vertical-align: middle; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.icon-btn.speak { color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }

.notice { background: var(--warn-soft); color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px; border-left: 4px solid var(--warn); }
.notice.bad { background: var(--bad-soft); border-left-color: var(--bad); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.seg button {
  border: none; background: transparent; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-weight: 600; color: var(--muted); font-size: 0.94rem;
}
/* ปุ่มที่เลือกใน .seg: พื้นยกขึ้น + ขอบ + ตัวหนา (ไม่พึ่งสีอย่างเดียว) */
.seg button.on { background: var(--seg-on); color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow); }
.seg.small button { padding: 6px 12px; font-size: 0.9rem; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.93rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 40px; height: 23px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border-strong); transition: background 0.2s; flex-shrink: 0;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }

select, input[type="text"] {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); max-width: 100%;
}
input[type="range"] { accent-color: var(--accent); width: 220px; max-width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 0.2em; }
.page-head p { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 1.8em; margin-bottom: 0.6em; }
.section-head h2 { margin: 0; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 20px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.toolbar .spacer { flex: 1; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 0.92rem; margin-bottom: 10px; }
.back-link:hover { color: var(--accent); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* จุดบอกระดับความจำ */
.lvl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lvl-new { background: var(--faint); }
.lvl-learning { background: var(--warn); }
.lvl-mastered { background: var(--ok); }

/* ---------- หน้าแรก ---------- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px; position: relative; overflow: hidden; }
.hero::before {
  content: "日本語"; position: absolute; right: 150px; bottom: -40px; font-family: var(--font-display);
  font-size: 150px; line-height: 1; color: var(--accent); opacity: 0.05; pointer-events: none; white-space: nowrap;
}
.hero h1 { margin-bottom: 0.4em; }
.hero-text { position: relative; max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.goal-ring { position: relative; display: grid; justify-items: center; flex-shrink: 0; }
.goal-ring svg { display: block; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--chart-1); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.goal-text { position: absolute; top: 0; height: 120px; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.goal-text strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.goal-text span { font-size: 0.78rem; color: var(--muted); }
.goal-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; text-decoration: none; color: var(--text); }
.stat strong { font-size: 1.8rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span:not(.stat-icon) { font-weight: 600; }
.stat small { color: var(--muted); font-size: 0.8rem; }
.stat-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--indigo-soft); color: var(--indigo); margin-bottom: 4px; }
.stat-link:hover { border-color: var(--accent); }

.home-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; }
.path { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.path-step a {
  display: flex; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: border-color 0.15s;
}
.path-step a:hover { border-color: var(--border-strong); }
.path-step.current a { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.path-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); font-weight: 700; color: var(--muted);
}
.path-step.current .path-num { background: var(--accent); color: var(--accent-ink); }
.path-step.done .path-num { background: var(--ok-soft); color: var(--ok); }
.path-body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.path-title { font-weight: 700; }
.path-desc { font-size: 0.88rem; color: var(--muted); }
.path-count { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.wotd { text-align: center; }
.wotd-word { font-size: 2.2rem; font-weight: 700; display: flex; justify-content: center; align-items: center; gap: 6px; }
.wotd-word .jp { font-family: var(--font-display); font-weight: 600; }
.wotd-reading { color: var(--muted); font-size: 1.05rem; }
.wotd-meaning { font-size: 1.2rem; font-weight: 600; margin: 8px 0; }
.wotd-ex { border-top: 1px dashed var(--border-strong); margin-top: 12px; padding-top: 12px; font-size: 0.95rem; }
.tips p { font-size: 0.93rem; color: var(--muted); }
.tips svg { vertical-align: -3px; color: var(--accent); }
.tips p:last-child { margin: 0; }

@media (max-width: 860px) {
  .hero { flex-direction: column; align-items: stretch; padding: 22px; }
  .hero::before { right: -20px; font-size: 110px; }
  .goal-ring { align-self: center; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* ---------- ตารางตัวอักษร ---------- */
.kana-layout { display: grid; grid-template-columns: minmax(0, 680px) minmax(0, 1fr); gap: 36px; align-items: start; }
.kana-side .note-grid { grid-template-columns: minmax(0, 1fr); }
.kana-side > p { margin-top: 12px; }
@media (max-width: 1000px) {
  .kana-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kana-side .note-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
.kana-section h2 { display: flex; align-items: baseline; gap: 10px; }
.kana-grid { display: grid; gap: 8px; max-width: 680px; }
.kana-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kana-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 420px; }
.kana-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 92px; padding: 8px 4px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; transition: transform 0.08s, border-color 0.15s, box-shadow 0.15s;
}
.kana-cell:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kana-cell:active { transform: scale(0.97); }
.kana-cell.empty { background: transparent; border: 1px dashed var(--border); cursor: default; box-shadow: none; }
.kana-cell.rare .kana-ch { opacity: 0.6; }
.kana-cell .lvl-dot { position: absolute; top: 8px; right: 8px; }
.kana-ch { font-family: var(--font-display); font-size: 2.2rem; line-height: 1.15; font-weight: 600; }
.kana-romaji { font-size: 0.85rem; color: var(--muted); font-family: ui-sans-serif, "Segoe UI", system-ui, sans-serif; }
.kana-th { font-size: 0.78rem; color: var(--muted); opacity: 0.85; }
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.note-card { padding: 16px 18px; }
.note-card h3 { margin-bottom: 0.4em; color: var(--accent); }
.note-card p { margin: 0; font-size: 0.93rem; }
.note-card .jp, .explain .jp, .points .jp { font-weight: 600; }

@media (max-width: 520px) {
  .kana-grid { gap: 5px; }
  .kana-cell { min-height: 76px; border-radius: 11px; }
  .kana-ch { font-size: 1.8rem; }
  .kana-th { font-size: 0.7rem; }
}

/* ---------- ป๊อปอัป ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--scrim);
  display: grid; place-items: center; padding: 16px; animation: fade 0.15s ease;
}
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 26px; animation: pop 0.18s ease;
}
.modal-sm { width: min(440px, 100%); }
.modal-md { width: min(560px, 100%); }
.modal-close { position: absolute; top: 10px; right: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.kana-detail, .kanji-detail { display: flex; gap: 22px; align-items: center; margin-bottom: 18px; }
.big-char {
  font-family: var(--font-display); font-size: 92px; line-height: 1; font-weight: 600;
  width: 140px; height: 140px; flex-shrink: 0; display: grid; place-items: center; border-radius: 18px;
  background:
    linear-gradient(var(--guide), var(--guide)) center / 100% 1px no-repeat,
    linear-gradient(var(--guide), var(--guide)) center / 1px 100% no-repeat,
    var(--surface-2);
}
.kana-detail-info { display: grid; gap: 4px; }
.romaji-lg { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.pair-char { font-size: 1.3rem; font-weight: 600; }
.ex-word { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 1.15rem; margin-top: 6px; }
.ex-word .muted { font-size: 0.92rem; margin-left: 2px; }
.kana-detail-info .notice { margin: 6px 0 0; }

.kanji-big { font-size: 100px; }
.kanji-info { flex: 1; }
.kanji-meaning { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.kanji-info dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 0.95rem; }
.kanji-info dt { color: var(--muted); }
.kanji-info dt small { font-size: 0.78em; }
.kanji-info dd { margin: 0; font-weight: 600; }
.kanji-words { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.kanji-words li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.kw-jp { font-size: 1.25rem; font-weight: 700; }
.kw-kana { color: var(--muted); }
.kw-th { margin-left: auto; }

@media (max-width: 480px) {
  .modal { padding: 22px 18px; }
  .kana-detail, .kanji-detail { flex-direction: column; text-align: center; gap: 14px; }
  .kana-detail-info { justify-items: center; }
  .ex-word { justify-content: center; }
  .kanji-info dl { text-align: left; }
}

/* ---------- คำศัพท์ ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cat-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.1s; }
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cat-icon { font-size: 1.8rem; line-height: 1; }
.cat-title { font-weight: 700; font-size: 1.05rem; }
.cat-desc { color: var(--muted); font-size: 0.88rem; flex: 1; }
.cat-count { color: var(--muted); font-size: 0.8rem; }

.word-list { display: grid; gap: 10px; }
.word-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 4px 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
.word-jp { display: flex; align-items: center; gap: 6px; font-size: 1.5rem; font-weight: 700; }
.word-jp .jp { font-family: var(--font-display); font-weight: 600; }
.word-reading { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; color: var(--muted); font-size: 0.95rem; }
.word-th { font-size: 1.05rem; font-weight: 600; }
.word-note { font-size: 0.85rem; color: var(--muted); }
.word-meaning { border-radius: 10px; transition: filter 0.2s; }
.word-meaning.concealed { filter: blur(7px); cursor: pointer; user-select: none; background: var(--surface-2); }
.word-ex { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 6px; }
.word-ex summary { cursor: pointer; color: var(--indigo); font-size: 0.9rem; font-weight: 600; }
.ex-jp { display: flex; align-items: center; gap: 4px; font-size: 1.15rem; font-weight: 600; margin-top: 6px; }
.ex-kana { color: var(--muted); font-size: 0.92rem; }
.ex-th { font-size: 0.97rem; }

@media (max-width: 640px) {
  .word-row { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; }
}

/* ---------- ไวยากรณ์ ---------- */
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.lesson-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
.lesson-item:hover { border-color: var(--accent); }
.lesson-num {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--indigo-soft); color: var(--indigo); font-weight: 700; font-variant-numeric: tabular-nums;
}
.lesson-item.done .lesson-num { background: var(--ok-soft); color: var(--ok); }
.lesson-body { display: grid; flex: 1; min-width: 0; }
.lesson-title { font-weight: 700; font-size: 1.05rem; }
.lesson-sub { font-size: 0.88rem; color: var(--muted); }
.lesson-go { color: var(--muted); }
@media (max-width: 400px) { .lesson-list { grid-template-columns: minmax(0, 1fr); } }

.lesson-head h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem); margin-bottom: 0.15em; }
.pattern {
  margin: 18px 0 22px; padding: 16px 20px; border-radius: var(--radius); font-size: 1.3rem; font-weight: 700;
  background: var(--indigo-soft); color: var(--indigo); border-left: 5px solid var(--indigo); letter-spacing: 0.02em;
}
.explain { max-width: 860px; font-size: 1.02rem; }
.view-grammar .examples, .view-grammar .lesson-quiz, .view-grammar #lesson-result { max-width: 860px; }
.explain b, .points b { color: var(--accent); }
.points { margin-top: 18px; max-width: 860px; }
.points h2 { margin-top: 0; font-size: 1.05rem; }
.points ul { margin: 0; padding-left: 1.2em; }
.points li { margin-bottom: 4px; }
.examples { display: grid; gap: 10px; }
.example { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.example .ex-jp { margin-top: 0; font-size: 1.25rem; }
.lesson-quiz { display: grid; gap: 12px; }
.lq { padding: 16px 18px; }
.lq.right { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.lq.wrong { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.lq-q { font-size: 1.15rem; font-weight: 600; margin-bottom: 10px; }
.lq-num { color: var(--muted); font-weight: 700; margin-right: 4px; }
.lq-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.lq-choices .choice { min-width: 64px; padding: 8px 16px; font-size: 1.05rem; }
.lq-explain { margin: 10px 0 0; font-size: 0.93rem; color: var(--muted); }
.result-card { margin-top: 16px; display: grid; gap: 8px; justify-items: start; border-color: var(--accent); }
.result-card strong { font-size: 1.3rem; }

/* ---------- คันจิ ---------- */
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.kanji-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px 10px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.kanji-tile:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kanji-tile .lvl-dot { position: absolute; top: 8px; right: 8px; }
.kanji-ch { font-family: var(--font-display); font-size: 2.3rem; line-height: 1.15; font-weight: 600; }
.kanji-th { font-size: 0.78rem; color: var(--muted); text-align: center; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- ปุ่มตัวเลือก (ใช้ร่วมกัน) ---------- */
.choice {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; text-align: left;
  font-weight: 600; transition: border-color 0.12s, background 0.12s;
}
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); opacity: 1; }
.choice.incorrect { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); opacity: 1; }
.choice kbd { flex-shrink: 0; }

/* ---------- ทบทวน / แฟลชการ์ด ---------- */
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.review-grid .card { display: grid; gap: 10px; align-content: start; }
.review-grid h2 { margin: 0; }
.due-num { font-size: 3.2rem; font-weight: 700; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.due-num span { font-size: 1rem; color: var(--muted); margin-left: 8px; font-weight: 500; }
.review-new select { width: 100%; }
.how { margin-top: 16px; }
.how h2 { margin-top: 0; font-size: 1.05rem; }
.how ol { margin: 0; padding-left: 1.3em; color: var(--muted); }
.how li { margin-bottom: 4px; }
@media (max-width: 720px) { .review-grid { grid-template-columns: minmax(0, 1fr); } }

.session-top { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.session-progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.session-progress .progress { flex: 1; }
.session-progress > span { font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.session-title { text-align: center; margin-bottom: 14px; }

.flashcard {
  max-width: 560px; margin: 0 auto; min-height: 320px; padding: 26px 24px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; cursor: pointer;
}
.flashcard.flipped { cursor: default; }
.fc-type { font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 3px 12px; border-radius: 999px; background: var(--surface-2); }
.fc-front { font-family: var(--font-display); font-size: clamp(3.5rem, 2.5rem + 6vw, 6rem); line-height: 1.2; font-weight: 600; word-break: keep-all; }
.type-vocab .fc-front { font-size: clamp(2.4rem, 1.8rem + 4vw, 4rem); }
.fc-back { display: grid; gap: 6px; justify-items: center; width: 100%; border-top: 1px dashed var(--border-strong); padding-top: 14px; animation: fade 0.2s ease; }
.back-main { font-size: 1.6rem; font-weight: 700; }
.back-reading { font-size: 1.15rem; color: var(--muted); }
.back-sub { color: var(--muted); font-size: 0.93rem; }
.back-ex { margin-top: 6px; font-size: 1rem; }
.back-words { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 4px; }
.back-words li { display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; }
.fc-actions { max-width: 560px; margin: 18px auto 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.fc-actions > .btn { grid-column: 1 / -1; }
.grade {
  display: grid; justify-items: center; gap: 1px; padding: 10px 6px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--surface);
}
.grade b { font-size: 1rem; }
.grade small { font-size: 0.74rem; color: var(--muted); }
.grade kbd { margin-top: 4px; }
.grade.g0 { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); }
.grade.g0 b { color: var(--bad); }
.grade.g1 b { color: var(--warn); }
.grade.g2 b { color: var(--ok); }
.grade.g3 b { color: var(--indigo); }
.grade:hover { background: var(--surface-2); }

.finish { max-width: 620px; margin: 20px auto; text-align: center; padding: 32px 24px; }
.finish-emoji { font-size: 3rem; line-height: 1; margin-bottom: 8px; }
.tally { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.tally span { padding: 4px 12px; border-radius: 999px; font-size: 0.88rem; font-weight: 600; background: var(--surface-2); }
.tally .t0 { color: var(--bad); }
.tally .t1 { color: var(--warn); }
.tally .t2 { color: var(--ok); }
.tally .t3 { color: var(--indigo); }
.mistakes { text-align: left; margin: 18px 0; }
.mistakes h2 { font-size: 1rem; margin-top: 0; }
.mistakes ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.mistakes li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--bad-soft); }
.mistakes li .jp { font-size: 1.2rem; font-weight: 700; }
.mistakes li > span:last-child { margin-left: auto; }

/* ---------- แบบทดสอบ ---------- */
.quiz-setup { max-width: 640px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; border: none; padding: 0; margin: 0; }
.field > label, .field > legend { font-weight: 700; padding: 0; }
.mode-list { display: grid; gap: 6px; }
.mode-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); cursor: pointer;
}
.mode-opt:has(input:checked) { border-color: var(--accent); background: var(--sel-bg); box-shadow: inset 0 0 0 0.5px var(--accent); }
.mode-opt input { accent-color: var(--accent); }
.mode-opt.disabled { opacity: 0.5; cursor: not-allowed; }

.quiz-card { max-width: 640px; margin: 10px auto 0; text-align: center; padding: 26px 22px; }
.q-label { color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.q-prompt { font-family: var(--font-display); font-size: clamp(3rem, 2.2rem + 5vw, 5rem); line-height: 1.25; font-weight: 600; margin-bottom: 18px; }
.q-prompt.q-text { font-family: var(--font); font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.2rem); font-weight: 700; margin: 10px 0 22px; }
.listen-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px; margin: 10px auto 22px;
  width: 120px; height: 120px; justify-content: center; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.85rem;
}
.listen-btn:hover { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.jp-choices .choice { justify-content: flex-start; font-size: 1.35rem; }
.jp-choices .choice .jp { font-family: var(--font-display); font-weight: 600; }
.jp-choices .choice small { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.text-choices .choice { font-size: 1.02rem; }
.type-form { display: flex; gap: 8px; max-width: 420px; margin: 0 auto; }
.type-form input { flex: 1; font-size: 1.2rem; text-align: center; padding: 12px; min-width: 0; }
.feedback { margin-top: 16px; display: grid; gap: 8px; justify-items: center; }
.feedback:empty { display: none; }
.feedback.ok, .feedback.bad { padding: 14px; border-radius: 14px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.fb-head { font-weight: 700; font-size: 1.05rem; }
.feedback.ok .fb-head { color: var(--ok); }
.feedback.bad .fb-head { color: var(--bad); }
.fb-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 1.05rem; }
.fb-info .jp { font-size: 1.2rem; font-weight: 700; }
@media (max-width: 520px) {
  .choices { grid-template-columns: minmax(0, 1fr); }
  .quiz-card { padding: 20px 14px; }
}

/* ---------- ฝึกเขียน ---------- */
.write-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.write-pad { display: grid; gap: 12px; }
.pad {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 20px; overflow: hidden; touch-action: none;
  border: 2px solid var(--border-strong); background: var(--surface);
  background-image:
    repeating-linear-gradient(90deg, var(--guide) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(0deg, var(--guide) 0 6px, transparent 6px 12px);
  background-size: 100% 1px, 1px 100%;
  background-position: center, center;
  background-repeat: no-repeat;
}
.pad-guide {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-display); font-size: min(300px, 72vw); line-height: 1; color: var(--guide); font-weight: 400;
  transition: opacity 0.2s;
}
.pad-guide.hidden { opacity: 0; }
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.write-info { display: grid; gap: 12px; justify-items: start; }
.write-char { font-family: var(--font-display); font-size: 5rem; line-height: 1; font-weight: 600; }
.write-meta { font-size: 1.2rem; font-weight: 600; }
.char-strip { display: flex; gap: 6px; overflow-x: auto; padding: 14px 2px 6px; margin-top: 18px; scrollbar-width: thin; }
.char-strip button {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-family: var(--font-display); font-size: 1.4rem; font-weight: 600;
}
.char-strip button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (max-width: 760px) {
  .write-layout { grid-template-columns: minmax(0, 1fr); }
  .write-info { grid-template-columns: auto 1fr; align-items: center; }
  .write-info .write-char { grid-row: span 2; font-size: 3.6rem; }
  .write-info > :nth-child(n + 4) { grid-column: 1 / -1; }
}

/* ---------- ตั้งค่า ---------- */
.settings-block { max-width: 720px; margin-bottom: 16px; }
.settings-block h2 { margin-top: 0; font-size: 1.1rem; }
.settings-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; }
.settings-row > label:first-child:not(.switch) { min-width: 140px; font-weight: 600; }
.settings-block .notice { margin: 6px 0 10px; }

/* ---------- แจ้งเตือน ---------- */
.toast-root { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.93rem;
  box-shadow: var(--shadow-lg); animation: pop 0.2s ease; transition: opacity 0.3s, transform 0.3s; text-align: center;
}
.toast.ok { background: var(--ok); color: var(--ok-ink); }
.toast.bad { background: var(--bad); color: var(--bad-ink); }
.toast.out { opacity: 0; transform: translateY(6px); }

@media (max-width: 520px) {
  .container { padding: 18px 16px 72px; }
  .card { padding: 16px; }
  .toolbar { padding: 10px 12px; }
  .stat strong { font-size: 1.5rem; }
}

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

/* =========================================================================
   ส่วนประกอบรุ่น 2 (หลายระดับ N5–N1)
   ========================================================================= */

/* ---------- ฟุริงานะ / ข้อความญี่ปุ่น ---------- */
ruby { ruby-position: over; }
/* ฟุริงานะอ่านออก (อันดับ 11): อย่างน้อย 11px (คูณ --jp-scale ตามขนาดตัวอักษรที่ตั้ง) สี --muted (≥ 4.5:1 ทั้งสองธีม) */
rt { font-size: max(0.55em, calc(11px * var(--jp-scale, 1))); color: var(--muted); font-weight: 500; letter-spacing: 0; user-select: none; }
.nofuri { text-decoration: underline dotted color-mix(in srgb, var(--muted) 40%, transparent); text-underline-offset: 4px; cursor: help; }
u.target { text-decoration: underline 2px var(--accent); text-underline-offset: 5px; }
.blank { display: inline-block; min-width: 3em; text-align: center; color: var(--muted); }
.jp-text { line-height: 2.1; font-size: 1.1rem; }

/* ---------- สถานะโหลด / ว่าง ---------- */
.loading { display: flex; align-items: center; gap: 10px; padding: 20px; color: var(--muted); font-size: 0.95rem; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
/* เปิดหน้าที่ยังไม่ได้โหลดสคริปต์ (js/loader.js ใส่ html.route-loading เมื่อรอเกิน 150ms) → แถบวิ่งบางๆ ที่ขอบบน */
html.route-loading body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 80; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat; background-size: 40% 100%;
  animation: route-load 1s linear infinite;
}
html.route-loading #app { cursor: progress; }
@keyframes route-load { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.empty-state { text-align: center; color: var(--muted); padding: 28px 20px; }
.empty-state p { margin: 0 0 8px; }

/* ---------- ป้ายระดับ ---------- */
.level-badge {
  display: inline-grid; place-items: center; padding: 1px 10px; border-radius: 8px; font-size: 0.85em;
  background: var(--accent); color: var(--accent-ink); font-variant-numeric: tabular-nums; vertical-align: 0.06em;
}
.level-tabs button { min-width: 48px; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.indigo { background: var(--indigo-soft); color: var(--indigo); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- หน้าแรก: แผนวันนี้ / ความคืบหน้า / กิจกรรม ---------- */
.plan { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plan-item { display: flex; align-items: center; gap: 14px; padding: 12px 16px; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
.plan-item:hover { border-color: var(--accent); }
.plan-glyph { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--indigo-soft); color: var(--indigo); font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.plan-body { display: grid; flex: 1; min-width: 0; }
.plan-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-desc { font-size: 0.86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-go { color: var(--muted); }

.level-progress { display: grid; gap: 8px; }
.lp-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius); width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.lp-row:hover { border-color: var(--border-strong); }
.lp-row.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lp-level { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-weight: 800; background: var(--surface-2); }
.lp-row.current .lp-level { background: var(--accent); color: var(--accent-ink); }
.lp-bars { display: grid; gap: 4px; flex: 1; min-width: 0; }
.lp-bar { display: grid; grid-template-columns: 64px 1fr 82px; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.lp-num { text-align: right; font-variant-numeric: tabular-nums; }
.lp-bar .progress { height: 6px; }

.heatmap { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; gap: 3px; justify-content: start; }
.hm-cell { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--heat-0); }
.hm-cell.future { background: transparent; }
.hm-cell.l1 { background: var(--heat-1); }
.hm-cell.l2 { background: var(--heat-2); }
.hm-cell.l3 { background: var(--heat-3); }
.hm-cell.l4 { background: var(--heat-4); }
.hm-legend { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.hm-scale { display: inline-flex; align-items: center; gap: 3px; }

/* ---------- หน่วยการเรียน ---------- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.unit-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.1s; }
.unit-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.unit-card.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.unit-head { display: flex; align-items: center; gap: 8px; }
.unit-icon { font-size: 1.5rem; line-height: 1; }
.unit-title { font-weight: 700; }
.unit-sample { font-size: 0.95rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-count { font-size: 0.8rem; color: var(--muted); }
.topic-block h2 { display: flex; align-items: center; gap: 8px; }

.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input, .search-box input[type="search"] { width: 100%; padding-left: 36px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
input[type="search"] {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
}

/* ---------- ลำดับเส้น ---------- */
.stroke-box { position: relative; width: 160px; height: 160px; border-radius: 18px; flex-shrink: 0; background:
    linear-gradient(var(--guide), var(--guide)) center / 100% 1px no-repeat,
    linear-gradient(var(--guide), var(--guide)) center / 1px 100% no-repeat, var(--surface-2); }
.stroke-box svg { width: 100%; height: 100%; display: block; }
.stroke-box .sk-ghost { fill: none; stroke: var(--stroke-ghost); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.stroke-box .sk-ink { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.stroke-box .sk-num { font-size: 8px; fill: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; font-weight: 700; }
.stroke-controls { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }

/* ---------- คำศัพท์รุ่น 2 ---------- */
.word-link { border: none; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.word-link:hover .jp { color: var(--accent); }
.word-ex-inline { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 4px; }
.word-ex-inline .ex-jp { margin-top: 0; font-size: 1.05rem; font-weight: 500; line-height: 2; }
.word-ex-inline .ex-th { font-size: 0.92rem; color: var(--muted); }
.word-detail h3 { margin-top: 18px; }
.wd-head { text-align: center; margin-bottom: 8px; }
.wd-word { font-size: 2.6rem; font-weight: 600; display: flex; justify-content: center; align-items: center; gap: 6px; }
.wd-word .jp { font-family: var(--font-display); }
.wd-reading { color: var(--muted); font-size: 1.1rem; }
.wd-pills { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.wd-meaning { font-size: 1.25rem; font-weight: 700; text-align: center; margin: 10px 0; }
.word-detail .example { margin: 10px 0; }
.conj-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; margin-bottom: 10px; }
.conj-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 5px 8px 5px 0; white-space: nowrap; width: 40%; }
.conj-table td { padding: 5px 0; border-top: 1px solid var(--border); }
.conj-table th { border-top: 1px solid var(--border); }
.conj-table td .jp { font-size: 1.1rem; font-weight: 600; }
.wd-kanji { display: grid; gap: 6px; }
.wd-k { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); text-decoration: none; color: var(--text); }
a.wd-k:hover { outline: 2px solid var(--accent-soft); }
.wd-k-ch { font-family: var(--font-display); font-size: 2rem; font-weight: 600; line-height: 1; }

/* ---------- คันจิรุ่น 2 ---------- */
.kanji-unit { margin-bottom: 8px; }
.kanji-unit .progress { margin-bottom: 12px; }
.kanji-unit .section-head h2 { margin: 0; }
.stroke-wrap { flex-shrink: 0; }
.kanji-detail .stroke-box { width: 170px; height: 170px; }
.kanji-words.compact li { padding: 6px 10px; font-size: 0.95rem; }
.kanji-words.compact .kw-jp { font-size: 1.1rem; }

/* ---------- ไวยากรณ์รุ่น 2 ---------- */
.pattern-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; opacity: 0.75; margin-bottom: 4px; }
.pattern > div[lang="ja"] { font-size: 1.15rem; line-height: 1.9; }
.notation { margin-top: 8px; font-size: 0.85rem; font-weight: 500; }
.notation summary { cursor: pointer; }
.notation dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 8px 0 0; color: var(--text); }
.notation dt { font-weight: 700; }
.notation dd { margin: 0; }
.example .ex-jp { line-height: 2.1; }
.lq-q, .lq-choices .choice { line-height: 2; }

/* ---------- แบบทดสอบรุ่น 2 ---------- */
.q-prompt.q-long { font-size: clamp(1.8rem, 1.3rem + 2.4vw, 2.8rem); }
.type-vocab .fc-front, .type-grammar .fc-front { font-size: clamp(2.2rem, 1.6rem + 3.6vw, 3.8rem); }
.type-grammar .fc-front { font-family: var(--font-jp); }

/* ---------- ฝึกเขียนรุ่น 2 ---------- */
.pad-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pad-svg .w-ghost { fill: none; stroke: var(--guide); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.pad-svg .w-done { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.pad-svg .w-hint { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.pad-wrong { animation: shake 0.3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.pad-demo { position: absolute; inset: 0; background: var(--surface); z-index: 2; cursor: pointer; }
.pad-demo svg { width: 100%; height: 100%; }
.pad-demo .sk-ghost { fill: none; stroke: var(--stroke-ghost); stroke-width: 4; stroke-linecap: round; }
.pad-demo .sk-ink { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.pad-demo .sk-num { font-size: 7px; fill: var(--accent); font-weight: 700; }
.write-status { width: 100%; display: grid; gap: 6px; }
.write-done { font-weight: 700; color: var(--ok); }

/* ---------- แตะคำเพื่อดูความหมาย (JP.app.enableLookup) ---------- */
.lk-on .lk-w { cursor: pointer; border-radius: 4px; transition: background-color 0.15s; }
.lk-on .lk-w:hover { background: var(--accent-soft); }
.lk-w:focus:not(:focus-visible) { outline: none; }
.lk-w:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.lk-w.lk-cur { background: var(--indigo-soft); box-shadow: 0 0 0 1px var(--indigo); }
.lk-pop {
  position: absolute; z-index: 45; width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 460px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 10px 14px 12px; overscroll-behavior: contain;
}
.lk-pop:focus, .lk-pop:focus-visible { outline: none; }
.lk-pop.lk-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 62vh;
  border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.lk-head { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.lk-word { flex: 1; min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 1.35rem; font-weight: 700; color: var(--ink); }
.lk-word .lk-read { font-size: 0.95rem; font-weight: 400; color: var(--muted); }
.lk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lk-entry { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 3px; }
.lk-e-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.lk-e-jp { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.lk-e-kana { color: var(--muted); }
.lk-via { font-size: 0.75rem; color: var(--indigo); }
.lk-e-th { overflow-wrap: anywhere; }
.lk-e-act { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.lk-e-act .icon-btn { width: 32px; height: 32px; }
.lk-sub { margin: 12px 0 6px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.lk-kanji { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.lk-k { font-family: var(--font-display); font-size: 1.9rem; line-height: 1; color: var(--ink); min-width: 1.2em; text-align: center; }
.lk-k-info { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.lk-foot { margin-top: 10px; text-align: right; }
.lk-foot a { display: inline-flex; align-items: center; gap: 4px; }
.lk-pop .loading { padding: 10px 0; }

/* =========================================================================
   รุ่น 3: ธีม การนำทาง หัวหน้าเพจ คำอธิบายศัพท์ หน้ารวม หน้าแรก และหน้าแนะนำครั้งแรก
   ========================================================================= */

/* ---------- แสดงเฉพาะจอเล็ก/จอใหญ่ ---------- */
.only-mobile { display: none; }
@media (max-width: 1023px) {
  .only-mobile { display: inline; }
  .only-desktop { display: none; }
}
/* จอสัมผัส: ซ่อนคำใบ้คีย์ลัด (ใส่คลาส .kbd-hint ที่ข้อความคำใบ้คีย์บอร์ดได้) */
@media (hover: none) and (pointer: coarse) {
  .btn kbd, .choice kbd, .grade kbd, .kbd-hint { display: none !important; }
}

/* ---------- หัวหน้าเพจ (JP.app.pageHead) ---------- */
.page-head-main { min-width: 0; flex: 1 1 320px; }
.page-head h1 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.page-desc { color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.level-chip-sm {
  display: inline-grid; place-items: center; padding: 1px 9px; border-radius: 8px; font-size: 0.72em; font-weight: 700;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); font-variant-numeric: tabular-nums;
}

/* ---------- คำอธิบายศัพท์ (JP.app.helpTip) ---------- */
.help-wrap { display: inline-flex; vertical-align: middle; }
.help-tip {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--indigo); font: 700 0.8rem/1 var(--font);
  vertical-align: middle; position: relative;
}
.help-tip::after { content: ""; position: absolute; inset: -10px; } /* พื้นที่แตะ ≥ 44px */
.help-tip svg { width: 15px; height: 15px; }
.help-tip:hover, .help-tip[aria-expanded="true"] { background: var(--indigo-soft); border-color: var(--indigo); }
.help-tip.help-q { width: 28px; height: 28px; font-size: 0.95rem; }
.help-pop {
  position: fixed; z-index: 70; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font: 400 0.9rem/1.6 var(--font); text-align: left;
  letter-spacing: normal; white-space: normal; text-transform: none;
}

/* ---------- เมนู: ลิงก์ภาพรวมของกลุ่มเมื่อเปิดอยู่ ---------- */
.nav-hub[aria-current="page"] { background: var(--indigo-soft); color: var(--indigo); }

/* ---------- หน้ารวม (hub) ---------- */
.hub-tip { margin-bottom: 16px; border-left-color: var(--indigo); background: var(--indigo-soft); max-width: 860px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hub-card { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.1s; }
.hub-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.hub-glyph {
  width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--indigo-soft); color: var(--indigo); font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
}
.hub-glyph svg { width: 24px; height: 24px; }
.hub-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.hub-title { font-weight: 700; font-size: 1.05rem; }
.hub-desc { font-size: 0.88rem; color: var(--muted); }
.hub-go { color: var(--muted); }

/* ---------- หน้าแรก ---------- */
.home-next { padding: 24px; display: grid; gap: 14px; position: relative; overflow: hidden; }
.home-next::before {
  content: "日本語"; position: absolute; right: -10px; top: -30px; font-family: var(--font-display);
  font-size: 140px; line-height: 1; color: var(--accent); opacity: 0.05; pointer-events: none; white-space: nowrap;
}
.home-next > * { position: relative; }
.home-next h1 { margin: 0; font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); }
.hn-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hn-top .eyebrow { margin: 0; }
.level-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 0.88rem;
}
.level-chip:hover { border-color: var(--accent); }
.next-cta {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--radius); text-decoration: none;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); transition: background 0.15s, transform 0.1s;
}
a.next-cta:hover { background: var(--accent-hover); transform: translateY(-1px); }
.next-cta.next-loading { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.next-cta.next-loading .loading { padding: 4px 0; }
.next-glyph {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent-ink) 16%, transparent); font-family: var(--font-display); font-size: 1.9rem; font-weight: 600;
}
.next-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.next-body small { font-size: 0.8rem; font-weight: 600; opacity: 0.9; }
.next-body b { font-size: 1.2rem; line-height: 1.35; }
.next-body > span { font-size: 0.9rem; opacity: 0.92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-go {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding: 10px 16px; border-radius: 12px; font-weight: 700;
  background: color-mix(in srgb, var(--accent-ink) 16%, transparent); white-space: nowrap;
}
.goal-line { display: grid; grid-template-columns: auto minmax(80px, 1fr) auto; align-items: center; gap: 10px; font-size: 0.9rem; }
.goal-label-text { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.goal-num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal-num b { color: var(--text); }
.progress.done > span { background: var(--ok); }
.hn-secondary { display: flex; flex-wrap: wrap; gap: 8px; }
.home-cols > section > h2:first-child, .home-cols > aside > h2:first-child { margin-top: 1.2em; }
.stat { padding: 14px 16px; }
.how-it-works p { margin: 0 0 8px; color: var(--text); }
.how-it-works p:last-child { margin: 0; }

@media (max-width: 640px) {
  .home-next { padding: 18px 16px; gap: 12px; }
  .next-cta { flex-wrap: wrap; padding: 14px; gap: 12px; }
  .next-glyph { width: 46px; height: 46px; font-size: 1.6rem; }
  .next-go { flex: 1 1 100%; justify-content: center; min-height: 44px; }
  .goal-line { grid-template-columns: auto 1fr; }
  .goal-line .progress { grid-column: 1 / -1; grid-row: 2; }
  .goal-num { justify-self: end; }
  .hn-secondary .btn { flex: 1 1 auto; }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px 10px; }
  .stat strong { font-size: 1.35rem; }
  .stat small { display: none; }
}

/* ---------- ตั้งค่า: ธีม ---------- */
.theme-seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.voice-help { margin-top: 8px; }
.voice-help summary { cursor: pointer; color: var(--indigo); font-weight: 600; font-size: 0.92rem; }
.voice-help ol { margin: 8px 0 0; padding-left: 1.3em; }

/* ---------- หน้าแนะนำครั้งแรก (onboarding) ---------- */
.modal.onboard { width: min(600px, 100%); padding: 26px 26px 20px; }
.onboard h2 { margin-top: 0; outline: none; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: -4px 0 16px; }
.ob-dots span { width: 28px; height: 5px; border-radius: 999px; background: var(--surface-3); }
.ob-dots span.done { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.ob-dots span.on { background: var(--accent); }
.ob-hero { text-align: center; }
.ob-hero .brand-mark { width: 64px; height: 64px; font-size: 40px; border-radius: 18px; margin: 0 auto 12px; }
.ob-points { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.ob-points li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.ob-points svg { flex-shrink: 0; color: var(--indigo); margin-top: 3px; }
.ob-opts { display: grid; gap: 8px; }
.ob-opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--surface);
}
.ob-opt:hover { background: var(--surface-2); }
.ob-opt:has(input:checked) { border-color: var(--accent); background: var(--sel-bg); }
.ob-opt input { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; margin: 0; }
.ob-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.ob-glyph { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--indigo-soft); color: var(--indigo); font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }
.ob-opt-text { display: grid; gap: 1px; min-width: 0; }
.ob-opt-text small { color: var(--muted); }
.ob-opts-sm .ob-opt { padding: 8px 12px; }
.ob-sub { font-weight: 700; margin: 14px 0 6px; }
.ob-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ob-theme {
  display: grid; gap: 6px; justify-items: center; padding: 10px 8px 12px; border-radius: 14px; cursor: pointer; text-align: center;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.ob-theme.on { border-color: var(--accent); background: var(--sel-bg); box-shadow: 0 0 0 1px var(--accent); }
.ob-theme-name { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.ob-theme small { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
/* ตัวอย่างธีมย่อส่วน — ใช้ .theme-light/.theme-dark จึงแสดงสีจริงของแต่ละธีม */
.ob-prev { position: relative; display: grid; align-content: start; gap: 5px; width: 100%; height: 74px; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); overflow: hidden; }
.ob-prev:not(.theme-light):not(.theme-dark) { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 0; }
.ob-prev-half { display: grid; align-content: start; gap: 5px; padding: 8px 6px; height: 100%; }
.ob-prev i, .ob-prev-half i { display: block; height: 8px; border-radius: 4px; background: var(--surface-3); }
.ob-prev i:first-child, .ob-prev-half i:first-child { width: 70%; background: var(--text); opacity: 0.8; }
.ob-prev b, .ob-prev-half b { display: block; height: 16px; width: 60%; border-radius: 5px; background: var(--accent); margin-top: 4px; }
.ob-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.ob-foot .spacer { flex: 1; }
@media (max-width: 520px) {
  .modal.onboard { padding: 22px 16px 16px; }
  .ob-themes { grid-template-columns: minmax(0, 1fr); }
  .ob-theme { grid-template-columns: 96px 1fr; justify-items: start; text-align: left; align-items: center; }
  .ob-theme .ob-prev { grid-row: span 2; height: 60px; }
  .ob-foot .btn-primary { flex: 1 1 100%; order: 3; }
}

/* ---------- แจ้งข้อผิดพลาด (JP.app.reportBtn + ป๊อปอัปรายงาน) ---------- */
/* ปุ่มธงเล็ก ไม่เด่น: สีรอง ขนาด 30px บนจอเมาส์ / 44px บนจอสัมผัสและจอแคบ */
.icon-btn.report-btn { width: 30px; height: 30px; color: var(--muted); }
.icon-btn.report-btn svg { width: 15px; height: 15px; }
.icon-btn.report-btn:hover { color: var(--bad); background: var(--bad-soft); }
.icon-btn.report-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
@media (hover: none) and (pointer: coarse), (max-width: 640px) {
  .icon-btn.report-btn { width: 44px; height: 44px; }
  .icon-btn.report-btn svg { width: 17px; height: 17px; }
}
/* ป้ายคลุมปุ่มที่จัดชิดขวา/ท้ายบรรทัด */
.report-slot { display: flex; justify-content: flex-end; align-items: center; margin-top: 4px; }
.report-form { display: grid; gap: 12px; }
.report-title { display: flex; align-items: center; gap: 8px; margin: 0; padding-right: 36px; font-size: 1.25rem; }
.report-title svg { color: var(--bad); }
.report-form p { margin: 0; }
.report-ctx { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); overflow-wrap: anywhere; max-height: 9.5em; overflow: auto; }
.report-reasons { gap: 6px; }
.report-reasons > .report-opt {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border-radius: 12px;
  border: 1px solid var(--border); cursor: pointer; font-weight: 500;
}
.report-opt:has(input:checked) { border-color: var(--accent); background: var(--sel-bg); }
.report-opt input { accent-color: var(--accent); margin: 0; }
.report-note {
  width: 100%; min-height: 72px; resize: vertical; font: inherit; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.report-note:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--accent); }
.rq-verdict > .report-btn { margin-left: auto; }
.fc-back .report-slot { margin-top: 8px; }

/* ---------- เสียงสูงต่ำของคำ (JP.text.pitchHtml) ----------
   แต่ละจังหวะ (โมระ) เป็น .pm: .h = เสียงสูง (เส้นด้านบน) · .dn = เสียงตกหลังจังหวะนี้ (ขีดลงที่ขอบขวา)
   .pm-tail = เส้นประท้ายคำแบบราบ ⓪ (คำช่วยที่ต่อท้ายยังสูง) · .pm-x = อักขระที่ไม่ใช่จังหวะ (～)
   .pitch-n = เลขแบบเสียงในวงกลม · สีเส้นจาก --indigo (ตั้งที่ .pitch เพื่อให้ .theme-dark/.theme-light ในกล่องย่อยได้สีถูก) */
.pitch { --pitch: var(--indigo); display: inline-flex; align-items: center; gap: 0 4px; white-space: nowrap; vertical-align: baseline; max-width: 100%; }
.pitch-k { display: inline-flex; align-items: flex-end; padding-top: 2px; }
.pm { position: relative; display: inline-block; padding: 1px 0.02em 0; border-top: 2px solid transparent; line-height: 1.12; }
.pm.h { border-top-color: var(--pitch); }
.pm.dn::after { content: ""; position: absolute; top: -2px; right: -1px; height: 0.55em; border-right: 2px solid var(--pitch); }
.pm-tail { width: 1em; align-self: stretch; }
.pm-tail.h { border-top-color: transparent; background: repeating-linear-gradient(90deg, transparent 0 3px, var(--pitch) 3px 6px) 0 0 / 100% 2px no-repeat border-box; }
.pm-hit { background: color-mix(in srgb, var(--warn) 26%, transparent); background-clip: padding-box; } /* ส่วนที่ตรงคำค้น (แบบเดียวกับ mark ในหน้าค้นหา) */
.pitch-n {
  display: inline-grid; place-items: center; min-width: 1.45em; height: 1.45em; padding: 0 0.3em; border-radius: 999px; flex-shrink: 0;
  border: 1.5px solid var(--pitch); color: var(--pitch); font: 700 0.7em/1 var(--font); font-variant-numeric: tabular-nums;
}
/* ตำแหน่งที่ใช้ */
.word-reading .pitch, .sr-word-read .pitch { font-size: 1.02em; }
.word-reading .pitch .pm, .sr-word-read .pitch .pm { color: var(--text); }
.wd-reading.wd-pitch { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.wd-reading .pitch { font-size: 1.2em; }
.wd-reading .pitch .pm { color: var(--text); }
.pitch-legend { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 10px; }
.pitch-legend .pitch { font-size: 1.05rem; }
.pitch-legend .pitch .pm { color: var(--text); }
.pitch-ex { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }

/* =========================================================================
   ตัวช่วยของเปลือกแอปที่หน้าอื่นใช้ (js/app.js): ป้าย "ทดลอง" · หน้ารวมแบบแบ่งหมวด · โหมดรอบฝึก ·
   ส่วนท้ายหน้าจบรอบ (finishFooter) · กล่องโหลดไม่สำเร็จ (loadFailHtml)
   ========================================================================= */
/* ป้าย "ทดลอง" — เนื้อหาที่ยังไม่ผ่านผู้ตรวจที่เป็นคน (betaTag(), pageHead({beta:true}), เมนู) */
.beta-tag {
  display: inline-flex; align-items: center; padding: 0 7px; border-radius: 999px; vertical-align: middle;
  font-size: 0.7rem; font-weight: 700; line-height: 1.6; letter-spacing: 0; white-space: nowrap;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}
.page-head h1 .beta-tag { font-size: 0.76rem; }
.nav-text .beta-tag { margin-left: 2px; }

/* หน้ารวมที่แบ่งหมวดย่อย (HUB_SECTIONS) */
.hub-sec { font-size: 0.98rem; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }
.hub-tip + .hub-sec { margin-top: 6px; }
@media (max-width: 400px) { .hub-grid { grid-template-columns: minmax(0, 1fr); } }

/* โหมดรอบฝึก (JP.app.sessionMode) — จอแคบ: ซ่อนแถบบน/แถบล่าง, หัวรอบ (.session-top: ปุ่มออก + ความคืบหน้า) ติดขอบบน
   แถบปุ่มประเมิน/คำตอบ (.fc-actions, .sticky-actions) ติดขอบล่างพื้นทึบ · หน้าที่ไม่มี .session-top ได้ .sess-bar สำรอง */
.sess-bar { display: none; }
@media (max-width: 1023px) {
  body.in-session { --tabbar-h: 0px; }
  body.in-session .topbar, body.in-session .tabbar { display: none; }
  body.in-session .container { padding-top: 10px; }
  body.in-session .session-top {
    position: sticky; top: 0; z-index: 15; min-height: 52px; padding: 6px 0; margin-bottom: 8px;
    background: var(--bg); box-shadow: 0 1px 0 var(--border);
  }
  body.in-session .view > .session-top { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  body.in-session .session-top .btn, body.in-session .sess-bar .btn { min-height: 44px; }
  body.in-session .sess-bar:not([hidden]) {
    display: flex; align-items: center; position: sticky; top: 0; z-index: 15; min-height: 52px; padding: 4px 10px;
    background: var(--bg); box-shadow: 0 1px 0 var(--border);
  }
}
body.in-session .fc-actions, body.in-session .sticky-actions {
  position: sticky; bottom: 0; z-index: 10; background: var(--bg);
  padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
@media (max-height: 700px) {
  body.in-session .flashcard { min-height: 200px; padding: 16px; }
  body.in-session .session-title { margin-bottom: 8px; }
}

/* ส่วนท้ายหน้าจบรอบ (JP.app.finishFooter) */
.finish-footer {
  display: grid; gap: 12px; margin-top: 18px; padding-top: 16px; text-align: left;
  border-top: 1px dashed var(--border-strong);
}
.ff-goal { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ff-ring { flex-shrink: 0; }
.ff-ring circle { fill: none; stroke-width: 5; }
.ff-ring-bg { stroke: var(--surface-3); }
.ff-ring-fg { stroke: var(--accent); stroke-linecap: round; }
.ff-goal.done .ff-ring-fg { stroke: var(--ok); }
.ff-goal-text { display: grid; gap: 2px; flex: 1; min-width: 150px; }
.ff-goal-text b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.ff-goal.done .ff-goal-text b { color: var(--ok); }
.ff-earned { padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.ff-streak { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); }
.ff-flame { display: inline-flex; color: var(--accent); }
.ff-flame svg { width: 16px; height: 16px; }
.ff-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ok-soft); }
.ff-badges[hidden] { display: none; }
.ff-badges-title { margin: 0; flex-basis: 100%; font-weight: 700; color: var(--ok); }
.ff-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.ff-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ff-actions .btn { min-height: 44px; }
.ff-next { flex: 1 1 240px; justify-content: flex-start; gap: 8px; min-height: 52px; text-align: left; white-space: normal; }
.ff-next-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ff-next-min { font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.ff-next svg { flex-shrink: 0; }
.ff-next.is-loading { background: var(--surface-2); border-color: var(--border); color: var(--muted); pointer-events: none; }
@media (max-width: 520px) {
  .ff-actions .btn { flex: 1 1 100%; }
}

/* กล่องโหลดไม่สำเร็จ (JP.app.loadFailHtml) */
.load-fail { display: grid; justify-items: center; gap: 4px; }
.load-fail-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bad-soft); color: var(--bad); }
.load-fail-icon svg { width: 22px; height: 22px; }
.load-fail-title { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.load-fail .btn-row { margin-top: 6px; }
.load-fail .btn { min-height: 44px; }

/* =========================================================================
   แพ็กเกจ B รอบ 2: หน้าแรก "วันนี้" ตามช่วงผู้เรียน · สตรีค/วันพัก · การ์ดแจ้ง · แถบระบบ (อัปเดต/สุขภาพข้อมูล)
   ปฏิทินเตือนเวลาเรียน · ตั้งค่า (ขนาดตัวอักษร/โซนอันตราย) · ป้าย "ไม่แน่ใจ" ในกล่องแตะคำ — ตัวแปรสีเท่านั้น ใช้ได้ที่ 360px
   ========================================================================= */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- แถบระบบเหนือเนื้อหา (#sys-banners) ---------- */
.sys-banners { display: grid; gap: 8px; max-width: 1120px; margin: 12px auto 0; padding: 0 28px; }
.sys-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.sys-banner.info { border-color: color-mix(in srgb, var(--indigo) 45%, var(--border)); background: var(--indigo-soft); }
.sys-banner.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); background: var(--bad-soft); }
.sys-icon { display: inline-flex; color: var(--indigo); flex-shrink: 0; }
.sys-banner.bad .sys-icon { color: var(--bad); }
.sys-text { flex: 1 1 220px; min-width: 0; font-size: 0.92rem; }
.sys-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sys-actions .btn { min-height: 40px; white-space: normal; }
@media (max-width: 1023px) {
  .sys-banners { padding: 0 16px; margin-top: 10px; }
  body.in-session .sys-banner.update { display: none; }   /* ระหว่างรอบฝึก ไม่รบกวน (แถบสุขภาพข้อมูลยังแสดง) */
}

/* ---------- เมนู: จุดเหรียญใหม่ · เมนูย่อช่วงตัวอักษร ---------- */
.nav-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 0 2px var(--surface); }
.nav a.nav-link .nav-dot { margin-left: 6px; }
.tabbar .nav-dot { position: absolute; top: 8px; left: 58%; }
.nav-more { padding: 10px 12px 4px; border-top: 1px dashed var(--border); margin-top: 6px; }
.nav-more p { margin: 0 0 6px; }
.nav-more .btn { min-height: 40px; white-space: normal; }

/* ---------- หน้าแรก ---------- */
.hn-chips { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stage-chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  background: var(--indigo-soft); color: var(--indigo); text-decoration: none; border: 1px solid transparent;
}
.stage-chip:hover { border-color: var(--indigo); }
.home-next .next-body b .jp { font-weight: 700; }

/* โครงร่างระหว่างรอข้อมูล (skeleton) */
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk-shine 1.2s ease-in-out infinite; }
.sk-glyph { width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; }
.sk-line { height: 14px; width: 80%; margin: 4px 0; }
.sk-line.short { width: 50%; }
.next-cta.next-loading { min-height: 84px; }
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* แถวสตรีค: เปลวไฟ + จำนวนวัน + วันพัก + จุด 7 วันของสัปดาห์นี้ + "ใกล้ได้เหรียญ" */
.hn-streak {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 12px;
  grid-template-areas: "flame body freeze" "dots dots week" "near near near";
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.hs-flame { grid-area: flame; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--faint); }
.hs-flame.lit { color: var(--accent); background: var(--accent-soft); }
.hs-flame svg { width: 22px; height: 22px; }
.hs-body { grid-area: body; min-width: 0; }
.hs-body p { margin: 0; }
.hs-count b { font-size: 1.02rem; }
.hs-note { color: var(--muted); }
.hs-freeze { grid-area: freeze; display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--indigo); white-space: nowrap; }
.hs-freeze > svg { width: 16px; height: 16px; }
.hs-week { grid-area: dots; display: flex; align-items: center; min-width: 0; }
.hs-dots { display: inline-flex; gap: 4px; }
.hs-dot {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 0.68rem; font-weight: 700;
  background: var(--surface); color: var(--muted); border: 1.5px solid var(--border-strong);
}
.hs-dot.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hs-dot.today { border-color: var(--accent); color: var(--accent); }
.hs-dot.freeze { background: var(--indigo-soft); border-color: var(--indigo); color: var(--indigo); }
.hs-dot.rest { border-style: dashed; }
.hs-dot.future { background: transparent; }
.hs-week-text { grid-area: week; justify-self: end; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hs-near { grid-area: near; margin: 0; }
.hs-near a { display: inline-flex; align-items: center; gap: 6px; color: var(--indigo); font-weight: 600; text-decoration: none; min-height: 32px; }
.hs-near a:hover { text-decoration: underline; }
.hs-near svg { width: 16px; height: 16px; flex-shrink: 0; }

/* การ์ดแจ้งบนหน้าแรก (กลับมาเรียน / สำรองข้อมูล / เตือนตอนเย็น / ชวนติดตั้ง) */
.home-alerts { display: grid; gap: 10px; margin-top: 14px; }
.home-alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 14px 16px; border-left: 4px solid var(--indigo); }
.home-alert.comeback { border-left-color: var(--ok); }
.home-alert.nudge { border-left-color: var(--accent); }
.ha-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--indigo-soft); color: var(--indigo); flex-shrink: 0; }
.home-alert.comeback .ha-icon { background: var(--ok-soft); color: var(--ok); }
.home-alert.nudge .ha-icon { background: var(--accent-soft); color: var(--accent); }
.ha-body { flex: 1; min-width: 0; }
.ha-body p { margin: 0 0 4px; }
.ha-title { font-weight: 700; }
.ha-body .btn-row { margin-top: 8px; }
.ha-body .btn { white-space: normal; min-height: 40px; }
.ha-close { margin: -6px -6px 0 0; width: 40px; height: 40px; }

/* โมดูลของหน้าแรก */
.home-mod > h2, .home-mod > .section-head { margin-top: 1.2em; }
.home-mod > .section-head h2 { margin: 0; }
.today-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.today-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
a.today-item:hover { border-color: var(--accent); }
.ti-glyph {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--indigo-soft); color: var(--indigo); font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
}
.ti-glyph svg { width: 20px; height: 20px; }
.ti-body { display: grid; flex: 1; min-width: 0; }
.ti-title { font-weight: 700; overflow-wrap: anywhere; }
.ti-sub { font-size: 0.86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti-min { font-size: 0.8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.today-item.done { background: var(--surface-2); box-shadow: none; }
.today-item.done .ti-glyph { background: var(--ok-soft); color: var(--ok); }
.today-item.done .ti-title { color: var(--muted); }
.today-item.sk-item { min-height: 70px; }
.today-done { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.today-note { margin: 8px 0 0; }
.today-link { margin: 10px 0 0; }
.home-today .how-it-works { margin-top: 14px; padding: 12px 16px; }
.how-it-works summary { cursor: pointer; font-weight: 700; color: var(--indigo); min-height: 32px; display: flex; align-items: center; }
.how-it-works[open] summary { margin-bottom: 8px; }
.kana-mod { display: grid; gap: 10px; }
.kana-mod p { margin: 0; }
.kana-prog { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: 36px; }
.kp-name { font-weight: 700; }
.kp-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.88rem; }
.home-hub { grid-template-columns: minmax(0, 1fr); }
.home-hub .hub-card { padding: 12px 14px; }
.hm-card { margin-top: 12px; overflow-x: auto; }
.wotd-from { margin: 0 0 4px; }
.home-exam .he-card { display: flex; align-items: flex-start; gap: 16px; margin-top: 14px; }
.he-count {
  flex-shrink: 0; width: 92px; height: 92px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: var(--accent-soft); color: var(--accent);
}
.he-count strong { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.he-count span { font-weight: 700; font-size: 0.85rem; }
.he-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.he-body p { margin: 0; }
.he-title { font-weight: 700; }
.he-rows { display: grid; gap: 4px; }
.he-rows .plan-row { display: grid; grid-template-columns: minmax(0, 7em) minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 0.82rem; }
.he-rows .plan-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.he-rows .plan-row-num { font-variant-numeric: tabular-nums; color: var(--muted); }
.he-mock { display: flex; align-items: center; gap: 6px; color: var(--indigo); }
.he-mock svg { width: 16px; height: 16px; flex-shrink: 0; }
@media (max-width: 640px) {
  /* จอแคบ: จุด 7 วันเต็มแถว · วันพักกับ "สัปดาห์นี้ x/y วัน" อยู่แถวเดียวกัน */
  .hn-streak { grid-template-areas: "flame body body" "dots dots dots" "freeze freeze week" "near near near"; }
  .home-exam .he-card { flex-direction: column; align-items: stretch; }
  .he-count { width: 76px; height: 76px; }
  .today-item { padding: 8px 12px; gap: 10px; }
  .ti-glyph { width: 36px; height: 36px; font-size: 1.1rem; }
  .ti-min { display: none; }
  /* งานที่เสร็จแล้ว: แถวเดียวแบบย่อ (ไม่กินพื้นที่งานที่ยังต้องทำ) */
  .today-item.done { padding: 6px 12px; }
  .today-item.done .ti-glyph { width: 28px; height: 28px; border-radius: 8px; }
  .today-item.done .ti-glyph svg { width: 16px; height: 16px; }
  .today-item.done .ti-sub { display: none; }
  /* จอแคบ: ปุ่มระดับมีที่แถบบนแล้ว — ซ่อนชิปซ้ำในหน้าแรกให้คำทักทาย + ช่วงอยู่บรรทัดเดียว */
  .hn-chips .level-chip { display: none; }
  .home-next { gap: 10px; }
  .home-mod > h2, .home-mod > .section-head { margin-top: 1em; }
  .home-today .how-it-works { margin-top: 10px; }
  /* ช่วงตัวอักษร: การ์ดฝึกหู/เกม/เขียนเป็นช่องเล็กเรียงแถวเดียว (ซ่อนคำอธิบาย — ชื่อพอบอกแล้ว) */
  .home-kana .home-hub { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .home-kana .home-hub .hub-card { flex-direction: column; justify-content: center; gap: 6px; padding: 10px 6px; text-align: center; min-height: 88px; }
  .home-kana .home-hub .hub-glyph { width: 38px; height: 38px; font-size: 1.2rem; }
  .home-kana .home-hub .hub-body { flex: 0 0 auto; }
  .home-kana .home-hub .hub-title { font-size: 0.92rem; }
  .home-kana .home-hub .hub-desc, .home-kana .home-hub .hub-go { display: none; }
}
@media (max-width: 380px) {
  .hs-dot { width: 26px; height: 26px; }
}

/* ---------- ฝึกบนมือถือ: คีย์บอร์ดบนจอเปิด → แถบปุ่มติดขอบล่างกลับเป็นปกติ (ไม่ทับช่องพิมพ์) ---------- */
body.kb-open .fc-actions, body.kb-open .sticky-actions { position: static; }

/* ---------- ปฏิทินเตือนเวลาเรียน (หน้าแนะนำ + ตั้งค่า) ---------- */
.cal-box { display: grid; gap: 6px; }
.cal-box .settings-row { padding: 4px 0; }
.cal-label { min-width: 140px; font-weight: 600; }
.cal-time { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; min-height: 44px; color-scheme: light dark; }
.cal-days { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-day {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.cal-day.on { background: var(--accent-soft); border: 2px solid var(--accent); color: var(--accent); }
.cal-box .btn { white-space: normal; min-height: 44px; }
.cal-box p { margin: 0; }
@media (max-width: 400px) {
  .cal-day { width: 38px; height: 38px; }
  .cal-box .btn-row .btn { flex: 1 1 100%; }
}

/* ---------- ตั้งค่า ---------- */
.scale-seg button { min-height: 40px; }
.scale-preview { margin-top: 6px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.scale-preview p { margin: 0; }
.scale-jp { font-size: 1.25rem; line-height: 2.1; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.danger-zone h2 { color: var(--bad); }
.import-cmp { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.import-cmp th, .import-cmp td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; font-variant-numeric: tabular-nums; }
.import-cmp thead th { color: var(--muted); font-weight: 600; }
.orphan-box { margin-top: 10px; }
.orphan-box p { margin: 0 0 6px; }
.reset-word { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; margin: 4px 0; }
.app-version { border-top: 1px dashed var(--border); margin-top: 10px; }
.settings-block .btn { white-space: normal; }

/* ---------- กล่องแตะคำ: ป้าย "ไม่แน่ใจ" ก่อนผลที่เดาจากการถอดรูปผัน ---------- */
.lk-unsure { margin: 6px 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; border-left: 3px solid var(--warn); }

/* ---------- ป๊อปอัปแจ้งข้อผิดพลาด: แนบข้อผิดพลาดของโปรแกรม ---------- */
.report-errs { margin: 6px 0; }
.report-errs details { margin-top: 4px; }
.report-errs summary { cursor: pointer; color: var(--indigo); }
.report-errs-pre { max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.75rem; padding: 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); margin: 6px 0 0; }

/* ---------- การ์ดฉลองเหรียญในหน้าจบรอบ ---------- */
.ff-badges-title { display: flex; align-items: center; gap: 6px; }
.ff-badges-title svg { width: 18px; height: 18px; }
.ff-badge > span:last-child { display: grid; line-height: 1.3; }
.ff-badge small { color: var(--muted); font-size: 0.75rem; }
.ff-badge-icon { font-family: var(--font-display); font-weight: 700; color: var(--warn); }
/* ===== css/views/reading.css ===== */
/* สไตล์เฉพาะหน้า reading (การอ่าน 読解) — ใช้ตัวแปรสีจาก style.css เท่านั้น (รองรับโหมดมืด) */

/* =========================================================================
   หน้ารวมบทอ่าน
   ========================================================================= */
.rd-overview { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding: 16px 18px; }
.rd-ov-stat { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; flex: 1 1 260px; min-width: 0; }
.rd-ov-go { min-height: 44px; }
.rd-overview .progress { flex: 1; min-width: 120px; }
.rd-ov-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-overview .rd-ov-go { margin-left: auto; }

.rd-group h2 { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin-top: 1.6em; margin-bottom: 0.25em; }
.rd-kind-ja { font-family: var(--font-display); font-weight: 600; color: var(--muted); font-size: 0.8em; }
.rd-kind-desc { margin: 0 0 12px; }

.rd-list {
  list-style: none; padding: 0; margin: 0; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
}
.rd-list > li { display: flex; min-width: 0; }
.rd-item {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.1s;
}
.rd-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.rd-num {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--indigo-soft); color: var(--indigo); font-weight: 700; font-variant-numeric: tabular-nums;
}
.rd-item.done .rd-num { background: var(--ok-soft); color: var(--ok); }
.rd-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.rd-title { font-weight: 700; line-height: 1.45; }
.rd-snippet {
  font-family: var(--font-jp); font-size: 0.86rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rd-meta { font-size: 0.8rem; color: var(--muted); }
.rd-go { color: var(--faint); flex-shrink: 0; }
.rd-score { font-size: 0.85rem; padding: 3px 10px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pill.rd-part { background: var(--warn-soft); color: var(--warn); }

/* =========================================================================
   หน้าบทอ่าน
   ========================================================================= */
.rd-page { max-width: 880px; }
.rd-head h1 { margin-bottom: 0.15em; }
.rd-head .eyebrow .pill .jp { font-family: var(--font-display); }
.rd-sub { margin-bottom: 14px; }
.rd-tools { margin-bottom: 16px; }
.rd-notext { margin: 0; text-align: center; }
/* เลื่อนไปยังบทอ่าน/คำถาม/ผลลัพธ์ ไม่ให้ถูกแถบด้านบน (จอเล็ก) บัง */
.rd-passage, .rd-questions, .rd-result, .rd-passage [data-say] { scroll-margin-top: 16px; scroll-margin-bottom: 16px; }
@media (max-width: 1023px) {
  .rd-passage, .rd-questions, .rd-result, .rd-passage [data-say] { scroll-margin-top: 72px; }
}

/* ---------- กระดาษบทอ่าน ---------- */
.rd-passage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px 36px; color: var(--ink);
}
.rd-para + .rd-para { margin-top: 0.7em; }
.rd-jp {
  margin: 0; font-family: var(--font-jp); font-size: 1.16rem; line-height: 2.25; letter-spacing: 0.02em;
  border-radius: 8px; transition: background 0.2s, box-shadow 0.2s;
}
.rd-para.indent .rd-jp { text-indent: 1em; }
.rd-para.sign .rd-jp { text-align: right; }
.rd-jp rt, .rd-flyer rt { letter-spacing: 0; }
/* ฟุริงานะที่ยาวกว่าคันจิ: จัดคันจิไว้กลาง ไม่ให้ตัวอักษรในคำถูกถ่างออกจากกัน */
.rd-page ruby { ruby-align: center; }

/* คำแปลภาษาไทยใต้ย่อหน้า — ซ่อนจนกว่าจะเปิด */
.rd-th {
  margin: 6px 0 4px; padding: 8px 14px; border-left: 3px solid var(--indigo); border-radius: 0 10px 10px 0;
  background: var(--indigo-soft); color: var(--text); font-family: var(--font); font-size: 0.95rem; line-height: 1.75;
  letter-spacing: 0; text-indent: 0; text-align: left; animation: fade 0.2s ease;
}
.rd-page:not(.show-th) .rd-th,
.rd-page:not(.show-th) .rd-th-block,
.rd-page:not(.show-th) .fl-top-th { display: none; }
.rd-th-block { margin-top: 16px; }
.rd-th-block h2 { margin-top: 0; font-size: 1.05rem; }
.rd-th-block p { margin: 0 0 0.6em; }

/* ย่อหน้าที่กำลังอ่านออกเสียง */
.rd-passage .speaking { background: var(--warn-soft); box-shadow: 0 0 0 6px var(--warn-soft); }
.rd-passage tr.speaking, .rd-passage tr.speaking > td { background: var(--warn-soft); }

/* ---------- เปรียบเทียบสองบทความ (統合理解) ---------- */
.rd-passage.kind-compare { background: transparent; border: none; box-shadow: none; padding: 0; }
.rd-intro { margin-bottom: 14px; padding: 0 4px; }
.rd-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.rd-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px 22px; border-top: 4px solid var(--accent);
}
.rd-panel:nth-child(2n) { border-top-color: var(--indigo); }
.rd-panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--border-strong); }
.rd-panel-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1.05rem;
}
.rd-panel:nth-child(2n) .rd-panel-mark { background: var(--indigo); color: var(--surface); }
.rd-panel-label { font-weight: 700; color: var(--muted); font-size: 0.92rem; }
.rd-panel .rd-jp { font-size: 1.1rem; }

/* ---------- ประกาศ / ใบปลิว (情報検索) ---------- */
.rd-passage.kind-info { background: var(--surface-2); padding: 34px 24px 28px; }
.rd-flyer {
  position: relative; max-width: 720px; margin: 0 auto; padding: 22px 28px 26px;
  background: var(--surface); border: 1px solid var(--border-strong); border-top: 6px solid var(--accent);
  border-radius: 4px 4px 12px 12px; box-shadow: var(--shadow); font-family: var(--font-jp);
}
/* หมุดปักกระดาษ */
.rd-flyer::before {
  content: ""; position: absolute; top: -17px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--accent-hover), var(--accent) 60%);
  box-shadow: 0 2px 3px var(--scrim);
}
.fl-top { text-align: center; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 3px double var(--border-strong); border-radius: 8px 8px 0 0; }
.fl-org { font-size: 0.95rem; font-weight: 600; color: var(--muted); line-height: 2; }
.fl-title { font-size: 1.45rem; font-weight: 700; line-height: 2; color: var(--ink); }
.fl-top-th .rd-th { margin-bottom: 8px; }
.fl-head {
  display: inline-block; margin: 14px 0 4px; padding: 0 12px; border-radius: 8px;
  background: var(--indigo-soft); color: var(--indigo); font-size: 1rem; font-weight: 700; line-height: 2.1;
}
.fl-line { margin: 0; font-size: 1.04rem; line-height: 2.1; border-radius: 6px; }
.fl-line.item { padding-left: 1em; text-indent: -1em; }
.fl-line.note { color: var(--accent); font-size: 0.97rem; }
.fl-label {
  display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 6px; line-height: 1.9;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 0.82em; font-weight: 700;
  text-indent: 0; vertical-align: 0.08em;
}
.fl-table-wrap { margin: 6px 0 4px; border: 1px solid var(--border-strong); border-radius: 10px; overflow-x: auto; scrollbar-width: thin; }
.fl-table { width: 100%; border-collapse: collapse; font-size: 1.02rem; line-height: 1.95; }
.fl-table td { padding: 5px 10px; border-top: 1px solid var(--border); vertical-align: top; transition: background 0.2s; }
.fl-table tr:first-child td { border-top: none; }
.fl-table td.nw { white-space: nowrap; }
.fl-table td + td { border-left: 1px dashed var(--border); }
.fl-table td:first-child { font-weight: 700; background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
/* ตารางที่ช่องเยอะหรือข้อความยาว (คลาส stack) → เรียงเป็นบล็อก แถวละหนึ่งการ์ด (จอแคบใช้แบบนี้กับทุกตาราง ดูด้านล่าง) */
.fl-table.stack, .fl-table.stack tbody, .fl-table.stack tr, .fl-table.stack td { display: block; }
.fl-table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 18px; padding: 6px 14px; border-top: 1px solid var(--border); }
.fl-table.stack tr:first-child { border-top: none; }
.fl-table.stack td { padding: 0; border: none; background: none; }
.fl-table.stack td:first-child { flex-basis: 100%; }
.fl-table.stack td.tag:first-child { flex-basis: auto; color: var(--accent); }
.fl-entry { margin: 8px 0; padding: 8px 14px 10px; border-radius: 10px; border: 1px solid var(--border); border-left: 4px solid var(--indigo); transition: background 0.2s; }
.fl-entry-title { font-weight: 700; font-size: 1.06rem; line-height: 2; }
.fl-entry-cells { display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 0.98rem; line-height: 2; }
.fl-cell { min-width: 0; }

/* ---------- คำศัพท์สำคัญ ---------- */
.rd-gloss { margin-top: 16px; padding: 0; }
.rd-gloss > summary {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; cursor: pointer; list-style: none;
  border-radius: var(--radius); font-weight: 700;
}
.rd-gloss > summary::-webkit-details-marker { display: none; }
.rd-gloss > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex-shrink: 0;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform 0.2s;
}
.rd-gloss[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.rd-gloss > summary:hover { background: var(--surface-2); }
.rd-gloss-title { display: inline-flex; align-items: center; gap: 8px; }
.rd-gloss-title svg { color: var(--accent); }
.rd-words {
  list-style: none; margin: 0; padding: 4px 16px 16px; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
}
.rd-words li { display: flex; align-items: flex-start; gap: 6px; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.rw-main { flex: 1; min-width: 0; }
.rw-top { display: flex; align-items: baseline; gap: 0 8px; flex-wrap: wrap; min-width: 0; }
.rd-words .speak { width: 32px; height: 32px; margin-top: 2px; }
.rw-jp { font-size: 1.2rem; font-weight: 700; }
.rw-kana { color: var(--muted); font-size: 0.95rem; }
.rw-top .romaji { font-size: 0.82rem; }
.rw-th { font-size: 0.92rem; line-height: 1.5; padding-right: 6px; }

/* ---------- คำถาม ---------- */
.rd-questions .section-head { margin-top: 1.6em; margin-bottom: 0.2em; }
.rd-q-hint { margin-bottom: 12px; }
/* คำใบ้คีย์ลัด: แสดงเฉพาะเครื่องที่มีเมาส์/แป้นพิมพ์ */
.rd-kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 761px) { .rd-kbd-hint { display: inline; } }
.rq-list { display: grid; gap: 12px; }
.rq { padding: 18px 20px; }
.rq.right { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.rq.wrong { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.rq-q { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.rq-num {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; margin-top: 0.45em;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.95rem;
}
.rq-text { flex: 1; min-width: 0; font-size: 1.1rem; font-weight: 600; line-height: 2.1; }
.rq-choices { display: grid; gap: 8px; }
.rq-choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rq-choices .choice { width: 100%; padding: 6px 14px; font-size: 1.04rem; font-weight: 500; line-height: 2; color: var(--text); }
.rq-choices .choice.correct { color: var(--ok); font-weight: 600; }
.rq-choices .choice.incorrect { color: var(--bad); font-weight: 600; }
.rq-choices .choice:disabled:not(.correct):not(.incorrect) { color: var(--muted); }
.rq-cnum {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  border: 1.5px solid currentColor; font-family: var(--font); font-size: 0.78rem; font-weight: 700; line-height: 1; opacity: 0.75;
}
.rq-ctext { flex: 1; min-width: 0; }
.rq-explain { margin-top: 12px; padding: 10px 14px; border-radius: 12px; font-size: 0.95rem; line-height: 1.95; }
.rq-explain.ok { background: var(--ok-soft); }
.rq-explain.bad { background: var(--bad-soft); }
.rq-verdict { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.rq-explain.ok .rq-verdict { color: var(--ok); }
.rq-explain.bad .rq-verdict { color: var(--bad); }
.rq-explain b { color: var(--accent); }

.rd-result { gap: 6px; }
.rd-result p { margin: 0 0 4px; }
.rd-result-score { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.rd-result-score strong { font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.rd-noq { margin-top: 16px; }

/* ---------- ปุ่มบทก่อนหน้า / ถัดไป ---------- */
.rd-pager .btn {
  flex-direction: column; align-items: flex-start; gap: 0; max-width: min(100%, 380px); min-width: 0;
  padding: 8px 16px; white-space: normal; text-align: left;
}
.rd-pager .btn small { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-weight: 500; font-size: 0.78rem; }
.rd-pager .btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-pager .rd-next { margin-left: auto; align-items: flex-end; text-align: right; }

/* ---------- จอมือถือ ---------- */
@media (max-width: 640px) {
  .rd-passage { padding: 20px 18px; }
  .rd-jp { font-size: 1.08rem; line-height: 2.2; }
  .rd-panel { padding: 16px 16px 18px; }
  .rd-passage.kind-info { padding: 26px 10px 16px; }
  .rd-flyer { padding: 16px 14px 18px; }
  .fl-title { font-size: 1.22rem; }
  /* ตารางในใบปลิว → เรียงเป็นบล็อก แถวละหนึ่งการ์ด */
  .fl-table, .fl-table tbody, .fl-table tr, .fl-table td { display: block; }
  .fl-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 14px; padding: 6px 12px; border-top: 1px solid var(--border); }
  .fl-table tr:first-child { border-top: none; }
  .fl-table td { padding: 0; border: none !important; background: none !important; }
  .fl-table td:first-child { flex-basis: 100%; }
  .fl-table.cols-2 td:first-child, .fl-table td.tag:first-child { flex-basis: auto; }
  .fl-table td.tag:first-child { color: var(--accent); }
  .rq { padding: 16px 14px; }
  .rq-q { gap: 10px; }
  .rq-text { font-size: 1.04rem; }
  .rq-choices .choice { padding: 6px 12px; font-size: 1rem; }
  .rd-result-score strong { font-size: 1.7rem; }
  .rd-overview .rd-ov-go { margin-left: 0; flex: 1 1 100%; justify-content: center; }
}
@media (max-width: 520px) {
  .rq-choices.two { grid-template-columns: minmax(0, 1fr); }
  .rd-pager .btn { max-width: 100%; flex: 1 1 100%; }
  .rd-gloss > summary { padding: 14px 16px; }
  .rd-words { padding: 4px 12px 12px; }
}

/* ---------- หัวหน้าเพจ (JP.app.pageHead) ---------- */
.rd-page .page-head .eyebrow { gap: 6px 12px; }
.rd-back { margin: 0; min-height: 32px; }
.rd-crumbs { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.rd-done-tag:empty { display: none; }

/* จอสัมผัส: ปุ่ม/สวิตช์ในแถบเครื่องมือสูงอย่างน้อย 44px ให้แตะง่าย */
@media (pointer: coarse) {
  .rd-tools .btn, .rd-tools .switch { min-height: 44px; }
  .rd-words .speak { width: 44px; height: 44px; margin-top: 0; }
  .rd-back { min-height: 44px; }
}
@media (max-width: 520px) {
  .rd-tools .spacer { display: none; }
  .rd-tools .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- แต้มที่ได้รอบนี้ + ส่วนท้ายหน้าจบรอบ (finishFooter ของเปลือกแอป) ---------- */
.view-reading .rd-earned {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.view-reading .rd-result-score .small { flex-basis: 100%; }
.view-reading .rd-finish { margin-top: 4px; }
/* ===== css/views/listening.css ===== */
/* สไตล์เฉพาะหน้า listening (การฟัง 聴解) — ใช้ตัวแปรสีจาก style.css เท่านั้น */

/* สีประจำผู้พูด: ชาย = คราม, หญิง = แดงชาด, ผู้บรรยาย = เทา, คำถาม = เหลืองอำพัน */
.view-listening .who-M { --who: var(--indigo); --who-soft: var(--indigo-soft); }
.view-listening .who-F { --who: var(--accent); --who-soft: var(--accent-soft); }
.view-listening .who-N { --who: var(--muted); --who-soft: var(--surface-2); }
.view-listening .who-Q { --who: var(--warn); --who-soft: var(--warn-soft); }

.view-listening .pill.bad { background: var(--bad-soft); color: var(--bad); }
.view-listening .ls-bad-text { color: var(--bad); font-weight: 600; }

/* ---------- หน้ารวม ---------- */
.ls-overview { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding: 16px 18px; }
.ls-ov-stat { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; flex: 1 1 260px; min-width: 0; }
.ls-ov-stat .progress { flex: 1; min-width: 120px; }
.ls-ov-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ls-ov-go { margin-left: auto; min-height: 44px; }
.ls-kind .section-head h2 { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.ls-kind-jp { font-family: var(--font-display); font-weight: 600; color: var(--muted); font-size: 0.8em; }
.ls-kind-desc { margin: -2px 0 12px; font-size: 0.92rem; color: var(--muted); max-width: 760px; }
.ls-item .lesson-title {
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.45;
}
.ls-item.wrong .lesson-num { background: var(--bad-soft); color: var(--bad); }
.ls-item.wrong { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.ls-item.done { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.ls-meta { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; margin-top: 3px; }
.ls-minis { display: inline-flex; gap: 3px; }
.ls-mini {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; line-height: 1;
  background: var(--who-soft); color: var(--who);
}

/* ---------- หน้าข้อ ---------- */
.ls-page { max-width: 820px; }
.ls-head h1 { margin-bottom: 0.15em; }
.ls-head .lead { font-size: 1rem; margin-bottom: 16px; }

/* เครื่องเล่นเสียง */
.ls-player { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 22px; align-items: center; }
.ls-play {
  position: relative; width: 92px; height: 92px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 2px; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; font-size: 0.86rem;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: background 0.15s, transform 0.08s;
}
.ls-play:hover:not(:disabled) { background: var(--accent-hover); }
.ls-play:active:not(:disabled) { transform: scale(0.96); }
.ls-play:disabled { background: var(--surface-3); color: var(--faint); box-shadow: none; cursor: not-allowed; }
.ls-play svg { width: 30px; height: 30px; }
.ls-play.is-playing::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  border: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
  animation: ls-pulse 1.5s ease-out infinite;
}
@keyframes ls-pulse {
  from { transform: scale(0.94); opacity: 1; }
  to { transform: scale(1.16); opacity: 0; }
}
.ls-player-main { display: grid; gap: 10px; min-width: 0; }
.ls-status { margin: 0; font-weight: 600; line-height: 1.5; }
.ls-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ls-speed { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.ls-speed output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.ls-speed .seg { padding: 3px; }
.ls-speed .seg button { padding: 4px 10px; font-size: 0.84rem; }
.ls-player .notice { margin: 0; }

/* ลำดับเสียง: ไอคอนผู้พูดแต่ละช่วง (ไม่แสดงข้อความก่อนตอบ) */
.ls-track {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 4px;
}
.ls-track li { display: contents; }
.ls-step {
  display: grid; justify-items: center; gap: 3px; width: 52px; padding: 5px 0 4px; border: none; border-radius: 12px;
  background: none; cursor: pointer; font: inherit; color: var(--muted);
}
.ls-step:hover { background: var(--surface-2); }
.ls-dot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; line-height: 1;
  border: 2px solid color-mix(in srgb, var(--who) 35%, var(--border)); color: var(--who); background: var(--surface);
  transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.ls-step.heard .ls-dot { background: var(--who-soft); border-color: var(--who); }
.ls-step.now .ls-dot {
  background: var(--who); color: var(--surface); border-color: var(--who);
  transform: scale(1.12); box-shadow: 0 0 0 4px var(--who-soft);
}
.ls-step-label { font-size: 0.7rem; line-height: 1.2; white-space: nowrap; }
.ls-step.now .ls-step-label { color: var(--who); font-weight: 700; }
.ls-keys { grid-column: 1 / -1; margin: -4px 0 0; }
/* คำใบ้คีย์ลัด: แสดงเฉพาะเครื่องที่มีเมาส์/แป้นพิมพ์ (จอสัมผัสใช้ข้อความ "แตะ…" แทน) */
.ls-keys, .ls-feedback .btn kbd, .ls-qa .btn kbd, .ls-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .ls-keys { display: block; }
  .ls-feedback .btn kbd, .ls-qa .btn kbd { display: inline-block; }
  .ls-mouse { display: inline; }
  .ls-touch { display: none; }
}

/* ปุ่มลำโพงต่อท้ายข้อความญี่ปุ่น (ไหลไปกับบรรทัดสุดท้าย) */
.ls-situation-jp .speak, .ls-question .speak, .ls-line-jp .speak { margin-left: 2px; vertical-align: -0.1em; }

/* สถานการณ์ (発話表現) */
.ls-situation { margin-top: 16px; border-left: 5px solid var(--indigo); }
.ls-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 4px; }
.ls-situation-jp { font-size: 1.15rem; line-height: 2.1; }
.ls-situation-th { margin: 6px 0 0; color: var(--muted); }

/* คำถามและตัวเลือก */
.ls-qa { margin-top: 16px; display: grid; gap: 14px; }
.ls-q-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.ls-q-head h2 { margin: 0; font-size: 1.05rem; }
.ls-q-head .switch { font-size: 0.86rem; }
.ls-question { font-size: 1.2rem; font-weight: 600; line-height: 2.1; }
.ls-locked {
  display: grid; justify-items: center; gap: 10px; text-align: center; padding: 18px 16px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted);
}
.ls-locked p { margin: 0; }
.ls-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ls-choices.one-col { grid-template-columns: minmax(0, 1fr); }
.ls-choices .choice { width: 100%; min-height: 54px; padding: 8px 14px; font-size: 1.1rem; line-height: 2; color: var(--text); }
.ls-choices .choice.correct { color: var(--ok); }
.ls-choices .choice.incorrect { color: var(--bad); }
.ls-choice-text { min-width: 0; transition: filter 0.2s; }
.ls-choices.conceal:not(.answered) .ls-choice-text { filter: blur(7px); user-select: none; }
.ls-choices .choice.speaking { border-color: var(--indigo); background: var(--indigo-soft); box-shadow: 0 0 0 3px var(--indigo-soft); }

.ls-feedback { display: grid; gap: 8px; padding: 14px 16px; border-radius: 14px; }
.ls-feedback.ok { background: var(--ok-soft); }
.ls-feedback.bad { background: var(--bad-soft); }
.ls-feedback .fb-head { font-weight: 700; font-size: 1.05rem; }
.ls-feedback.ok .fb-head { color: var(--ok); }
.ls-feedback.bad .fb-head { color: var(--bad); }
.ls-xp { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 999px; background: var(--ok); color: var(--ok-ink); font-size: 0.85rem; }
.ls-explain { margin: 0; line-height: 1.95; }
.ls-explain ruby rt { color: var(--muted); }

/* 統合理解 แบบหลายคำถาม: กล่องคำถามแต่ละข้อ (ตัวเลือกพิมพ์ไว้) */
.view-listening .pill.warn { background: var(--warn-soft); color: var(--warn); }
.ls-mq { display: grid; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 14px; transition: border-color 0.15s, box-shadow 0.15s; }
.ls-mq.active { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.ls-mq-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ls-mq-no { font-family: var(--font-display); font-weight: 700; color: var(--warn); font-size: 1.02rem; }
.ls-mq-wait { font-size: 0.9rem; }
.ls-mq .ls-question { font-size: 1.1rem; }
.ls-choices .choice.picked { border-color: var(--indigo); background: var(--indigo-soft); color: var(--indigo); }
.ls-mq-fb { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; }
.ls-mq-fb.ok { background: var(--ok-soft); }
.ls-mq-fb.ok > b { color: var(--ok); }
.ls-mq-fb.bad { background: var(--bad-soft); }
.ls-mq-fb.bad > b { color: var(--bad); }
.ls-check { display: flex; align-items: center; justify-content: flex-end; gap: 8px 14px; flex-wrap: wrap; }

/* บทพูด (เฉลย) */
.ls-script .section-head { margin-top: 1.6em; }
.ls-lines { padding: 6px; display: grid; gap: 2px; }
.ls-line {
  display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 2px 14px; padding: 10px 12px; border-radius: 12px;
  transition: background 0.2s;
}
.ls-line + .ls-line { border-top: 1px solid var(--border); border-radius: 0; }
.ls-line.now { background: var(--who-soft); border-radius: 12px; }
.ls-who { display: flex; align-items: flex-start; gap: 8px; padding-top: 6px; font-size: 0.86rem; font-weight: 700; color: var(--who); line-height: 1.3; }
.ls-who > span:last-child { display: grid; }
.ls-who small { font-weight: 500; color: var(--muted); font-size: 0.78rem; }
.ls-who .ls-dot { width: 28px; height: 28px; font-size: 0.88rem; background: var(--who-soft); border-color: var(--who); }
.ls-line-body { min-width: 0; }
.ls-line-jp { font-size: 1.12rem; line-height: 2.1; }
.ls-line-th { color: var(--muted); font-size: 0.95rem; line-height: 1.6; }
.ls-lines.no-th .ls-line-th { display: none; }

.ls-sub-h { margin: 18px 0 8px; }
.ls-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ls-opts li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; padding: 6px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 1.05rem; line-height: 2;
}
.ls-opt-acts { display: inline-flex; align-items: center; gap: 4px; }
.ls-opts li.right { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); background: var(--ok-soft); }
.ls-opt-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 0.85rem; line-height: 1;
}
.ls-opts li.right .ls-opt-num { background: var(--ok); color: var(--ok-ink); }
.ls-opts li.speaking { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.ls-opt-jp { min-width: 0; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 640px) {
  .ls-player { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .ls-player-main { justify-items: center; width: 100%; }
  .ls-controls { justify-content: center; }
  .ls-speed { margin-left: 0; justify-content: center; }
  .ls-track { justify-content: center; width: 100%; }
  .ls-track-label { text-align: center; }
  .ls-ov-go { margin-left: 0; flex: 1 1 100%; justify-content: center; }
  .ls-line { grid-template-columns: minmax(0, 1fr); padding: 10px 8px; }
  .ls-who { padding-top: 0; }
  .ls-who > span:last-child { display: flex; gap: 6px; align-items: baseline; }
}
@media (max-width: 520px) {
  .ls-choices { grid-template-columns: minmax(0, 1fr); }
  .ls-opts li { grid-template-columns: 26px minmax(0, 1fr); align-items: start; }
  .ls-opt-num { margin-top: 7px; }
  .ls-opt-acts { grid-column: 2; margin: -4px 0 2px -8px; }
  .ls-play { width: 84px; height: 84px; }
  .ls-step { width: 46px; }
  .ls-dot { width: 32px; height: 32px; }
  .ls-question, .ls-situation-jp { font-size: 1.1rem; }
  .ls-mq { padding: 10px; }
  .ls-check { justify-content: center; }
}

/* ---------- หัวหน้าเพจ / ลำดับผู้พูด / จอสัมผัส ---------- */
.ls-page .page-head .eyebrow { gap: 6px 12px; }
.ls-back { margin: 0; min-height: 32px; }
.ls-crumbs { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.ls-track-wrap { grid-column: 1 / -1; display: grid; gap: 6px; padding-top: 12px; border-top: 1px dashed var(--border-strong); min-width: 0; }
.ls-track-label { margin: 0; }
@media (pointer: coarse) {
  .ls-back, .ls-controls .btn, .ls-speed .seg button, .ls-q-head .btn { min-height: 44px; }
  .ls-step { min-height: 56px; }
}
/* เลขตัวเลือกเป็นป้ายบอกหมายเลขข้อ (เฉลยอ้างถึง "ข้อ 2") — แสดงบนจอสัมผัสด้วย แม้ style.css ซ่อน kbd ของ .choice */
@media (hover: none) and (pointer: coarse) {
  .ls-choices .choice kbd { display: inline-grid !important; place-items: center; }
}

/* ---------- ฟังซ้ำ + ส่วนท้ายหน้าจบรอบ (finishFooter ของเปลือกแอป) ---------- */
.view-listening .ls-redo-note { font-weight: 400; }
.view-listening .ls-finish { margin-top: 4px; }
/* ===== css/views/conjugate.css ===== */
/* สไตล์เฉพาะหน้า conjugate (ฝึกผันคำ 活用ドリル) — ใช้ตัวแปรสีจาก style.css เท่านั้น (รองรับโหมดมืด) */

.cj-h1-ja { font-family: var(--font-display); font-weight: 600; font-size: 0.7em; margin-left: 4px; }

/* =========================================================================
   หน้าตั้งค่า
   ========================================================================= */
.cj-setup { max-width: 780px; }
.cj-setup .seg { max-width: 100%; }
@media (max-width: 520px) {
  .cj-type { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
}

.cj-levels { display: flex; flex-wrap: wrap; gap: 8px; }
.cj-lv {
  position: relative; display: grid; justify-items: center; gap: 0; min-width: 76px; padding: 8px 12px;
  border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.cj-lv input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cj-lv span { font-weight: 800; font-variant-numeric: tabular-nums; }
.cj-lv small { font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.cj-lv:hover { border-color: var(--accent); }
.cj-lv:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.cj-lv:has(input:checked) span { color: var(--accent); }
.cj-lv:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.cj-lv.disabled { cursor: not-allowed; border-style: dashed; background: var(--surface-2); color: var(--muted); }
.cj-lv.disabled:hover { border-color: var(--border-strong); }
.cj-vs { margin-top: 6px; flex-wrap: wrap; }

.cj-form-group { margin-top: 8px; }
.cj-form-title { font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.cj-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 6px; }
.cj-check {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); cursor: pointer; min-width: 0; font-size: 0.93rem;
}
.cj-check:hover { border-color: var(--border-strong); }
.cj-check:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); }
.cj-check input { accent-color: var(--accent); flex-shrink: 0; margin: 0; }
.cj-check-text { flex: 1; min-width: 0; }
.cj-check .pill { font-size: 0.7rem; padding: 1px 7px; }

.cj-start { display: grid; gap: 8px; justify-items: start; }
.cj-start p { margin: 0; }
.cj-start .cj-warn { color: var(--bad); font-weight: 600; }

/* =========================================================================
   คำถาม
   ========================================================================= */
.cj-card { padding-top: 18px; }
.cj-pills { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.cj-dict { display: grid; gap: 2px; justify-items: center; }
.cj-dict-jp { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.cj-dict-jp > .jp {
  font-family: var(--font-display); font-weight: 600; line-height: 1.2;
  font-size: clamp(2.4rem, 1.8rem + 3.4vw, 3.6rem); word-break: keep-all; overflow-wrap: anywhere;
}
.cj-dict-reading { display: flex; gap: 10px; align-items: baseline; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 1.05rem; }
.cj-dict-th { font-weight: 600; font-size: 1.05rem; }

.cj-ask { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 12px 0 16px; }
.cj-ask .q-label { margin: 0; font-size: 0.85rem; }
.cj-arrow { color: var(--faint); font-size: 1.1rem; line-height: 1; }
.cj-target {
  display: inline-block; padding: 7px 18px; border-radius: 999px; font-weight: 700; font-size: 1.12rem;
  background: var(--accent-soft); color: var(--accent); border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.cj-choices .choice { font-size: 1.3rem; line-height: 1.9; min-height: 60px; }
.cj-choices .choice .jp { overflow-wrap: anywhere; }
.cj-choices .choice rt { font-size: 0.48em; }
.cj-type-form input { font-family: var(--font-jp); }
.cj-skip { margin-top: 8px; }

.cj-feedback { text-align: center; }
.cj-answer .jp { font-size: 1.5rem; line-height: 1.9; }
.cj-rule {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; max-width: 540px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  font-size: 0.95rem; line-height: 1.7;
}
.cj-rule b { color: var(--accent); }
.cj-rule-tag {
  flex-shrink: 0; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  background: var(--indigo-soft); color: var(--indigo); margin-top: 3px;
}

/* =========================================================================
   ผลลัพธ์
   ========================================================================= */
.cj-mistakes li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 12px; }
.cj-mistakes li > span:last-child { margin-left: 0; }
.cj-m-q { min-width: 0; }
.cj-m-q .muted { font-size: 0.88rem; font-weight: 500; }
.cj-m-a { display: inline-flex; align-items: center; gap: 2px; justify-self: end; }
.cj-mistakes .cj-m-a .jp { font-size: 1.2rem; font-weight: 700; line-height: 1.9; }
.cj-m-given { grid-column: 1 / -1; color: var(--muted); }
.cj-mistakes .cj-m-given .jp { font-size: 0.95rem; font-weight: 500; }
.cj-finish p.small { margin: 12px 0 0; }

/* =========================================================================
   ตารางกฎการผัน
   ========================================================================= */
.modal.cj-sheet-modal { width: min(900px, 100%); }
.cj-sheet h2 { margin-top: 0; padding-right: 36px; }
.cj-sheet h3 { margin: 20px 0 8px; }
.cj-groups, .cj-notes { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.cj-groups li, .cj-notes li { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); line-height: 1.7; }
.cj-notes b { color: var(--accent); }

.cj-sheet-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.cj-sheet-table th, .cj-sheet-table td { padding: 7px 8px; border-top: 1px solid var(--border); vertical-align: top; text-align: left; }
.cj-sheet-table thead th { border-top: none; font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.cj-sheet-table tbody th { font-weight: 600; width: 22%; }
.cj-sh-form { display: block; }
.cj-sheet-table tbody th .pill { font-size: 0.68rem; padding: 0 6px; margin-top: 2px; }
.cj-sh-rule { display: block; font-size: 0.8rem; color: var(--muted); }
.cj-ex { display: inline-block; white-space: nowrap; margin-right: 10px; font-size: 1.05rem; font-weight: 600; line-height: 1.9; }
.cj-te-table td:nth-child(2) { white-space: nowrap; }
.cj-te-table b { color: var(--accent); }
.cj-sheet .notice { margin: 10px 0 0; }

@media (max-width: 640px) {
  .cj-hide-sm { display: none; }
  .cj-card .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cj-choices .choice { font-size: 1.12rem; padding: 10px 10px; gap: 6px; }
  .cj-choices .choice kbd { display: none; }
  .cj-target { font-size: 1rem; padding: 6px 14px; }

  /* ตารางกฎ: เปลี่ยนแต่ละแถวเป็นการ์ดซ้อนกัน (ไม่ต้องเลื่อนแนวนอน) */
  .cj-sheet-table:not(.cj-te-table) thead { display: none; }
  .cj-sheet-table:not(.cj-te-table) tr { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); }
  .cj-sheet-table:not(.cj-te-table) th, .cj-sheet-table:not(.cj-te-table) td { display: block; border: none; padding: 0 4px; width: auto; }
  .cj-sheet-table:not(.cj-te-table) tbody th { display: flex; align-items: center; gap: 8px; }
  .cj-sheet-table:not(.cj-te-table) tbody th .pill { margin-top: 0; }
  .cj-sheet-table:not(.cj-te-table) td::before {
    content: attr(data-label); display: inline-block; min-width: 76px; font-size: 0.74rem; font-weight: 700; color: var(--indigo);
  }
  .cj-sh-rule { display: inline; margin-right: 8px; }
  .cj-te-table td:nth-child(2) { white-space: normal; }
}
@media (max-width: 360px) {
  .cj-card .choices { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .cj-mistakes li { grid-template-columns: minmax(0, 1fr); }
  .cj-m-a { justify-self: start; }
}

/* =========================================================================
   หน้าตั้งค่า (รุ่นเรียบง่าย): ขั้นตอน 1-2-3 + ตั้งค่าเพิ่มเติมแบบพับ
   ========================================================================= */
.cj-setup .field > label, .cj-setup legend { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.cj-step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; font-weight: 800;
}
.cj-setup .seg button { min-height: 40px; }
.cj-presets-seg button { padding-left: 16px; padding-right: 16px; }
.cj-custom { margin: 6px 0 0; }
.cj-row2 { display: flex; flex-wrap: wrap; gap: 4px 28px; align-items: flex-start; }
.cj-row2 > * { flex: 1 1 260px; min-width: 0; }
.cj-adv { margin: 4px 0 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.cj-adv > summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-height: 48px; padding: 12px 14px;
  cursor: pointer; font-weight: 700; list-style: none;
}
.cj-adv > summary::-webkit-details-marker { display: none; }
.cj-adv > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; display: inline-block; }
.cj-adv[open] > summary::before { transform: rotate(90deg); }
.cj-adv > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.cj-adv-sum { font-weight: 500; }
.cj-adv[open] .cj-adv-sum { display: none; }
.cj-adv > .field { padding: 0 14px 6px; margin-top: 0; }
.cj-adv .cj-check { background: var(--surface); min-height: 44px; }
.cj-start { padding-top: 14px; border-top: 1px solid var(--border); }
.cj-start .btn-lg svg { width: 18px; height: 18px; }
.cj-pills .help-wrap { margin-right: 2px; }
@media (max-width: 520px) {
  .cj-start, .cj-start .btn-lg { justify-items: stretch; width: 100%; justify-content: center; }
  .cj-presets-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .cj-presets-seg button { padding-left: 6px; padding-right: 6px; }
}
/* ===== css/views/exam.css ===== */
/* สไตล์เฉพาะหน้า exam (ข้อสอบจำลอง JLPT) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืดอัตโนมัติ */

.view-exam .ex-h-ja { font-family: var(--font-display); font-weight: 600; font-size: 0.62em; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.view-exam .ex-linkbtn { border: none; background: none; padding: 0; cursor: pointer; font: inherit; font-size: 0.92rem; }
.view-exam .pill.bad, .ex-modal-title + p .pill.bad { background: var(--bad-soft); color: var(--bad); }
.ex-modal-title { margin-top: 0; padding-right: 30px; }
.ex-bad-text { color: var(--bad); }

/* ---------- หน้ารวม: รูปแบบข้อสอบจริง ---------- */
.view-exam .ex-format { margin-top: 20px; }
.view-exam .ex-format h2 { margin: 0; }
.view-exam .ex-format h3 { margin: 18px 0 10px; }
.view-exam .ex-format-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.view-exam .ex-sections { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 10px; }
.view-exam .ex-sec { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.view-exam .ex-sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-exam .ex-sec-head .pill { margin-left: auto; }
.view-exam .ex-sec-head .pill svg { width: 13px; height: 13px; }
.view-exam .ex-sec-no {
  width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.view-exam .ex-sec-name { display: grid; line-height: 1.35; font-weight: 700; min-width: 0; flex: 1 1 200px; }
.view-exam .ex-sec-name small { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.view-exam .ex-sec-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.view-exam .ex-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.85rem;
  background: var(--surface); border: 1px solid var(--border);
}
.view-exam .ex-chip b { color: var(--accent); font-variant-numeric: tabular-nums; }

.view-exam .ex-scoring { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 10px; }
.view-exam .ex-score-cell { display: grid; gap: 2px; align-content: start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.view-exam .ex-score-cell.total { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.view-exam .ex-score-name { display: grid; font-weight: 700; line-height: 1.35; font-size: 0.92rem; }
.view-exam .ex-score-name small { font-weight: 500; color: var(--muted); font-size: 0.78rem; }
.view-exam .ex-score-range { font-size: 0.95rem; margin-top: 4px; }
.view-exam .ex-score-range b { font-size: 1.25rem; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------- หน้ารวม: ปุ่มเริ่ม / ฝึกตามประเภท ---------- */
.view-exam .ex-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.view-exam .ex-action h2 { margin-top: 0; }
.view-exam .ex-action.main { position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.view-exam .ex-action.main > :not(.ex-action-glyph) { position: relative; }
.view-exam .ex-action-glyph {
  position: absolute; right: -6px; top: -18px; font-family: var(--font-display); font-size: 120px; line-height: 1;
  color: var(--accent); opacity: 0.07; pointer-events: none;
}
.view-exam .ex-bullets { margin: 0 0 14px; padding-left: 1.2em; color: var(--muted); }
.view-exam .ex-bullets li { margin-bottom: 3px; }
.view-exam .ex-action .notice { margin-bottom: 14px; }
.view-exam .ex-action .btn-lg { white-space: normal; }
.view-exam .ex-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.view-exam .ex-type {
  min-height: 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 8px; text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: border-color 0.15s, background 0.15s;
}
.view-exam .ex-type:hover { border-color: var(--accent); background: var(--accent-soft); }
.view-exam .ex-type-main { font-weight: 700; font-size: 0.98rem; line-height: 1.35; }
.view-exam .ex-type-sub { font-family: var(--font-jp); font-size: 0.78rem; grid-column: 1 / -1; color: var(--muted); }
.view-exam .ex-type-n { font-size: 0.78rem; color: var(--accent); font-weight: 600; grid-row: 1; grid-column: 2; white-space: nowrap; }

/* ---------- หน้ารวม: ประวัติ ---------- */
.view-exam .ex-history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.view-exam .ex-hist { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-left: 4px solid var(--bad); }
.view-exam .ex-hist.pass { border-left-color: var(--ok); }
.view-exam .ex-hist-pct { display: grid; min-width: 92px; line-height: 1.25; }
.view-exam .ex-hist-pct strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.view-exam .ex-hist-body { display: grid; gap: 4px; min-width: 0; flex: 1; }
.view-exam .ex-hist-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-exam .ex-hist-secs { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.82rem; color: var(--muted); }
.view-exam .ex-hist-sec b { color: var(--text); font-variant-numeric: tabular-nums; }
.view-exam .ex-empty-hist { padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }

/* ---------- ก่อนเริ่มแต่ละส่วน ---------- */
.view-exam .ex-gate-wrap { max-width: 760px; margin: 0 auto; }
.view-exam .ex-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.view-exam .ex-ov { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.view-exam .ex-ov.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.view-exam .ex-ov-no {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); font-weight: 700; font-size: 0.85rem; color: var(--muted);
}
.view-exam .ex-ov.current .ex-ov-no { background: var(--accent); color: var(--accent-ink); }
.view-exam .ex-ov-body { display: grid; line-height: 1.35; font-size: 0.85rem; font-weight: 600; min-width: 0; }
.view-exam .ex-ov-body small { color: var(--muted); font-weight: 500; }
.view-exam .ex-prev { display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 14px; background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.view-exam .ex-prev > svg { color: var(--ok); flex-shrink: 0; }
.view-exam .ex-gate { padding: 26px 28px; }
.view-exam .ex-gate h1 { font-family: var(--font-jp); margin-bottom: 0.1em; }
.view-exam .ex-gate .lead { margin-bottom: 14px; }
.view-exam .ex-gate-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.view-exam .ex-gate-stats > div { display: grid; justify-items: center; padding: 10px 6px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.view-exam .ex-gate-stats strong { font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.view-exam .ex-gate-stats span { font-size: 0.8rem; color: var(--muted); }
.view-exam .ex-gate-parts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.view-exam .ex-gate-parts li { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.view-exam .ex-gate-parts li > span:nth-child(2) { flex: 1 1 0; min-width: 0; }
.view-exam .ex-gate-parts li > span:last-child { white-space: nowrap; }
.view-exam .ex-gate .notice { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.view-exam .ex-notes { margin: 0 0 14px; font-size: 0.9rem; }
.view-exam .ex-notes summary { cursor: pointer; color: var(--warn); font-weight: 600; }
.view-exam .ex-notes ul { margin: 6px 0 0; padding-left: 1.2em; color: var(--muted); }

/* ---------- ระหว่างสอบ: แถบด้านบน ---------- */
.view-exam .ex-bar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap;
  margin: -8px -8px 16px; padding: 10px 14px 0; border-radius: 0 0 var(--radius) var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--border); border-top: none;
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); box-shadow: var(--shadow);
}
.view-exam .ex-bar-info { display: grid; line-height: 1.3; min-width: 0; flex: 1 1 200px; }
.view-exam .ex-bar-step { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.view-exam .ex-bar-name { font-weight: 700; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-exam .ex-timer {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 10px; font-weight: 800;
  font-size: 1.15rem; font-variant-numeric: tabular-nums; background: var(--indigo-soft); color: var(--indigo);
}
.view-exam .ex-timer.free { font-size: 0.85rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.view-exam .ex-timer.warn { background: var(--warn-soft); color: var(--warn); }
.view-exam .ex-timer.bad { background: var(--bad-soft); color: var(--bad); animation: ex-blink 1s steps(2, start) infinite; }
@keyframes ex-blink { 50% { opacity: 0.55; } }
.view-exam .ex-bar-count { font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.view-exam .ex-bar-count b { color: var(--text); font-size: 1.05rem; }
.view-exam .ex-bar-actions { display: flex; gap: 6px; }
.view-exam .ex-bar-progress { flex-basis: 100%; margin: 0 -14px; }
.view-exam .ex-bar-progress .progress { height: 4px; border-radius: 0; background: transparent; }

/* ---------- ระหว่างสอบ: กระดาษข้อสอบ + แผนผังข้อ ---------- */
.view-exam .ex-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; align-items: start; }
.view-exam .ex-paper { min-width: 0; display: grid; gap: 22px; }
.view-exam .ex-side {
  position: sticky; top: 104px; max-height: calc(100vh - 120px); overflow-y: auto; scrollbar-width: thin;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.view-exam .ex-nav-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.view-exam .ex-nav-close { display: none; }
.view-exam .ex-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); margin-bottom: 10px; }
.view-exam .ex-legend span { display: inline-flex; align-items: center; gap: 5px; }
.view-exam .ex-cell-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--border-strong); background: var(--surface); }
.view-exam .ex-cell-dot.done { background: var(--indigo); border-color: var(--indigo); }
.view-exam .ex-cell-dot.flag { border-color: var(--warn); background: var(--warn-soft); }
.view-exam .ex-nav-part { margin-bottom: 10px; }
.view-exam .ex-nav-label { font-size: 0.78rem; font-weight: 700; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-exam .ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 5px; }
.view-exam .ex-cell {
  position: relative; height: 34px; border-radius: 8px; border: 1.5px solid var(--border-strong); background: var(--surface);
  color: var(--muted); font-weight: 700; font-size: 0.85rem; cursor: pointer; font-variant-numeric: tabular-nums; padding: 0;
}
.view-exam .ex-cell:hover { border-color: var(--accent); color: var(--accent); }
.view-exam .ex-cell.done { background: var(--indigo); border-color: var(--indigo); color: var(--surface); }
.view-exam .ex-cell.flag { border-color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.view-exam .ex-cell.flag::after {
  content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn); border: 2px solid var(--surface);
}
.view-exam .ex-nav-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.view-exam .ex-exit { color: var(--bad); }
.view-exam .ex-scrim { display: none; }

/* หัว 問題 */
.view-exam .ex-part { display: grid; gap: 12px; }
.view-exam .ex-mondai { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--ink); }
.view-exam .ex-mondai-top { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 4px; }
.view-exam .ex-mondai-no {
  display: inline-block; padding: 1px 10px; border: 1.5px solid var(--ink); border-radius: 4px; font-family: var(--font-jp);
  font-weight: 700; font-size: 0.95rem; color: var(--ink); background: var(--surface);
}
.view-exam .ex-mondai-no.sm { font-size: 0.8rem; padding: 0 7px; }
.view-exam .ex-mondai-type { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.view-exam .ex-instr { margin: 0; font-size: 1rem; line-height: 1.8; font-weight: 500; }
.view-exam .ex-instr-th { margin: 2px 0 0; font-size: 0.86rem; color: var(--muted); }

/* คำถามหนึ่งข้อ */
.view-exam .ex-q {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px;
  scroll-margin-top: 130px; transition: border-color 0.15s, box-shadow 0.2s;
}
.view-exam .ex-q.answered { border-color: color-mix(in srgb, var(--indigo) 30%, var(--border)); }
.view-exam .ex-q.flagged { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.view-exam .ex-q.right { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.view-exam .ex-q.wrong, .view-exam .ex-q.skipped { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); }
.view-exam .ex-q.pulse { animation: ex-pulse 1.1s ease; }
@keyframes ex-pulse { 0%, 60% { box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); } }
.view-exam .ex-q-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.view-exam .ex-q-num {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; margin-top: 6px;
  background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.view-exam .ex-q.answered .ex-q-num { background: var(--indigo); color: var(--surface); }
.view-exam .ex-q-body { flex: 1; min-width: 0; }
.view-exam .ex-flag { color: var(--faint); margin-top: 3px; }
.view-exam .ex-flag.on { color: var(--warn); background: var(--warn-soft); }
.view-exam .ex-flag.static { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; }
.view-exam .ex-sent { font-size: 1.18rem; line-height: 2.25; overflow-wrap: anywhere; }
.view-exam .ex-sent rt, .view-exam .ex-word rt { font-size: 0.5em; }
.view-exam .ex-word { font-family: var(--font-display); font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.1rem); font-weight: 600; line-height: 1.8; }
.view-exam .ex-slots { display: inline-flex; gap: 6px; margin: 0 6px; vertical-align: middle; }
.view-exam .ex-slot {
  display: inline-grid; place-items: center; width: 2.6em; height: 1.4em; border-bottom: 2px solid var(--ink);
  font-size: 0.95em; line-height: 1; color: var(--accent); font-weight: 800;
}

/* ตัวเลือก 1–4 */
.view-exam .ex-choices { display: grid; gap: 8px; }
.view-exam .ex-choices.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.view-exam .ex-choices.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.view-exam .ex-choices.cols-1 { grid-template-columns: minmax(0, 1fr); }
.view-exam .ex-choice { padding: 8px 12px; gap: 10px; font-weight: 500; font-size: 1.08rem; line-height: 1.9; color: var(--text); min-width: 0; }
.view-exam .ex-choice .ex-ch { min-width: 0; overflow-wrap: anywhere; }
.view-exam .ex-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); font-size: 0.85rem; font-weight: 700; color: var(--muted); line-height: 1;
}
.view-exam .ex-choice.picked { border-color: var(--indigo); background: var(--indigo-soft); }
.view-exam .ex-choice.picked .ex-num { background: var(--indigo); border-color: var(--indigo); color: var(--surface); }
.view-exam .ex-choice.correct .ex-num { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.view-exam .ex-choice.incorrect .ex-num { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.view-exam .ex-choice.correct, .view-exam .ex-choice.incorrect { color: var(--text); }
.view-exam .ex-choices.cols-1 .ex-choice { font-size: 1.02rem; }

/* บทอ่านในข้อสอบ */
.view-exam .ex-group { display: grid; gap: 12px; }
.view-exam .ex-group-qs { display: grid; gap: 12px; }
.view-exam .ex-passage { padding: 22px 26px; }
.view-exam .ex-passage.kind-info { padding: 30px 18px 22px; }
.view-exam .ex-passage.kind-compare { padding: 0; }
.view-exam .ex-passage-d { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.view-exam .ex-passage-d > summary { display: flex; align-items: center; gap: 8px; padding: 10px 16px; cursor: pointer; font-weight: 600; color: var(--indigo); }
.view-exam .ex-passage-d[open] > summary { border-bottom: 1px dashed var(--border); }
.view-exam .ex-passage-d .rd-passage { border: none; box-shadow: none; }

/* เครื่องเล่นเสียง */
.view-exam .ex-player { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; min-height: 42px; margin-top: 2px; }
.view-exam .ex-play { min-width: 128px; }
.view-exam .ex-play-note { display: inline-flex; align-items: center; gap: 6px; }
.view-exam .ex-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.view-exam .ex-eq i { width: 3px; height: 100%; border-radius: 2px; background: var(--accent); animation: ex-eq 0.9s ease-in-out infinite; }
.view-exam .ex-eq i:nth-child(2) { animation-delay: -0.3s; }
.view-exam .ex-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes ex-eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.view-exam .ex-eq i { transform-origin: bottom; }
.view-exam .ex-peek { margin-top: 8px; font-size: 0.9rem; }
.view-exam .ex-peek summary { cursor: pointer; color: var(--muted); }

/* บทพูด */
.view-exam .ex-script { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.view-exam .ex-line { display: flex; gap: 10px; align-items: flex-start; }
.view-exam .ex-sp {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; margin-top: 4px;
  font-family: var(--font-jp); font-size: 0.8rem; font-weight: 700; background: var(--surface-3); color: var(--muted);
}
.view-exam .ex-line.sp-M .ex-sp { background: var(--indigo-soft); color: var(--indigo); }
.view-exam .ex-line.sp-F .ex-sp { background: var(--accent-soft); color: var(--accent); }
.view-exam .ex-line-body { min-width: 0; font-size: 1.02rem; line-height: 2; }
.view-exam .ex-line-th { font-size: 0.88rem; color: var(--muted); line-height: 1.6; }
.view-exam .ex-script-d summary { cursor: pointer; font-weight: 600; color: var(--indigo); }

/* คำอธิบาย / เฉลย */
.view-exam .ex-explain { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 0.95rem; line-height: 1.75; }
.view-exam .ex-explain.ok { background: var(--ok-soft); }
.view-exam .ex-explain.bad { background: var(--bad-soft); }
.view-exam .ex-explain-head { font-weight: 700; margin-bottom: 4px; }
.view-exam .ex-explain.ok .ex-explain-head { color: var(--ok); }
.view-exam .ex-explain.bad .ex-explain-head { color: var(--bad); }
.view-exam .ex-explain p { margin: 4px 0 0; }
.view-exam .ex-explain b { color: var(--accent); }
.view-exam .ex-full { line-height: 2.1; }
.view-exam .ex-full mark { background: var(--warn-soft); color: inherit; padding: 0 3px; border-radius: 4px; box-shadow: inset 0 -2px 0 var(--warn); }
.view-exam .ex-explain .ex-script-d { margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: var(--surface); }

.view-exam .ex-endcard { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.view-exam .ex-endcard p { margin: 0; }

/* ---------- หน้าผล ---------- */
.view-exam .ex-verdict { display: flex; align-items: center; gap: 24px; padding: 24px 28px; border-width: 2px; }
.view-exam .ex-verdict.pass { border-color: var(--ok); background: linear-gradient(135deg, var(--ok-soft), var(--surface) 60%); }
.view-exam .ex-verdict.fail { border-color: color-mix(in srgb, var(--bad) 60%, var(--border)); background: linear-gradient(135deg, var(--bad-soft), var(--surface) 60%); }
.view-exam .ex-stamp {
  flex-shrink: 0; display: grid; place-items: center; width: 118px; height: 118px; border-radius: 50%;
  border: 4px double currentColor; font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; letter-spacing: 0.04em;
  transform: rotate(-10deg); color: var(--bad); text-align: center; line-height: 1.1; padding: 8px;
}
.view-exam .ex-verdict.pass .ex-stamp { color: var(--ok); font-size: 2.1rem; }
.view-exam .ex-verdict-body { min-width: 0; }
.view-exam .ex-verdict h1 { margin-bottom: 0.2em; }
.view-exam .ex-total { margin: 0 0 4px; font-size: 1.1rem; }
.view-exam .ex-total strong { font-size: 2.2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.view-exam .ex-why { color: var(--bad); font-weight: 600; font-size: 0.95rem; margin: 6px 0 0; }
.view-exam .ex-verdict .notice { margin: 10px 0 0; }

.view-exam .ex-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.view-exam .ex-gscore { display: grid; gap: 8px; padding: 16px 18px; border-top: 4px solid var(--ok); }
.view-exam .ex-gscore.bad { border-top-color: var(--bad); }
.view-exam .ex-gscore.na { border-top-color: var(--border-strong); }
.view-exam .ex-gscore.na p { margin: 0; }
.view-exam .ex-gscore-name { display: grid; font-weight: 700; line-height: 1.35; }
.view-exam .ex-gscore-name small { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.view-exam .ex-gscore-num { color: var(--muted); }
.view-exam .ex-gscore-num strong { font-size: 2rem; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.view-exam .ex-meter { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); }
.view-exam .ex-meter > span { position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: inherit; background: var(--ok); }
.view-exam .ex-gscore.bad .ex-meter > span { background: var(--bad); }
.view-exam .ex-meter > i { position: absolute; top: -4px; bottom: -4px; left: var(--min); width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.view-exam .ex-gscore-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }

.view-exam .ex-sec-table { padding: 6px 18px; }
.view-exam .ex-sec-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.view-exam .ex-sec-row:first-child { border-top: none; }
.view-exam .ex-sec-score { font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.view-exam .ex-sec-score small { color: var(--muted); }
.view-exam .ex-sec-time { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; white-space: nowrap; }
.view-exam .ex-sec-time svg { width: 14px; height: 14px; }
.view-exam .ex-sec-table + .ex-notes, .view-exam .ex-sec-table + p { margin-top: 12px; }

.view-exam .ex-review-head { position: relative; }
.view-exam .ex-review { display: grid; gap: 14px; }
.view-exam .ex-review-sec { display: grid; gap: 14px; }
.view-exam .ex-review-title { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; font-size: 1.1rem; }
.view-exam .ex-wrong-tag { margin-bottom: -8px; }

/* ---------- ฝึกตามประเภท ---------- */
.view-exam .ex-practice { max-width: 820px; margin: 0 auto; display: grid; gap: 14px; }
.view-exam .ex-practice .session-top { margin-bottom: 0; flex-wrap: wrap; }
.view-exam .ex-pcard { padding: 6px; }
.view-exam .ex-pcard .ex-q { border: none; box-shadow: none; padding: 12px 12px 6px; }
.view-exam .ex-pnext { justify-content: flex-end; padding: 6px 12px 10px; }
.view-exam .ex-practice + h2, .view-exam .finish + h2 { max-width: 820px; margin-left: auto; margin-right: auto; }
.view-exam .finish ~ .ex-review { max-width: 820px; margin: 0 auto; }

/* ---------- จอกลาง: แผนผังข้อเป็นแผ่นเลื่อนขึ้นจากด้านล่าง ---------- */
@media (max-width: 1099px) {
  .view-exam .ex-layout { grid-template-columns: minmax(0, 1fr); }
  .view-exam .ex-side {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 45; max-height: 70vh;
    border-radius: 20px 20px 0 0; padding: 16px 16px 20px; box-shadow: var(--shadow-lg);
    transform: translateY(105%); transition: transform 0.22s ease; visibility: hidden;
  }
  .view-exam .ex-side.open { transform: none; visibility: visible; }
  .view-exam .ex-nav-close { display: inline-grid; }
  .view-exam .ex-scrim.open { display: block; position: fixed; inset: 0; z-index: 44; background: var(--scrim); }
  .view-exam .ex-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  .view-exam .ex-cell { height: 38px; }
}
@media (min-width: 1100px) {
  .view-exam .ex-nav-btn { display: none; }
}
@media (max-width: 1023px) {
  .view-exam .ex-bar { top: 57px; }
  .view-exam .ex-q { scroll-margin-top: 190px; }
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 760px) {
  .view-exam .ex-actions { grid-template-columns: minmax(0, 1fr); }
  .view-exam .ex-verdict { flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; }
  .view-exam .ex-stamp { width: 92px; height: 92px; font-size: 1.3rem; align-self: center; }
  .view-exam .ex-verdict.pass .ex-stamp { font-size: 1.7rem; }
  .view-exam .ex-choices.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .view-exam .ex-bar { margin: -6px -4px 14px; padding: 8px 10px 0; gap: 6px 10px; }
  .view-exam .ex-bar-info { flex-basis: 100%; }
  .view-exam .ex-bar-name { font-size: 0.9rem; }
  .view-exam .ex-timer { font-size: 1.02rem; padding: 4px 10px; }
  .view-exam .ex-bar-count span { display: none; }
  .view-exam .ex-bar-actions { margin-left: auto; }
  .view-exam .ex-bar-progress { margin: 0 -10px; }
  .view-exam .ex-q { padding: 12px 12px 14px; }
  .view-exam .ex-q-head { gap: 8px; }
  .view-exam .ex-sent { font-size: 1.08rem; }
  .view-exam .ex-choices.cols-2:not(.short) { grid-template-columns: minmax(0, 1fr); }
  .view-exam .ex-choice { font-size: 1rem; padding: 7px 10px; }
  .view-exam .ex-mondai { padding: 10px 12px; }
  .view-exam .ex-instr { font-size: 0.94rem; }
  .view-exam .ex-passage { padding: 16px 14px; }
  .view-exam .ex-passage.kind-info { padding: 26px 8px 14px; }
  .view-exam .ex-passage .rd-flyer { padding: 16px 14px 18px; }
  .view-exam .ex-gate { padding: 20px 16px; }
  .view-exam .ex-gate-stats strong { font-size: 1.3rem; }
  .view-exam .ex-hist { gap: 12px; padding: 12px; }
  .view-exam .ex-hist-pct { min-width: 72px; }
  .view-exam .ex-sec-table { padding: 4px 14px; }
  .view-exam .ex-slot { width: 2em; }
  .view-exam .ex-slots { gap: 4px; margin: 0 4px; }
}

/* ---------- 文章の文法: ช่องว่างในบทความ ---------- */
.view-exam .ex-tg-title { margin: 0 0 10px; text-align: center; font-family: var(--font-jp); font-size: 1.1rem; }
.view-exam .ex-blank {
  display: inline-grid; place-items: center; min-width: 2.4em; height: 1.5em; margin: 0 3px; padding: 0 6px; vertical-align: 0.05em;
  border: 1.5px solid var(--ink); border-radius: 4px; background: var(--surface); color: var(--ink);
  font-family: var(--font-jp); font-weight: 800; font-size: 0.9em; line-height: 1; font-variant-numeric: tabular-nums;
}
.view-exam .ex-blank.sm { min-width: 2em; height: 1.6em; margin: 0 8px 0 0; font-size: 0.95rem; }

/* ---------- การฟัง: คำถามย่อย / ตัวเลือกที่เป็นเสียง ---------- */
.view-exam .ex-subq { margin-top: 6px; font-size: 1.02rem; line-height: 1.9; }
.view-exam .ex-subq-no { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--surface-2); font-weight: 700; font-size: 0.9rem; }
.view-exam .ex-choices.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.view-exam .ex-choice.audio { justify-content: center; padding: 10px 8px; }
.view-exam .ex-choice.audio .ex-num { width: 30px; height: 30px; font-size: 0.95rem; }
.view-exam .ex-audio-note { margin: 8px 0 0; }
.view-exam .ex-audio-note .ex-linkbtn { color: var(--indigo); font-size: inherit; text-decoration: underline; }

/* ---------- หน้ารวม: จำนวนในคลังเทียบกับข้อสอบจริง ---------- */
.view-exam .ex-chip small { color: var(--warn); font-size: 0.75rem; font-weight: 600; }
.view-exam .ex-chip.none { border-style: dashed; color: var(--muted); }
.view-exam .ex-chip.none b { color: var(--muted); }
.view-exam .ex-short { color: var(--warn); font-weight: 600; white-space: nowrap; }
.view-exam .ex-action .btn-row .btn-lg small { font-weight: 500; font-size: 0.78rem; margin-left: 4px; }

/* ---------- โหมดสอบ: ซ่อนเมนูกันออกจากหน้าโดยไม่ตั้งใจ ---------- */
body.ex-focus .sidebar, body.ex-focus .scrim, body.ex-focus .topbar-level, body.ex-focus .menu-btn { display: none; }
body.ex-focus .main-col { margin-left: 0; }
body.ex-focus .topbar .brand { pointer-events: none; }

/* ---------- ชื่อไทยเป็นหลัก + ป้ายญี่ปุ่นเล็ก ---------- */
.view-exam .ex-ja-tag {
  display: inline-block; font-family: var(--font-jp); font-size: 0.74rem; font-weight: 500; color: var(--muted);
  padding: 0 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; line-height: 1.6;
}
.view-exam .ex-sec-name small[lang="ja"], .view-exam .ex-score-name small[lang="ja"], .view-exam .ex-gscore-name small[lang="ja"] { font-family: var(--font-jp); }
.view-exam .ex-mondai-type { color: var(--text); font-size: 0.9rem; }
.view-exam .ex-stat { font-size: 1.05rem; margin: 0 0 4px; }
.view-exam .ex-stat b { font-size: 1.3rem; color: var(--text); font-variant-numeric: tabular-nums; }
.view-exam .ex-time-note { margin: 0 0 10px; }
.view-exam .ex-action .btn-row .btn-lg { min-height: 48px; }

/* ---------- บอกตามจริง: คลังที่ยังไม่เคยเห็น / ชุดที่มีข้อเคยเห็น ---------- */
.view-exam .ex-fresh { margin: 0 0 12px; line-height: 1.6; }
.view-exam .ex-fresh:not(.warn) { color: var(--text); }
.view-exam .ex-fresh b { font-variant-numeric: tabular-nums; }
.view-exam .ex-fresh-label { font-weight: 700; margin-right: 2px; }
.view-exam .ex-verdict .ex-fresh { margin: 10px 0 0; }
.view-exam .ex-gate .ex-fresh.warn { display: block; margin: 0 0 14px; }
/* หน้าก่อนเริ่มแต่ละส่วน: ระหว่างสอบ ปุ่ม "เริ่มส่วนที่ n" ติดขอบล่างของจอ (style.css ทำ .sticky-actions ให้ติดขอบล่าง)
   อยู่ในการ์ดจึงใช้พื้นการ์ดและยืดเต็มความกว้างการ์ด (ลบ padding ของ .ex-gate) */
body.in-session .view-exam .ex-gate .ex-gate-go {
  margin: 4px -28px -26px; padding-left: 28px; padding-right: 28px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
@media (max-width: 520px) {
  body.in-session .view-exam .ex-gate .ex-gate-go { margin: 4px -16px -20px; padding-left: 16px; padding-right: 16px; }
  body.in-session .view-exam .ex-gate .ex-gate-go .btn-primary { flex: 1; }
}
.view-exam .pill.ex-seen-pill { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); }

/* ---------- ส่วนท้ายหน้าจบรอบ (finishFooter ของเปลือกแอป) ---------- */
.view-exam .ex-finish { max-width: 820px; margin: 0 0 6px; }
.view-exam .finish .ex-finish { margin: 0; }

/* ---------- ฝึกตามประเภท: ปุ่มข้อถัดไปติดขอบล่างของจอ (ไม่ต้องเลื่อนหาปุ่ม) ---------- */
/* --tabbar-h = ความสูงแถบล่างบนมือถือ (โหมดรอบฝึกของเปลือกแอปตั้งเป็น 0) */
.view-exam .ex-pnext {
  position: sticky; bottom: var(--tabbar-h, 0px); z-index: 5;
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
body.in-session .view-exam .ex-pnext { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
/* คำใบ้ก่อนตอบ: คีย์บอร์ด = .kbd-hint (style.css ซ่อนบนจอสัมผัส) · จอสัมผัส = .ex-touch-hint */
.view-exam .ex-touch-hint { display: none; }
@media (hover: none) and (pointer: coarse) { .view-exam .ex-touch-hint { display: inline; } }
@media (max-width: 520px) {
  .view-exam .ex-pnext .btn-primary { flex: 1; min-height: 48px; }
  .view-exam .ex-practice .session-top { gap: 8px 10px; }
}
/* จอเตี้ย (มือถือแนวตั้งราคาประหยัด 360×640): ลดระยะห่างให้คำถาม+ตัวเลือก+ปุ่มอยู่ในจอเดียว */
@media (max-height: 700px) and (max-width: 760px) {
  .view-exam .ex-practice { gap: 10px; }
  .view-exam .ex-practice .ex-mondai { padding: 8px 10px; }
  .view-exam .ex-practice .ex-instr { font-size: 0.86rem; line-height: 1.6; margin: 4px 0 0; }
  .view-exam .ex-practice .ex-instr-th { font-size: 0.8rem; margin: 2px 0 0; }
  .view-exam .ex-pcard .ex-q { padding: 8px 8px 4px; }
  .view-exam .ex-pnext { padding: 6px 8px 8px; }
}
/* ===== css/views/placement.css ===== */
/* สไตล์เฉพาะหน้า placement (แบบทดสอบวัดระดับ) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืดอัตโนมัติ */

/* ---------- หน้าแนะนำ ---------- */
.view-placement .pl-intro {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 26px 28px;
}
.view-placement .pl-intro-lead { font-size: 1.06rem; margin-bottom: 16px; }
.view-placement .pl-facts { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.view-placement .pl-facts li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.95rem; }
.view-placement .pl-facts svg {
  flex-shrink: 0; width: 34px; height: 34px; padding: 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.view-placement .pl-facts b { margin-right: 4px; }
.view-placement .pl-note { margin: -4px 0 16px; padding-left: 12px; border-left: 3px solid var(--border-strong); }

/* บันไดระดับ N5 → N1 */
.view-placement .pl-ladder { display: flex; align-items: flex-end; gap: 8px; height: 200px; }
.view-placement .pl-rung {
  flex: 1; display: flex; justify-content: center; padding-top: 10px; border-radius: 12px 12px 6px 6px;
  font-weight: 800; font-size: 0.95rem; font-variant-numeric: tabular-nums; color: var(--accent-ink);
}
.view-placement .pl-rung.r0 { height: 26%; background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); color: var(--accent); }
.view-placement .pl-rung.r1 { height: 42%; background: color-mix(in srgb, var(--accent) 40%, var(--surface-2)); color: var(--accent); }
.view-placement .pl-rung.r2 { height: 60%; background: color-mix(in srgb, var(--accent) 60%, var(--surface-2)); }
.view-placement .pl-rung.r3 { height: 80%; background: color-mix(in srgb, var(--accent) 80%, var(--surface-2)); }
.view-placement .pl-rung.r4 { height: 100%; background: var(--accent); }
.view-placement .pl-ladder-cap { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.8rem; color: var(--muted); }

.view-placement .pl-resume,
.view-placement .pl-last { display: flex; align-items: center; gap: 14px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-placement .pl-resume { justify-content: space-between; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.view-placement .pl-last { margin: 16px 0 0; }
.view-placement .pl-last-badge {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
  background: var(--indigo-soft); color: var(--indigo); font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums;
}
.view-placement .pl-last-body { flex: 1 1 180px; min-width: 0; }
.view-placement .pl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.view-placement .pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- ระหว่างทำแบบทดสอบ ---------- */
.view-placement .pl-track {
  list-style: none; padding: 0; margin: 4px auto 12px; max-width: 720px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px;
}
.view-placement .pl-step {
  display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 0; border-radius: 10px;
  background: var(--surface-2); color: var(--faint); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
}
.view-placement .pl-step svg { width: 15px; height: 15px; }
.view-placement .pl-step.done { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.view-placement .pl-step.fail { background: var(--bad-soft); color: var(--bad); }
.view-placement .pl-step.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* ระดับที่ยังไม่มีข้อสอบในแอป */
.view-placement .pl-step.na { background: transparent; border-style: dashed; border-color: var(--border-strong); color: var(--faint); }
/* ข้อความสำหรับโปรแกรมอ่านหน้าจอเท่านั้น */
.view-placement .pl-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.view-placement .session-top { max-width: 720px; margin-left: auto; margin-right: auto; }
.view-placement .pl-card { max-width: 720px; margin: 0 auto; padding: 22px 24px; }
.view-placement .pl-card:focus, .view-placement .pl-card:focus-visible { outline: none; }
.view-placement .pl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.view-placement .pl-card .q-label { margin-bottom: 6px; }
.view-placement .pl-q {
  font-size: 1.3rem; line-height: 2.3; margin: 4px 0 18px; padding: 10px 16px; border-radius: 12px;
  background: var(--surface-2); overflow-wrap: anywhere;
}
.view-placement .pl-q rt { font-size: 0.48em; }
.view-placement .pl-word { text-align: center; margin: 8px 0 20px; }
.view-placement .pl-word-jp { font-family: var(--font-display); font-size: clamp(2.2rem, 1.7rem + 2.5vw, 3.2rem); font-weight: 600; line-height: 1.25; }
.view-placement .pl-word-kana { color: var(--muted); font-size: 1.1rem; }

.view-placement .pl-choices .choice { font-size: 1.12rem; line-height: 1.9; padding: 10px 14px; min-width: 0; }
.view-placement .pl-choices.text-choices .choice { font-size: 1rem; line-height: 1.5; }
.view-placement .pl-ch { min-width: 0; overflow-wrap: anywhere; }
.view-placement .pl-choices .choice.picked {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.view-placement .pl-choices .choice.picked kbd { border-color: var(--accent); color: var(--accent); }
.view-placement .pl-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.view-placement .pl-between { max-width: 560px; margin: 8px auto 0; text-align: center; padding: 30px 24px; }
.view-placement .pl-between h2 { margin-top: 6px; }
.view-placement .pl-between-mark {
  display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
}
.view-placement .pl-between-mark svg { width: 28px; height: 28px; }

.modal .pl-modal-title { margin-top: 0; padding-right: 30px; }

/* ---------- หน้าผล ---------- */
.view-placement .pl-hero { display: flex; align-items: center; gap: 24px; padding: 24px; }
.view-placement .pl-hero-level {
  display: grid; justify-items: center; align-content: center; gap: 2px; flex-shrink: 0; width: 150px; min-height: 130px;
  padding: 16px 10px; border-radius: var(--radius); background: var(--accent-soft);
}
.view-placement .pl-hero-label { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.view-placement .pl-hero-badge { font-size: 3.4rem; font-weight: 800; line-height: 1.05; color: var(--accent); font-variant-numeric: tabular-nums; }
.view-placement .pl-hero-text { flex: 1; min-width: 0; }
.view-placement .pl-hero-head { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.view-placement .pl-hero-text .notice { margin-bottom: 12px; }
.view-placement .pl-hero-text .btn-row { margin-top: 12px; }

.view-placement .pl-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }

.view-placement .pl-table-card { padding: 6px 16px 10px; }
.view-placement .pl-table { width: 100%; border-collapse: collapse; }
.view-placement .pl-table th, .view-placement .pl-table td { padding: 9px 6px; text-align: left; vertical-align: middle; border-top: 1px solid var(--border); }
.view-placement .pl-table thead th { border-top: none; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding-top: 10px; padding-bottom: 6px; }
.view-placement .pl-table tbody th { width: 56px; }
.view-placement .pl-lv {
  display: inline-grid; place-items: center; width: 42px; height: 32px; border-radius: 9px;
  background: var(--surface-2); font-weight: 800; font-size: 0.92rem; font-variant-numeric: tabular-nums;
}
.view-placement .pl-table tr.rec .pl-lv { background: var(--accent); color: var(--accent-ink); }
.view-placement .pl-score { display: flex; align-items: center; gap: 10px; }
.view-placement .pl-score .progress { flex: 1; min-width: 40px; height: 6px; }
.view-placement .pl-num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.4em; }
.view-placement .pl-status { white-space: nowrap; }
.view-placement .pl-status .pill + .pill { margin-left: 4px; }
.view-placement .pl-table-foot { margin: 6px 0 0; }
.view-placement .progress.pl-good > span { background: var(--ok); }
.view-placement .progress.pl-weak > span { background: var(--bad); }

.view-placement .pl-types { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.view-placement .pl-types li { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) 2.6em; align-items: center; gap: 10px; font-size: 0.92rem; }
.view-placement .pl-types .progress { height: 6px; }
.view-placement .pl-type-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.view-placement .pl-advice { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.view-placement .pl-advice li { display: grid; gap: 4px; padding-left: 14px; border-left: 3px solid var(--accent-soft); }
.view-placement .pl-advice li:first-child { border-left-color: var(--accent); }
.view-placement .pl-advice li > span:not(.pl-links) { font-size: 0.93rem; color: var(--muted); }
.view-placement .pl-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.view-placement .pl-review { display: grid; gap: 12px; }
.view-placement .pl-rv { padding: 18px 20px; }
.view-placement .pl-rv .pl-q { font-size: 1.15rem; margin-bottom: 12px; }
.view-placement .pl-rv .pl-word { margin: 4px 0 12px; }
.view-placement .pl-rv .pl-word-jp { font-size: 2rem; }
.view-placement .pl-rv .choice { cursor: default; font-weight: 500; font-size: 1.02rem; padding: 6px 12px; justify-content: space-between; }
.view-placement .pl-rv .choice:hover { border-color: var(--border-strong); background: var(--surface); }
.view-placement .pl-rv .choice.correct, .view-placement .pl-rv .choice.correct:hover { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.view-placement .pl-rv .choice.incorrect, .view-placement .pl-rv .choice.incorrect:hover { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.view-placement .pl-tag { flex-shrink: 0; font-size: 0.72rem; font-weight: 700; line-height: 1.6; padding: 0 8px; border-radius: 999px; background: var(--surface); }
.view-placement .pl-explain { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--border-strong); font-size: 0.93rem; color: var(--muted); line-height: 1.9; }
.view-placement .pl-explain b { color: var(--text); }
.view-placement .pl-ex { display: block; margin-top: 4px; }
.view-placement .pl-perfect { text-align: center; color: var(--ok); font-weight: 600; }
.view-placement .pl-bottom { margin-top: 28px; }

/* ---------- จอสัมผัส: ไม่มีแป้นพิมพ์ ซ่อนป้ายคีย์ลัด ---------- */
@media (hover: none) and (pointer: coarse) {
  .view-placement .pl-choices .choice kbd { display: none; }
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 860px) {
  .view-placement .pl-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .view-placement .pl-intro { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px; }
  .view-placement .pl-ladder-wrap { order: -1; }
  .view-placement .pl-ladder { height: 110px; }
  .view-placement .pl-hero { flex-direction: column; align-items: stretch; text-align: center; padding: 20px; }
  .view-placement .pl-hero-level { width: auto; min-height: 0; }
  .view-placement .pl-hero-text .btn-row { justify-content: center; }
}
@media (max-width: 520px) {
  .view-placement .pl-card { padding: 16px 14px; }
  .view-placement .pl-q { font-size: 1.15rem; padding: 8px 12px; }
  .view-placement .pl-step { font-size: 0.78rem; padding: 5px 0; }
  .view-placement .pl-step svg { display: none; }
  .view-placement .pl-actions .btn-primary { flex: 1; }
  .view-placement .pl-rv { padding: 14px; }
  .view-placement .pl-rv .choices { grid-template-columns: minmax(0, 1fr); }
  .view-placement .pl-types li { grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) 2.4em; font-size: 0.86rem; }
  .view-placement .pl-hero-badge { font-size: 2.8rem; }
  .view-placement .pl-resume .btn-row, .view-placement .pl-resume .btn,
  .view-placement .pl-last .btn { width: 100%; }
}

/* ---------- ด่านแรก: อ่านฮิรางานะได้หรือยัง ---------- */
.view-placement .pl-gate { margin-bottom: 16px; display: grid; gap: 10px; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.view-placement .pl-gate.warn { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.view-placement .pl-gate h2 { margin: 0; font-size: 1.2rem; }
.view-placement .pl-gate p { margin: 0; }
.view-placement .pl-kana-check { display: flex; flex-wrap: wrap; gap: 8px; }
.view-placement .pl-kc { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.view-placement .pl-kc summary {
  list-style: none; cursor: pointer; padding: 8px 16px; min-height: 44px; display: flex; align-items: center;
  font-size: 1.4rem; font-weight: 600; font-family: var(--font-display);
}
.view-placement .pl-kc summary::-webkit-details-marker { display: none; }
.view-placement .pl-kc[open] { border-color: var(--ok); background: var(--ok-soft); }
.view-placement .pl-kc-ans { display: block; padding: 0 16px 8px; font-size: 0.9rem; color: var(--text); }
.view-placement .pl-gate .btn-lg { white-space: normal; min-height: 48px; }
@media (max-width: 520px) {
  .view-placement .pl-gate .btn-row .btn { flex: 1 1 100%; }
}

/* ---------- ระหว่างทำ: ปุ่ม "ไม่รู้/ข้อถัดไป" ติดขอบล่างของจอ (ไม่ต้องเลื่อนหาปุ่ม) ---------- */
/* --tabbar-h = ความสูงแถบล่างบนมือถือ (โหมดรอบฝึกของเปลือกแอปตั้งเป็น 0) */
.view-placement .pl-actions {
  position: sticky; bottom: var(--tabbar-h, 0px); z-index: 5;
  margin: 18px -24px -22px; padding: 10px 24px 12px;
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
body.in-session .view-placement .pl-actions { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 520px) {
  .view-placement .pl-actions { margin: 14px -14px -16px; padding: 8px 14px 10px; }
  .view-placement .pl-actions .btn { min-height: 44px; }
}
/* จอเตี้ย (เช่น 360×640): ลดระยะห่าง ให้คำถาม ตัวเลือก และปุ่มอยู่ในจอเดียว */
@media (max-height: 700px) and (max-width: 760px) {
  .view-placement .session-top { margin-bottom: 4px; }
  .view-placement .pl-track { margin: 0 auto 8px; }
  .view-placement .pl-step { padding: 3px 0; }
  .view-placement .pl-card { padding: 12px 14px 16px; }
  .view-placement .pl-tags { margin-bottom: 4px; }
  .view-placement .pl-card .q-label { margin-bottom: 2px; font-size: 0.9rem; }
  .view-placement .pl-q { line-height: 2; margin: 2px 0 10px; padding: 6px 10px; }
  .view-placement .pl-word { margin: 4px 0 10px; }
  .view-placement .pl-choices { gap: 8px; }
  .view-placement .pl-choices .choice { padding: 6px 12px; line-height: 1.7; }
  .view-placement .pl-actions { margin: 10px -14px -16px; padding: 6px 14px 8px; }
}

/* ---------- ส่วนท้ายหน้าผล (finishFooter ของเปลือกแอป) ---------- */
.view-placement .pl-finish { max-width: 720px; margin: 0 auto; }
/* ===== css/views/search.css ===== */
/* สไตล์เฉพาะหน้า search (ค้นหา / พจนานุกรม) */

/* ---------- ช่องค้นหา (ติดด้านบนขณะเลื่อนดูผล) ---------- */
.sr-bar {
  position: sticky; top: 0; z-index: 6; margin: 0 -6px 12px; padding: 8px 6px 10px;
  background: var(--bg);
}
@media (max-width: 1023px) {
  .sr-bar { top: 57px; }
}
.sr-field { position: relative; }
.sr-field > svg {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; color: var(--muted); pointer-events: none;
}
.sr-field input[type="search"] {
  width: 100%; min-width: 0; font-size: 1.3rem; line-height: 1.4; padding: 14px 52px 14px 52px;
  border-radius: 18px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.sr-field input[type="search"]::placeholder { color: var(--muted); font-size: 1.05rem; }
.sr-field input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.sr-field input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.sr-field:focus-within > svg { color: var(--accent); }
.sr-clear { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }

.sr-nowrap { white-space: nowrap; }
/* ซ่อนจากตา แต่โปรแกรมอ่านหน้าจอยังอ่านได้ (ประกาศจำนวนผลลัพธ์) */
.sr-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- สรุปผล / แท็บหมวด ---------- */
.sr-summary { margin: 0 2px 12px; color: var(--muted); font-size: 0.95rem; }
.sr-summary b { color: var(--text); }
.sr-summary .jp { color: var(--text); font-weight: 600; }
.sr-tabs { margin-bottom: 4px; max-width: 100%; }
.sr-tabs button { white-space: nowrap; }
.sr-n { font-size: 0.82em; font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 2px; }
.sr-tabs button.on .sr-n { color: inherit; }

/* โฟกัสด้วยคีย์บอร์ดแล้วรายการต้องไม่ถูกช่องค้นหาที่ติดด้านบนบัง */
#sr-results button, #sr-results a { scroll-margin: 110px 0 24px; }
@media (max-width: 1023px) {
  #sr-results button, #sr-results a { scroll-margin-top: 150px; }
}

.view-search mark {
  background: color-mix(in srgb, var(--warn) 26%, transparent); color: inherit;
  border-radius: 3px; padding: 0 1px;
}

/* ---------- หมวดผลลัพธ์ ---------- */
.sr-group { margin-top: 22px; }
.sr-group-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 1.15rem; }
.sr-count { font-size: 0.85rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sr-more { margin-top: 10px; }
.sr-more .muted { font-weight: 500; }
.sr-words, .sr-kanji-grid, .sr-glist { list-style: none; margin: 0; padding: 0; }

/* คำศัพท์ */
.sr-words { display: grid; gap: 8px; }
.sr-word {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; grid-template-areas: "main th side";
  align-items: center; gap: 2px 18px; padding: 10px 10px 10px 16px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sr-word:hover { border-color: var(--accent); }
.sr-word:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sr-word-main { grid-area: main; min-width: 0; }
.sr-word-jp { display: flex; align-items: center; gap: 6px; font-size: 1.4rem; font-weight: 600; line-height: 1.35; }
.sr-word-jp .jp { font-family: var(--font-display); }
.sr-word-link {
  border: none; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer;
  text-align: left; min-width: 0; overflow-wrap: anywhere;
}
.sr-word-link:focus-visible { outline-offset: 3px; border-radius: 4px; }
.sr-word-read { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; color: var(--muted); font-size: 0.92rem; }
.sr-alt { font-size: 0.82rem; }
.sr-word-th { grid-area: th; min-width: 0; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.sr-pos { display: inline-block; margin-left: 8px; font-size: 0.78rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.sr-word-side { grid-area: side; display: flex; align-items: center; gap: 2px; }

@media (max-width: 640px) {
  .sr-word {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main side" "th th";
    padding: 10px 6px 12px 14px; gap: 2px 8px;
  }
  .sr-word-jp { font-size: 1.3rem; }
}

/* คันจิ */
.sr-kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.sr-kanji {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; height: 100%;
  padding: 12px 12px 12px 12px; text-align: left; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sr-kanji:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sr-k-ch {
  width: 62px; height: 62px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px;
  background: var(--surface-2); font-family: var(--font-display); font-size: 2.5rem; line-height: 1; font-weight: 600;
}
.sr-k-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.sr-k-th { font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sr-k-read { display: flex; align-items: baseline; gap: 6px; font-size: 0.88rem; color: var(--muted); min-width: 0; }
.sr-k-read .jp { overflow-wrap: anywhere; }
.sr-k-read .jp > span { white-space: nowrap; }
.sr-k-read .hit { color: var(--accent); font-weight: 700; }
.sr-k-tag {
  flex-shrink: 0; padding: 0 6px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; line-height: 1.6;
  background: var(--surface-2); color: var(--muted);
}
.sr-k-side { align-self: flex-start; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.sr-k-side .lvl-dot { margin-right: 4px; }

/* ไวยากรณ์ */
.sr-glist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.sr-glist .lesson-num { font-size: 0.8rem; background: var(--accent-soft); color: var(--accent); }
.sr-glist .lesson-item.done .lesson-go { color: var(--ok); }
@media (max-width: 400px) {
  .sr-glist { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- ก่อนพิมพ์: ประวัติ วิธีค้น ขอบเขตข้อมูล ---------- */
.sr-sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.sr-sub-head h2 { margin: 0; font-size: 1.05rem; }
.sr-recent { margin-bottom: 8px; }
.sr-ways-title { font-size: 1.05rem; margin: 22px 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sr-recent + section .sr-ways-title { margin-top: 26px; }
.sr-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sr-way { display: grid; gap: 6px; align-content: start; padding: 16px 18px; }
.sr-way-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.sr-way-glyph {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  background: var(--indigo-soft); color: var(--indigo); font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
}
.sr-way p { margin: 0 0 4px; font-size: 0.9rem; color: var(--muted); }
.sr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sr-chip {
  padding: 4px 13px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.sr-chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sr-cover { margin: 22px 0 4px; line-height: 1.8; }
.sr-keys { line-height: 2; }
/* คีย์ลัดไม่มีประโยชน์บนจอสัมผัส */
@media (hover: none), (pointer: coarse) {
  .sr-keys { display: none; }
}

@media (max-width: 520px) {
  .sr-bar { margin: 0 -4px 10px; padding: 6px 4px 8px; }
  .sr-field > svg { left: 15px; width: 20px; height: 20px; }
  .sr-field input[type="search"] { font-size: 1.15rem; padding: 12px 46px 12px 44px; border-radius: 16px; }
  .sr-field input[type="search"]::placeholder { font-size: 0.98rem; }
  .sr-clear { right: 5px; }
  .sr-way { padding: 14px 16px; }
  /* แท็บหมวดเรียงแถวเดียว เลื่อนซ้าย-ขวาได้ถ้าไม่พอ */
  .sr-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 0; }
  .sr-tabs::-webkit-scrollbar { display: none; }
  .seg.sr-tabs button { flex: 1 0 auto; padding: 6px 5px; font-size: 0.8rem; }
  .sr-tabs .sr-n { margin-left: 1px; }
  .sr-tabs [data-tab="all"] .sr-n { display: none; } /* จำนวนรวมมีในบรรทัดสรุปแล้ว */
}
@media (max-width: 380px) {
  .seg.sr-tabs button { padding: 6px 3px; }
}

/* หัวหน้าเพจ: ช่องค้นหาอยู่ใต้หัวข้อทันที — ลดช่องว่าง */
.view-search .page-head { margin-bottom: 8px; }
.sr-group-head .help-wrap { align-self: center; }
.sr-tabs button { min-height: 40px; }
@media (max-width: 520px) {
  .view-search .page-desc { font-size: 0.92rem; }
  .sr-field input[type="search"] { font-size: 1.15rem; padding-top: 12px; padding-bottom: 12px; }
}
/* ===== css/views/kana.css ===== */
/* หน้าตัวอักษร (#/kana): คำแนะนำทีละขั้น + ป๊อปอัปเรียนทีละแถว — ใช้ตัวแปรสีเท่านั้น */
.kn-guide { margin-bottom: 16px; display: grid; gap: 14px; }
.kn-guide h2 { margin: 0 0 8px; font-size: 1.1rem; }
.kn-guide-top { display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap; }
.kn-guide-top > div:first-child { flex: 1 1 360px; min-width: 0; }
.kn-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kn-steps li { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.kn-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.85rem;
}
.kn-progress { flex: 0 1 220px; display: grid; gap: 4px; align-content: start; }
.kn-progress-num { font-size: 0.95rem; color: var(--muted); }
.kn-progress-num b { font-size: 1.6rem; color: var(--text); font-variant-numeric: tabular-nums; }
.kn-actions .btn-primary .jp { font-size: 1.15em; }
.kn-toolbar { gap: 8px 18px; }
.kn-legend { margin-top: 14px; }

/* ป๊อปอัปเรียนทีละแถว */
.kn-row h2 { margin: 0 0 4px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kn-row-chars { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; margin: 12px 0 16px; }
.kn-row-ch {
  display: grid; justify-items: center; gap: 2px; padding: 10px 4px; min-height: 96px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.kn-row-ch:hover { border-color: var(--accent); }
.kn-row-ch.on { border-color: var(--accent); background: var(--sel-bg); box-shadow: 0 0 0 3px var(--accent-soft); }
.kn-row-th { font-size: 0.78rem; color: var(--muted); }
.kn-row-note { margin: 12px 0 0; }

/* เสียงที่ไม่มีในภาษาไทย (แถว が ざ じ/じゃ + ぢ づ): ป้าย ! มุมซ้ายบนของช่อง + กล่องอธิบายใต้ตาราง */
.kana-cell.no-th { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.kana-warn {
  position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); font-size: 0.72rem; font-weight: 700; line-height: 1;
}
.kana-warn-inline { position: static; display: inline-grid; vertical-align: middle; }
.kn-warn-box {
  margin-top: 12px; max-width: 680px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); border-left: 4px solid var(--warn); color: var(--text); display: grid; gap: 8px; justify-items: start;
}
.kn-warn-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kn-warn-box ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; line-height: 1.6; }
.kn-warn-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.kn-warn-link svg { width: 16px; height: 16px; }
.kn-warn-note { margin-top: 6px; line-height: 1.6; }

@media (max-width: 640px) {
  .kn-guide { padding: 16px; }
  .kn-progress { flex-basis: 100%; }
  .kn-actions .btn { min-height: 44px; flex: 1 1 calc(50% - 8px); }
  .kn-actions .btn-primary { flex-basis: 100%; }
  .kn-seg button { min-height: 44px; }
  .kn-row .btn-row .btn { min-height: 44px; flex: 1 1 100%; }
  .kana-warn { top: 4px; left: 4px; width: 16px; height: 16px; font-size: 0.66rem; }
  /* พื้นที่แตะ 44px โดยไม่ดันระยะบรรทัด (margin ติดลบชดเชยความสูงที่เพิ่ม) */
  .kn-warn-link { min-height: 44px; margin-block: -10px; vertical-align: middle; }
  .kn-warn-box .btn { min-height: 44px; }
}
.kana-cell.no-th:hover { border-color: var(--accent); }
/* ===== css/views/vocab.css ===== */
/* หน้าคำศัพท์ (#/vocab): หน่วยแนะนำ, การ์ดหมวดพร้อมชิปหน่วย, ขั้นตอน 3 ขั้นในหน่วย — ใช้ตัวแปรสีเท่านั้น */

/* ---------- หน้ารวม ---------- */
.vc-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); margin-bottom: 12px;
}
.vc-hero-main { flex: 1 1 340px; min-width: 0; display: grid; gap: 6px; justify-items: start; }
.vc-hero h2 { margin: 0; font-size: 1.25rem; }
.vc-hero-done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); box-shadow: none; }
.vc-hero-done h2 { color: var(--ok); display: flex; align-items: center; gap: 6px; }
.vc-hero-prog, .vc-topic-prog { display: grid; grid-template-columns: minmax(80px, 1fr) auto; gap: 10px; align-items: center; width: 100%; }
.vc-preview { margin: 0; color: var(--muted); font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.vc-stats { margin: 0 0 12px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.vc-list-toolbar .search-box { flex: 1 1 260px; }

.vc-more { font-size: 0.92rem; }
.vc-more > summary { cursor: pointer; color: var(--indigo); font-weight: 600; padding: 6px 2px; list-style-position: inside; }
.vc-more[open] { flex-basis: 100%; }
.vc-more-body { padding: 8px 0 2px; display: grid; gap: 6px; justify-items: start; }
.vc-more-body.btn-row { display: flex; }
.vc-more-body p { margin: 0; }

.vc-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.vc-topic { display: grid; gap: 8px; align-content: start; padding: 16px 18px; }
.vc-topic.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.vc-topic.has-next { border-color: var(--accent); }
.vc-topic-h { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vc-topic-h .pill svg { width: 13px; height: 13px; }
.vc-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-top: 2px; }
.vc-part {
  display: grid; gap: 1px; padding: 7px 10px; min-height: 44px; border-radius: 10px; text-decoration: none; color: var(--text);
  border: 1px solid var(--border-strong); background: var(--surface); transition: border-color 0.15s, background 0.15s;
}
.vc-part:hover { border-color: var(--accent); background: var(--surface-2); }
.vc-part-n { font-weight: 700; font-size: 0.92rem; display: inline-flex; align-items: center; gap: 4px; }
.vc-part-n svg { width: 14px; height: 14px; color: var(--ok); }
.vc-part-sub { font-size: 0.78rem; color: var(--muted); }
.vc-part.done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.vc-part.next { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vc-part.next .vc-part-sub { color: var(--accent-ink); }

/* ---------- หน้าหน่วย: 3 ขั้น ---------- */
.vc-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.vc-step {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border);
}
.vc-step.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.vc-step-num {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); font-weight: 700; color: var(--muted);
}
.vc-step-num svg { width: 16px; height: 16px; }
.vc-step.current .vc-step-num { background: var(--accent); color: var(--accent-ink); }
.vc-step.done .vc-step-num { background: var(--ok-soft); color: var(--ok); }
.vc-step-body { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.vc-step-title { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vc-step-desc { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
.vc-toolbar { gap: 8px 18px; scroll-margin-top: 80px; }
.vc-next { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-top: 18px; }

@media (max-width: 900px) {
  .vc-steps { grid-template-columns: minmax(0, 1fr); }
  .vc-step-body { grid-template-columns: minmax(0, 1fr) auto; align-items: center; justify-items: stretch; width: 100%; }
  .vc-step-body > .btn { grid-column: 2; grid-row: 1 / span 2; }
  .vc-step { flex: 1; }
}
@media (max-width: 640px) {
  .vc-topics { grid-template-columns: minmax(0, 1fr); }
  .vc-hero .btn-lg, .vc-next .btn-lg { flex: 1 1 100%; }
  .vc-step { padding: 12px; }
  .vc-step-body { grid-template-columns: minmax(0, 1fr); }
  .vc-step-body > .btn { grid-column: auto; grid-row: auto; justify-self: start; min-height: 44px; }
  /* ขั้นที่ไม่ใช่ขั้นต่อไป: ย่อเหลือหัวข้อ + ปุ่มในบรรทัดเดียว ลดความยาวหน้า */
  .vc-step:not(.current) { padding: 8px 12px; align-items: center; }
  .vc-step:not(.current) .vc-step-desc { display: none; }
  .vc-step:not(.current) .vc-step-body { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .vc-step:not(.current) .vc-step-body > .btn { grid-column: 2; grid-row: 1; }
  .vc-more > summary { min-height: 44px; display: flex; align-items: center; }
  .pager .btn { min-height: 44px; white-space: normal; text-align: left; }
}
/* ===== css/views/kanji.css ===== */
/* หน้าคันจิ (#/kanji): ชุดที่แนะนำ, แถบเครื่องมือแบบย่อ — ใช้ตัวแปรสีเท่านั้น */
.kj-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); margin-bottom: 14px;
}
.kj-hero-main { flex: 1 1 340px; min-width: 0; display: grid; gap: 8px; justify-items: start; }
.kj-hero h2 { margin: 0; font-size: 1.25rem; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kj-hero-done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); box-shadow: none; }
.kj-hero-done h2 { color: var(--ok); align-items: center; }
.kj-hero-sample { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.kj-mini {
  display: grid; justify-items: center; min-width: 46px; padding: 4px 6px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.kj-mini [lang="ja"] { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.2; font-weight: 600; }
.kj-mini small { font-size: 0.7rem; color: var(--muted); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kj-hero-actions { display: grid; gap: 8px; justify-items: stretch; }
.kj-toolbar { gap: 8px 18px; }
.kj-toolbar .legend { margin: 0; align-items: center; }
.kj-more > summary { cursor: pointer; color: var(--indigo); font-weight: 600; font-size: 0.92rem; padding: 6px 2px; }
.kj-more[open] { flex-basis: 100%; }
.kj-more-body { padding-top: 8px; }
.kanji-unit { scroll-margin-top: 80px; }
.kj-next .section-head h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .kj-hero-actions { flex: 1 1 100%; }
  .kj-hero-actions .btn { min-height: 44px; white-space: normal; }
  .kj-more > summary { min-height: 44px; display: flex; align-items: center; }
  .kanji-unit .section-head .btn-row { width: 100%; }
  .kanji-unit .section-head .btn { min-height: 44px; flex: 1 1 0; }
  .kanji-tile { min-height: 88px; }
}

/* ส่วนประกอบ + คำช่วยจำ (JP.kanjiView.memoryHtml) — ใช้ในรายละเอียดคันจิ ด้านหลังแฟลชการ์ด และหน้าฝึกเขียน */
.kj-report { margin-left: auto; display: inline-flex; align-items: center; }
.kj-memory {
  display: grid; gap: 10px; margin: 0 0 18px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); text-align: left;
}
.kj-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kj-part {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); max-width: 100%;
}
.kj-part-c { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; line-height: 1.2; }
.kj-part-th { font-size: 0.88rem; color: var(--text); overflow-wrap: anywhere; }
.kj-part-res { background: var(--accent-soft); border-color: var(--accent); }
.kj-part-res .kj-part-th { font-weight: 600; }
.kj-op { color: var(--muted); font-weight: 700; padding: 0 1px; }
.kj-mn { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }
.kj-mn .help-wrap { margin-right: 6px; vertical-align: middle; }
.kj-mn-label {
  display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 999px; vertical-align: 1px;
  font-size: 0.75rem; font-weight: 700; color: var(--indigo); background: var(--indigo-soft);
}
/* แบบย่อ: ด้านหลังแฟลชการ์ด (จัดกลาง) และหน้าฝึกเขียน */
.kj-memory.compact { margin: 6px 0 0; padding: 10px 12px; gap: 8px; width: 100%; font-size: 0.92rem; }
.kj-memory.compact .kj-part-c { font-size: 1.12rem; }
.fc-back .kj-memory.compact { max-width: 460px; text-align: center; }
.fc-back .kj-memory.compact .kj-parts { justify-content: center; }
.write-info .kj-memory.compact { margin: 0; }

@media (max-width: 480px) {
  .kj-memory { padding: 10px 12px; }
}

/* ป้าย "ทดลอง" (k.beta — คันจิเพิ่มใหม่ที่ยังไม่ผ่านผู้ตรวจที่เป็นคน) */
.kj-beta {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; line-height: 1.5;
  color: var(--warn); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); vertical-align: 1px;
}
/* แถวป้าย: เป็นบล็อกธรรมดา ให้จัดชิดซ้าย/กลางตาม text-align ของกล่องที่อยู่ (รายละเอียดคันจิบนมือถือจัดกลาง) */
.kj-beta-row { margin: 2px 0 8px; line-height: 1.6; }
.kj-beta-row > * { vertical-align: middle; }
.kj-memory .kj-beta-row { margin: 0; }
.kj-beta-count { display: inline-flex; align-items: center; gap: 4px; }
.kanji-tile .kj-tile-beta {
  position: absolute; top: 5px; left: 5px; padding: 0 5px; border-radius: 999px; font-size: 0.62rem; font-weight: 700; line-height: 1.5;
  color: var(--warn); background: var(--warn-soft);
}
/* ส่วนประกอบที่เรียนในระดับสูงกว่า: "(เรียนใน N4)" */
.kj-part-lv { font-size: 0.72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* คันจิชื่อคน (ชุดพับท้ายหน้า N1) */
.kj-names { margin-top: 22px; padding: 0; overflow: hidden; }
.kj-names > summary {
  cursor: pointer; padding: 14px 16px; min-height: 44px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 700; color: var(--text);
}
.kj-names > summary { list-style: none; }
.kj-names > summary::-webkit-details-marker { display: none; }
.kj-names > summary::before {
  content: ""; width: 8px; height: 8px; flex: none; margin-right: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.kj-names[open] > summary::before { transform: rotate(45deg); }
.kj-names-title { font-size: 1.02rem; }
.kj-names-note { margin: 0 16px 12px; }
.kj-names-grid { padding: 0 16px 16px; }
.kj-names-grid:empty { display: none; }
.kj-name-tile .kanji-ch { color: var(--muted); }
/* ===== css/views/write.css ===== */
/* หน้าฝึกเขียน (#/write) — ใช้ตัวแปรสีเท่านั้น */
.wr-klevel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 16px; }
.wr-mode { display: grid; gap: 4px; }
.wr-mode .seg button[aria-pressed="true"] { font-weight: 700; }

/* โหมดมืด: ให้กรอบเขียนเป็นพื้นที่สว่างกว่าการ์ดเล็กน้อย เห็นขอบเขตชัด */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pad { background-color: var(--surface-2); }
}
:root[data-theme="dark"] .pad { background-color: var(--surface-2); }
:root[data-theme="dark"] .pad .pad-demo { background-color: var(--surface-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pad .pad-demo { background-color: var(--surface-2); }
}

@media (max-width: 760px) {
  /* จอเล็ก: กรอบเขียนต้องไม่สูงเกินจอ (เผื่อแถบบน หัวหน้า และแถบล่าง) */
  .write-pad .pad { width: min(100%, calc(100svh - 260px)); min-width: 240px; justify-self: center; }
}
@media (max-width: 640px) {
  .write-pad .btn-row .btn, .write-info .btn { min-height: 44px; }
  .write-pad .btn-row.center .btn { flex: 1 1 calc(50% - 8px); }
  .wr-seg button, .wr-klevel .seg button, .wr-mode .seg button { min-height: 44px; }
  .page-actions:has(.wr-seg) { flex: 1 1 100%; }
  .page-actions .wr-seg { display: flex; width: 100%; flex-wrap: nowrap; }
  .page-actions .wr-seg button { flex: 1 1 0; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
}
/* ===== css/views/pairs.css ===== */
/* สไตล์เฉพาะหน้า ไวยากรณ์ที่สับสน (#/pairs) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืด */

/* สีประจำรูป A / B / C / D */
.view-pairs .t0 { --pr-c: var(--accent); --pr-soft: var(--accent-soft); }
.view-pairs .t1 { --pr-c: var(--indigo); --pr-soft: var(--indigo-soft); }
.view-pairs .t2 { --pr-c: var(--ok); --pr-soft: var(--ok-soft); }
.view-pairs .t3 { --pr-c: var(--warn); --pr-soft: var(--warn-soft); }

.pr-h1-jp { font-family: var(--font-display); font-size: 0.55em; color: var(--muted); font-weight: 600; margin-left: 6px; white-space: nowrap; }

/* ป้ายรูปไวยากรณ์ "A ⇄ B" */
.pr-vs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.pr-tag {
  display: inline-flex; align-items: center; padding: 2px 12px; border-radius: 999px; font-weight: 700;
  background: var(--pr-soft); color: var(--pr-c); border: 1px solid color-mix(in srgb, var(--pr-c) 30%, transparent);
  max-width: 100%; overflow-wrap: anywhere;
}
.pr-vs-sep { color: var(--faint); font-size: 0.9em; }
.pr-letter {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 1.6em; height: 1.6em; border-radius: 7px;
  background: var(--pr-c); color: var(--surface); font-size: 0.8rem; font-weight: 800; font-family: var(--font);
  line-height: 1;
}

/* ---------- หน้ารวม ---------- */
.pr-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.pr-progress .progress { flex: 1; }
.pr-progress > span { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pr-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.pr-grid > li { display: flex; min-width: 0; }
.pr-card {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; text-decoration: none; color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.pr-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pr-card.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.pr-card.weak { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.pr-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pr-num {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums;
}
.pr-card.done .pr-num { background: var(--ok-soft); color: var(--ok); }
.pr-card .pr-vs { font-size: 1.15rem; }
.pr-card-title { font-weight: 700; font-size: 0.98rem; }
.pr-card-sum {
  font-size: 0.86rem; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pr-pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill svg { width: 12px; height: 12px; }

/* สถานะว่าง */
.pr-empty { padding: 36px 20px; }
.pr-empty-glyph {
  font-family: var(--font-display); font-size: 3.4rem; line-height: 1; width: 92px; height: 92px; margin: 0 auto 14px;
  display: grid; place-items: center; border-radius: 24px; background: var(--accent-soft); color: var(--accent);
}
.pr-empty b { color: var(--text); }
.pr-empty .btn-row { margin-top: 14px; }

/* ---------- หน้าบทเรียน ---------- */
.pr-head h1 { font-size: clamp(1.45rem, 1.15rem + 1.3vw, 2.1rem); }
.pr-hero { margin: 6px 0 10px; }
.pr-hero .pr-vs { font-size: clamp(1.3rem, 1.05rem + 1.2vw, 1.9rem); gap: 10px; }
.pr-hero .pr-tag { padding: 4px 18px; font-family: var(--font-display); }
.pr-head .lead { max-width: 860px; }
.pr-head .lead b, .pr-diff b, .pr-col b, .pr-explain b, .pr-mix-explain b { color: var(--accent); }

/* ตารางเทียบ: คอลัมน์เคียงกันบนจอกว้าง (แถวตรงกันด้วย subgrid) ซ้อนกันบนมือถือ */
.pr-compare { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.pr-col { display: grid; gap: 12px; align-content: start; padding: 0; overflow: hidden; border-top: 4px solid var(--pr-c); min-width: 0; }
.pr-col > * { padding: 0 18px; min-width: 0; }
.pr-col-head { display: flex; align-items: center; gap: 10px; padding-top: 14px; padding-bottom: 12px; background: var(--pr-soft); }
.pr-col-head h3 { margin: 0; font-size: 1.35rem; color: var(--pr-c); font-family: var(--font-display); overflow-wrap: anywhere; }
.pr-meaning { font-weight: 700; font-size: 1.02rem; }
.pr-label { display: block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 4px; }
.pr-use p { margin: 0; font-size: 0.93rem; line-height: 1.75; }
.pr-exs { padding-bottom: 16px; display: grid; gap: 8px; align-content: start; }
.pr-ex { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; border-left: 3px solid var(--pr-c); }
.pr-ex-jp { font-size: 1.12rem; line-height: 2; overflow-wrap: anywhere; }
.pr-ex-jp .icon-btn { vertical-align: middle; }
.pr-ex .romaji { font-size: 0.82rem; }
.pr-th { font-size: 0.9rem; color: var(--muted); }
.pr-hide-th .pr-th { display: none; }
.pr-col u.target { text-decoration-color: var(--pr-c); text-decoration-thickness: 2px; text-underline-offset: 4px; color: var(--pr-c); font-weight: 700; }

@media (min-width: 760px) {
  .pr-compare { grid-template-columns: repeat(min(var(--pr-n, 2), 2), minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .pr-compare { grid-template-columns: repeat(var(--pr-n, 2), minmax(0, 1fr)); }
}
@media (min-width: 760px) {
  @supports (grid-template-rows: subgrid) {
    .pr-compare { grid-auto-rows: auto; }
    .pr-col { grid-row: span 4; grid-template-rows: subgrid; gap: 12px; }
  }
}

/* จุดต่าง */
.pr-diff { margin-top: 22px; border-left: 4px solid var(--warn); }
.pr-diff h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.1rem; }
.pr-diff h2 svg { color: var(--warn); }
.pr-diff ol { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; }
.pr-diff li { line-height: 1.75; }
.pr-diff li::marker { color: var(--warn); font-weight: 700; }

/* แบบฝึกหัด */
.pr-quiz .lesson-quiz, .pr-quiz #pr-result { max-width: 860px; }
.pr-keys kbd { font-size: 0.8em; }
.pr-lq .lq-q { overflow-wrap: anywhere; }
.pr-lq .lq-q u.target { color: var(--ok); text-decoration-color: var(--ok); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.pr-lq .choice { gap: 8px; }
.pr-lq .choice .pr-letter { width: 1.45em; height: 1.45em; font-size: 0.72rem; }
.pr-lq .choice.correct .pr-letter { background: var(--ok); }
.pr-lq .choice.incorrect .pr-letter { background: var(--bad); }
.pr-explain { line-height: 1.8; }
.pr-bad { color: var(--bad); font-weight: 600; }
.pr-warn-text { color: var(--warn); font-weight: 600; }
.pr-result-top { display: flex; align-items: center; gap: 12px; }
.pr-result-emoji { font-size: 2.2rem; line-height: 1; }

/* ปุ่มบทก่อน/ถัดไป */
.pr-pager .btn { max-width: min(48%, 360px); min-width: 0; }
.pr-pager-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- ฝึกรวม ---------- */
.pr-mix { max-width: 760px; margin: 0 auto; }
.pr-mix .q-label { display: flex; flex-wrap: wrap; gap: 4px; }
.pr-mix-from { color: var(--accent); font-weight: 600; }
.pr-mix-q { font-size: clamp(1.2rem, 1rem + 1vw, 1.55rem); line-height: 2.1; font-weight: 600; margin: 8px 0 18px; overflow-wrap: anywhere; }
.pr-mix-q u.target { color: var(--ok); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.pr-mix-choices .choice { font-size: 1.15rem; line-height: 1.9; }
.pr-mix-fb { justify-items: stretch; text-align: left; }
.pr-mix-fb .fb-head { text-align: center; }
.pr-mix-explain { line-height: 1.8; }
.pr-mistakes li { padding: 0; }
.pr-mistakes li a { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; padding: 8px 12px; color: var(--text); text-decoration: none; }
.pr-mistakes li a:hover .pr-mis-title { color: var(--accent); }
.pr-mistakes .pr-vs { font-size: 1rem; }
.pr-mis-title { font-size: 0.9rem; font-weight: 600; }
.pr-mis-go { margin-left: auto; color: var(--muted); display: inline-flex; }

@media (max-width: 520px) {
  .pr-col > * { padding: 0 14px; }
  .pr-col-head { padding-top: 12px; padding-bottom: 10px; }
  .pr-hero .pr-tag { padding: 3px 12px; }
  .pr-pager .btn { max-width: 100%; flex: 1 1 100%; justify-content: center; }
  .pr-h1-jp { display: block; margin: 2px 0 0; font-size: 0.6em; }
}

/* ======================================================================
   ใช้ร่วมกับหน้า ไวยากรณ์ (#/grammar) และหน้าค้นหา — ไฟล์นี้ลิงก์ไว้ใน index.html ทุกหน้าอยู่แล้ว
   ====================================================================== */

/* ช่องให้เติมคำในรูปไวยากรณ์ (แทนตัวย่อ N / V / イA / ナA) */
.gph {
  display: inline-block; margin: 0 2px; padding: 0 6px; border-radius: 6px; vertical-align: 0.08em;
  border: 1.5px dashed currentColor; background: var(--surface); color: var(--indigo);
  font: 700 0.62em/1.55 var(--font); letter-spacing: 0; white-space: nowrap;
}
.gph sub { font-size: 0.78em; vertical-align: -0.15em; line-height: 0; margin-left: 1px; }
.lesson-head h1 .gph, .pr-hero .gph { font-size: 0.5em; }
.lesson-title .gph, .pr-tag .gph, .pr-col-head .gph, .gn-continue-title .gph { font-size: 0.72em; }
.explain .gph, .points .gph, .lq-explain .gph, .pr-diff .gph, .pr-use .gph, .pr-meaning .gph, .lead .gph { font-size: 0.78em; }
.pattern .gph { color: var(--indigo); }

/* แท็บหมวดไวยากรณ์ */
.gn-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 16px; border-bottom: 1px solid var(--border); }
.gn-tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; margin-bottom: -1px;
  color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent;
}
.gn-tabs a svg { width: 18px; height: 18px; }
.gn-tabs a:hover { color: var(--text); }
.gn-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.gn-adv {
  font-size: 0.72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn);
}

/* หมายเหตุสัญลักษณ์ */
.gn-note {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 10px 14px; max-width: 860px;
  border-radius: var(--radius-sm); background: var(--indigo-soft); color: var(--text); font-size: 0.92rem; line-height: 1.8;
}
.gn-note > svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 5px; color: var(--indigo); }
.gn-note .gph { font-size: 0.85em; }

/* คำอธิบายสัญลักษณ์ในกล่องวิธีต่อคำ */
.gn-legend { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 0; color: var(--text); align-items: baseline; }
.gn-legend dt { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.gn-legend dt .gph { font-size: 0.78em; }
.gn-legend dd { margin: 0; }
.view-grammar .pattern-label { opacity: 1; color: var(--indigo); display: flex; align-items: center; gap: 6px; }
.view-grammar .notation summary { min-height: 32px; display: inline-flex; align-items: center; }

/* หน้ารวม: กล่อง "เรียนต่อ" */
.gn-continue { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-bottom: 14px; border-color: var(--accent); }
.gn-continue-text { display: grid; gap: 2px; flex: 1 1 320px; min-width: 0; }
.gn-continue-label { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.gn-continue-title { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.gn-continue-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gn-progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.gn-progress .progress { flex: 1; max-width: 360px; }
.gn-progress > span { font-size: 0.85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gn-toolbar .search-box { flex: 1 1 260px; max-width: 420px; }
.lesson-item.gn-next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.lesson-item.gn-next .lesson-num { background: var(--accent); color: var(--accent-ink); }
.gn-bad { color: var(--bad); font-weight: 600; }

/* สถานะว่าง */
.gn-empty { padding: 36px 20px; }
.gn-empty-glyph {
  font-family: var(--font-display); font-size: 3.2rem; line-height: 1; width: 88px; height: 88px; margin: 0 auto 14px;
  display: grid; place-items: center; border-radius: 24px; background: var(--indigo-soft); color: var(--indigo);
}
.gn-empty b { color: var(--text); }
.gn-empty .btn-row { margin-top: 14px; }

/* แถบล่างติดจอในหน้าบทเรียน: ทำแบบฝึกหัด / บทถัดไป */
.gn-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + 10px); z-index: 5; margin: 22px 0 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.gn-bar-status { flex: 1 1 auto; font-size: 0.9rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.gn-bar-status svg { width: 15px; height: 15px; vertical-align: -2px; }
.gn-bar .btn { min-height: 44px; }
.view-grammar .ok-text svg { width: 15px; height: 15px; vertical-align: -2px; }
@media (max-width: 520px) {
  .gn-bar { padding: 8px; }
  .gn-bar { flex-wrap: nowrap; gap: 6px; bottom: calc(var(--tabbar-h) + 6px); }
  .gn-bar-status { flex: 0 0 auto; font-size: 0.8rem; max-width: 64px; line-height: 1.3; }
  .gn-bar .btn { flex: 1 1 0; justify-content: center; padding-left: 8px; padding-right: 8px; font-size: 0.92rem; white-space: nowrap; }
  .gn-bar .btn svg { display: none; }
  .gn-continue-actions, .gn-continue-actions .btn { flex: 1 1 100%; justify-content: center; }
  .gn-tabs a { padding: 8px 10px; flex: 1 1 auto; justify-content: center; }
}

/* ---------- หน้ารวม pairs: คำแนะนำ / กล่องเรียนต่อ / แถบค้นหา ---------- */
.pr-tag .gph, .pr-col-head .gph { color: inherit; background: transparent; }
.pr-tip { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; max-width: 860px; line-height: 1.7; }
.pr-tip > svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 4px; color: var(--warn); }
.pr-tip a { color: var(--accent); font-weight: 700; }
.pr-continue { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-bottom: 14px; border-color: var(--accent); }
.pr-continue-text { display: grid; gap: 6px; flex: 1 1 320px; min-width: 0; }
.pr-continue-label { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.pr-continue-title { font-size: 1.15rem; font-weight: 700; }
.pr-continue .pr-vs { font-size: 1.1rem; }
.pr-continue .pr-progress { margin: 4px 0 0; }
.pr-continue .pr-progress .progress { max-width: 360px; }
.pr-continue-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pr-toolbar .search-box { flex: 1 1 220px; min-width: 0; }
.pr-toolbar .seg { flex: 0 1 auto; }
.pr-toolbar .seg button { min-height: 40px; }
@media (max-width: 520px) {
  .pr-continue-actions, .pr-continue-actions .btn { flex: 1 1 100%; justify-content: center; }
  .pr-toolbar .seg { width: 100%; }
  .pr-toolbar .seg button { flex: 1 1 0; }
}

/* ลิงก์ไปหน้าฝึกเพิ่ม (ทดลอง): บทเปรียบเทียบ → #/particles · บทไวยากรณ์ → #/build (class gn-build ใช้ใน grammar.js) */
.pr-practice {
  display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 14px 16px; text-decoration: none; color: var(--text);
  border-color: var(--indigo); background: var(--indigo-soft);
}
.pr-practice > svg { flex-shrink: 0; color: var(--indigo); }
.pr-practice > svg:last-child { margin-left: auto; color: var(--muted); }
.pr-practice-text { display: grid; gap: 2px; min-width: 0; }
.pr-practice-text b { color: var(--indigo); }
.pr-practice:hover { border-color: var(--accent); }
.gn-build {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 10px 14px; min-height: 44px;
  border-radius: var(--radius-sm); border: 1.5px dashed var(--indigo); color: var(--indigo); font-weight: 600; text-decoration: none;
}
.gn-build:hover { background: var(--indigo-soft); }
.gn-build svg { flex-shrink: 0; }
/* ===== css/views/dictation.css ===== */
/* สไตล์เฉพาะหน้า ฟังแล้วพิมพ์ (ディクテーション) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืดและจอ 360px */

/* ---------- หน้าตั้งค่า ---------- */
.dict-notice { margin: 0 0 16px; }
.dict-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 20px; align-items: start; }
.dict-setup { max-width: none; }
.dict-setup .mode-opt { min-width: 0; }
.dict-opt-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.dict-opt-text small { font-size: 0.85rem; }
.dict-setup-row { display: flex; flex-wrap: wrap; gap: 18px; }
.dict-pool { margin: 0; min-height: 1.4em; }
.dict-side { display: grid; gap: 16px; }
.dict-side h2 { margin: 0 0 10px; font-size: 1.02rem; }
.dict-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dict-stat-grid > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 2px; }
.dict-stat-grid b { font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--text); }
.dict-stat-grid span { font-size: 0.82rem; color: var(--muted); }
.dict-tips ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 0.92rem; }
.dict-tips code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; padding: 0 5px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); white-space: nowrap;
}

/* ---------- การ์ดฝึก ---------- */
.dict-session { max-width: 720px; margin: 0 auto; }
.dict-card { margin-top: 10px; padding: 22px 22px 24px; }
.dict-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 6px; }
.dict-player { display: grid; justify-items: center; gap: 10px; margin: 8px 0 16px; }
.dict-play {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 112px; height: 112px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.9rem;
  transition: transform 0.15s, background 0.15s;
}
.dict-play:hover { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.dict-play:active { transform: scale(0.96); }
.dict-play.playing { animation: dict-pulse 1.2s ease-out infinite; }
.dict-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dict-tools .btn.playing { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
@keyframes dict-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .dict-play.playing { animation: none; outline: 3px solid var(--accent); }
}

/* ประโยคที่มีช่องว่าง (โหมดเติมคำ) */
.dict-sentence {
  font-size: 1.35rem; line-height: 2.2; text-align: center; margin: 0 0 14px; padding: 10px 14px;
  background: var(--surface-2); border-radius: var(--radius-sm); overflow-wrap: anywhere;
}
.dict-sentence u.target, .dict-answer u.target {
  text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; color: var(--accent);
}
.dict-blank {
  display: inline-flex; align-items: baseline; gap: 4px; margin: 0 4px; padding: 0 8px; border-radius: 8px;
  color: var(--accent); background: var(--accent-soft); border: 2px dashed var(--accent); letter-spacing: -0.1em;
}
.dict-blank small { font-family: var(--font); font-size: 0.6em; color: var(--muted); letter-spacing: 0; }

/* ช่องพิมพ์ */
.dict-form { display: grid; gap: 8px; }
.dict-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dict-input {
  width: 100%; resize: vertical; min-height: 52px; font-size: 1.25rem; line-height: 1.5; padding: 12px 14px;
  border: 2px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text);
  font-family: var(--font-jp);
}
.dict-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dict-input.done { background: var(--surface-2); }
.dict-input.is-ok { border-color: var(--ok); }
.dict-input.is-close { border-color: var(--warn); }
.dict-input.is-bad { border-color: var(--bad); }
.dict-preview { min-height: 1.5em; font-size: 1.05rem; color: var(--text); overflow-wrap: anywhere; }
.dict-preview .muted { font-size: 0.85rem; }
.dict-hint { background: var(--indigo-soft); color: var(--text); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.95rem; }
.dict-hint b { color: var(--indigo); }
.dict-actions .spacer { flex: 1; }

/* ผลตรวจ */
.dict-result { margin-top: 16px; border-radius: 14px; padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; border: 1px solid var(--border); }
.dict-result > * { min-width: 0; }
.dict-result.is-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.dict-result.is-close { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.dict-result.is-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.dict-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.dict-verdict-head { font-weight: 700; font-size: 1.08rem; }
.is-ok .dict-verdict-head { color: var(--ok); }
.is-close .dict-verdict-head { color: var(--warn); }
.is-bad .dict-verdict-head { color: var(--bad); }
.dict-acc { margin-left: auto; font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.dict-diff-wrap { background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 6px; }
.dict-diff { font-size: 1.3rem; line-height: 1.9; letter-spacing: 0.04em; overflow-wrap: anywhere; word-break: break-all; }
.d-ok { color: var(--ok); }
.d-miss { color: var(--warn); background: var(--warn-soft); border-bottom: 2px dashed var(--warn); border-radius: 3px; padding: 0 1px; }
.d-extra {
  color: var(--bad); background: var(--bad-soft); text-decoration: line-through; text-decoration-thickness: 2px;
  border-radius: 3px; padding: 0 1px;
}
.d-punct { color: var(--faint); }
.dict-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); }
.dict-legend > .d-ok, .dict-legend > .d-miss, .dict-legend > .d-extra { font-family: var(--font-jp); font-size: 0.95rem; margin-left: 6px; }
.dict-legend > .d-ok { margin-left: 0; }
.dict-answer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; overflow-wrap: anywhere; }
.dict-answer .romaji { word-break: break-all; }
.dict-answer-jp { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 1.25rem; font-weight: 600; line-height: 2.1; }
.dict-answer-jp .jp { overflow-wrap: anywhere; min-width: 0; flex: 0 1 auto; }
.dict-th { font-size: 1rem; }
.dict-word .jp { font-weight: 600; }
.dict-keys { text-align: center; margin-top: 12px; }

/* ---------- สรุปผล ---------- */
.dict-finish { max-width: 720px; }
.dict-review { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; text-align: left; }
.dict-review li {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border-left: 4px solid var(--border-strong);
}
.dict-review li.is-ok { border-left-color: var(--ok); }
.dict-review li.is-close { border-left-color: var(--warn); }
.dict-review li.is-bad { border-left-color: var(--bad); background: var(--bad-soft); }
.dict-review-acc { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.2em; padding-top: 6px; color: var(--muted); }
.is-ok .dict-review-acc { color: var(--ok); }
.is-close .dict-review-acc { color: var(--warn); }
.is-bad .dict-review-acc { color: var(--bad); }
.dict-review-body { flex: 1; min-width: 0; line-height: 2; overflow-wrap: anywhere; }
.dict-review-body .small { line-height: 1.5; }
.dict-review-given { color: var(--bad); }

/* ---------- จอเล็ก ---------- */
@media (max-width: 900px) {
  .dict-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .dict-card { padding: 16px 12px 18px; }
  .dict-play { width: 92px; height: 92px; }
  .dict-sentence { font-size: 1.15rem; padding: 8px 10px; }
  .dict-diff { font-size: 1.15rem; }
  .dict-answer-jp { font-size: 1.1rem; }
  .dict-actions .spacer { display: none; }
  .dict-actions #check { flex: 1 1 100%; }
  .dict-review li { padding: 8px 10px; gap: 8px; }
  .dict-setup-row { gap: 12px; }
}
.dict-review-body .jp { font-weight: 500; }

/* ---------- ตัวเลือกเพิ่มเติม (พับไว้) ---------- */
.dict-more { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.dict-more > summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; padding: 8px 14px;
  cursor: pointer; font-weight: 700; list-style: none; border-radius: 12px;
}
.dict-more > summary::-webkit-details-marker { display: none; }
.dict-more > summary::before {
  content: ""; width: 7px; height: 7px; flex-shrink: 0; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.2s;
}
.dict-more[open] > summary::before { transform: rotate(45deg); }
.dict-more > summary:hover { background: var(--surface-2); }
.dict-more > summary .small { font-weight: 400; }
.dict-more-body { display: grid; gap: 16px; padding: 4px 14px 14px; }
.dict-empty { margin: 0; }
.dict-start-row .btn-lg { min-width: 180px; justify-content: center; }

/* คำใบ้คีย์ลัด: แสดงเฉพาะเครื่องที่มีเมาส์/แป้นพิมพ์ — จอสัมผัสแสดงคำแนะนำแบบแตะแทน */
.dict-keys { display: none; }
.dict-touch { text-align: center; margin-top: 12px; }
@media (hover: hover) and (pointer: fine) {
  .dict-keys { display: block; }
  .dict-touch { display: none; }
}
@media (pointer: coarse) {
  .dict-setup .seg button, .dict-tools .btn, .dict-actions .btn, .dict-session #quit { min-height: 44px; }
}
@media (max-width: 520px) {
  .dict-start-row .btn { flex: 1 1 100%; justify-content: center; }
}

/* ป้ายชนิดข้อผิด (เสียงยาว/っ/゛/ゃ/ん/คำช่วย) ใต้ผลเทียบ — สไตล์ป้ายอยู่ใน games.css (.err-chip) */
.dict-errs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.dict-err-tip { margin: 0; color: var(--text); }
/* ผลตรวจอยู่ในฟอร์มก่อนแถบปุ่ม (แถบปุ่มติดขอบล่างในโหมดรอบฝึก จึงยังเห็นปุ่ม "ข้อถัดไป" หลังเลื่อนดูผล) */
.dict-form #dict-result:empty { display: none; }
.dict-form .dict-result { margin-top: 8px; }
/* ===== css/views/games.css ===== */
/* สไตล์เฉพาะหน้า เกมฝึกจำ (#/games) — ใช้ตัวแปรสีจาก style.css เท่านั้น (รองรับโหมดมืด) */

.gm-h1-ja { font-family: var(--font-display); font-weight: 600; font-size: 0.7em; margin-left: 4px; color: var(--muted); }
.gm-pool { margin: -6px 0 14px; }

/* =========================================================================
   หน้าเลือกเกม
   ========================================================================= */
.gm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); gap: 14px; }
.gm-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; position: relative; overflow: hidden; }
.gm-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 130px; height: 130px; border-radius: 50%;
  background: var(--accent-soft); opacity: 0.5; pointer-events: none;
}
.gm-card-speed::after { background: var(--warn-soft); }
.gm-card-rain::after { background: var(--indigo-soft); }
.gm-card > * { position: relative; z-index: 1; }
.gm-card-head { display: flex; align-items: center; gap: 12px; }
.gm-glyph {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-display); font-size: 1.9rem; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.gm-card-speed .gm-glyph { background: var(--warn); color: var(--surface); }
.gm-card-rain .gm-glyph { background: var(--indigo); color: var(--surface); }
.gm-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.gm-card-title h2 { margin: 0; width: 100%; font-size: 1.18rem; }
.gm-desc { margin: 0; line-height: 1.55; }

.gm-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-mode {
  min-height: 44px; padding: 7px 12px; border-radius: 11px; border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.gm-mode:hover:not(:disabled) { border-color: var(--accent); }
.gm-mode.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.gm-mode:disabled { background: var(--surface-2); border-color: var(--border); border-style: dashed; color: var(--muted); cursor: not-allowed; }
.gm-modes-label { font-weight: 700; color: var(--muted); margin-bottom: -6px; }
.gm-na { margin: -4px 0 0; }
.gm-mode [lang="ja"] { font-size: 1rem; }

.gm-best { font-size: 0.92rem; min-height: 1.5em; }
.gm-best b { font-size: 1.15rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.gm-play { margin-top: auto; min-height: 46px; }

.gm-records { margin-top: 16px; }
.gm-records h2 { margin: 0 0 10px; font-size: 1.05rem; }
.gm-table-wrap { overflow-x: auto; }
.gm-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.gm-table th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.gm-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.gm-table tr:last-child td { border-bottom: none; }
.gm-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) {
  .gm-table th:nth-child(4), .gm-table td:nth-child(4) { display: none; }
  .gm-table td, .gm-table th { padding: 7px 4px; }
}

/* =========================================================================
   ส่วนหัวขณะเล่น
   ========================================================================= */
.gm-play-wrap { max-width: 760px; margin: 0 auto; }
.gm-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.gm-top-title { display: grid; line-height: 1.3; flex: 1; min-width: 0; }
.gm-top-title b { font-size: 1.05rem; }
.gm-stats { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.gm-stat {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-variant-numeric: tabular-nums; font-size: 0.95rem;
}
.gm-stat b { font-size: 1.05rem; }
.gm-stat.ok { color: var(--ok); }
.gm-stat.bad { color: var(--bad); }
.gm-stat.combo { color: var(--warn); background: var(--warn-soft); border-color: transparent; font-weight: 700; animation: gm-pop 0.25s ease; }
.gm-stat[hidden] { display: none; }
.gm-ico { display: inline-flex; color: var(--muted); }
.gm-prog { margin-bottom: 12px; }

.gm-stage { position: relative; }
.gm-hint { text-align: center; margin: 0 0 12px; }
.gm-keys { text-align: center; margin: 14px 0 0; }
@media (hover: none) { .gm-keys { display: none; } }

/* นับถอยหลัง */
.gm-count {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.gm-count span {
  font-size: clamp(3rem, 2rem + 6vw, 5rem); font-weight: 800; color: var(--accent); line-height: 1;
  animation: gm-zoom 0.55s ease both;
}

/* =========================================================================
   เกมจับคู่
   ========================================================================= */
.gm-match { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gm-col { display: grid; gap: 8px; align-content: start; }
.gm-tile {
  position: relative; min-height: 62px; padding: 8px 10px; border-radius: 14px; border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; font-size: 0.98rem; line-height: 1.3;
  display: flex; align-items: center; justify-content: center; text-align: center; overflow-wrap: anywhere;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s, background 0.12s, transform 0.12s, opacity 0.3s;
}
.gm-tile.q { background: var(--surface-2); }
.gm-tile.jpt .jp { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; }
.gm-tile.jpt.long .jp { font-size: 1.2rem; }
.gm-tile.a.jpt .jp { font-family: var(--font-jp); font-size: 1.15rem; }
.gm-tile.long:not(.jpt) { font-size: 0.88rem; }
.gm-tile:hover:not(:disabled) { border-color: var(--accent); }
.gm-tile.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); transform: translateY(-2px); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.gm-tile.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); animation: gm-shake 0.38s ease; }
.gm-tile.done { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); cursor: default; opacity: 0; visibility: hidden; animation: gm-out 0.42s ease; }
.gm-enter .gm-tile { animation: gm-in 0.3s ease both; }
.gm-enter .gm-col .gm-tile:nth-child(2) { animation-delay: 0.03s; }
.gm-enter .gm-col .gm-tile:nth-child(3) { animation-delay: 0.06s; }
.gm-enter .gm-col .gm-tile:nth-child(4) { animation-delay: 0.09s; }
.gm-enter .gm-col .gm-tile:nth-child(5) { animation-delay: 0.12s; }
.gm-enter .gm-col .gm-tile:nth-child(6) { animation-delay: 0.15s; }
.gm-enter .gm-tile.done { animation: gm-out 0.42s ease; }
.gm-enter .gm-tile.wrong { animation: gm-shake 0.38s ease; }
.gm-float {
  position: absolute; top: -6px; right: 6px; font-size: 0.85rem; font-weight: 800; pointer-events: none;
  animation: gm-float 0.85s ease forwards;
}
.gm-float.bad { color: var(--bad); }
@media (max-width: 520px) {
  .gm-stage.card { padding: 12px 10px; }
  .gm-match { gap: 8px; }
  .gm-tile { min-height: 56px; padding: 6px 6px; font-size: 0.9rem; }
  .gm-tile.jpt .jp { font-size: 1.3rem; }
  .gm-tile.jpt.long .jp { font-size: 1.02rem; }
  .gm-tile.a.jpt .jp { font-size: 1rem; }
}

/* =========================================================================
   ตอบไว 60 วินาที
   ========================================================================= */
.gm-timer { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.gm-timer b { min-width: 2.4em; text-align: right; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.gm-timer-bar { flex: 1; height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gm-timer-bar span { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--ok); transition: width 0.1s linear, background 0.3s; }
.gm-timer.low .gm-timer-bar span { background: var(--bad); }
.gm-timer.low b { color: var(--bad); animation: gm-pulse 1s ease infinite; }
.gm-timer.gm-bonus b { animation: gm-pop 0.4s ease; color: var(--ok); }
.gm-speed { margin-top: 0; max-width: none; }
.gm-q { min-height: 120px; display: grid; align-content: center; }
.gm-q .q-prompt { margin-bottom: 4px; }
.gm-qjp.long { font-size: clamp(2.1rem, 1.6rem + 3vw, 3.4rem); }
.gm-reading { color: var(--muted); font-size: 1.05rem; margin-bottom: 8px; }
.gm-q .q-text { margin: 6px 0 12px; }
.gm-in { animation: gm-in 0.22s ease both; }
.gm-speed .choice { min-height: 56px; touch-action: manipulation; }
.gm-ch { display: grid; min-width: 0; overflow-wrap: anywhere; }
.gm-speed .jp-choices .choice small { font-size: 0.78rem; }
.gm-shake { animation: gm-shake 0.38s ease; }

/* =========================================================================
   ฝนคานะ
   ========================================================================= */
.gm-rain {
  position: relative; height: clamp(300px, 52vh, 460px); overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  background: linear-gradient(180deg, var(--indigo-soft), var(--surface) 70%);
}
.gm-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--accent); opacity: 0.55; }
.gm-rain.gm-hurt { animation: gm-hurt 0.45s ease; }
.gm-drop {
  position: absolute; top: 0; width: 58px; height: 52px; display: grid; place-items: center; border-radius: 14px;
  font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border-strong); box-shadow: var(--shadow);
  will-change: transform;
}
.gm-drop.wide { font-size: 1.35rem; }
.gm-drop.danger { border-color: var(--bad); color: var(--bad); }
.gm-drop.popped { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); animation: gm-burst 0.36s ease forwards; }
.gm-drop.missed { animation: gm-fade 0.36s ease forwards; }
.gm-type { display: flex; justify-content: center; margin-top: 12px; }
.gm-type input {
  width: min(320px, 100%); font-size: 1.3rem; text-align: center; padding: 12px; border-radius: 14px;
  border-width: 2px; font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.08em;
}
.gm-type input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.gm-type input.bad { border-color: var(--bad); animation: gm-shake 0.3s ease; }
.gm-lives { display: inline-flex; gap: 2px; font-size: 1.2rem; }
.gm-heart { color: var(--accent); transition: color 0.2s, transform 0.2s; }
.gm-heart.lost { color: var(--surface-3); transform: scale(0.8); }
.gm-rain-stage .gm-count { border-radius: var(--radius); bottom: auto; height: clamp(300px, 52vh, 460px); }

/* =========================================================================
   สรุปผล
   ========================================================================= */
.gm-finish { animation: gm-in 0.3s ease both; }
.gm-finish.best { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.gm-fin-title { margin: 0 0 6px; }
.gm-big { line-height: 1; margin: 10px 0 4px; }
.gm-big b { font-size: clamp(3rem, 2.4rem + 3vw, 4.2rem); color: var(--accent); font-variant-numeric: tabular-nums; }
.gm-big span { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.gm-newbest {
  display: inline-block; margin: 8px 0 2px; padding: 4px 14px; border-radius: 999px; font-weight: 800;
  background: var(--warn-soft); color: var(--warn); animation: gm-pop 0.5s ease 0.15s both;
}
.gm-prev { margin: 4px 0 6px; }
.gm-xp { font-weight: 700; color: var(--warn); margin: 0 0 6px; }
.gm-finish .mistakes li { flex-wrap: wrap; row-gap: 2px; }
.gm-mis-th { font-size: 0.92rem; min-width: 0; overflow-wrap: anywhere; }
.gm-finish .mistakes li .speak { margin-left: auto; }
.gm-sent { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; color: var(--ok); }
.gm-finish .btn-row .btn { flex: 1 1 200px; }
@media (max-width: 520px) {
  .gm-finish { padding: 24px 14px; }
  .gm-finish .btn kbd { display: none; }
}

/* =========================================================================
   แอนิเมชัน
   ========================================================================= */
@keyframes gm-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes gm-out { 0% { opacity: 1; visibility: visible; } 40% { transform: scale(1.06); opacity: 1; visibility: visible; } 99% { visibility: visible; } to { transform: scale(0.92); opacity: 0; } }
@keyframes gm-shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes gm-zoom { from { opacity: 0; transform: scale(1.6); } to { opacity: 1; transform: scale(1); } }
@keyframes gm-pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes gm-pulse { 50% { opacity: 0.45; } }
@keyframes gm-float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }
@keyframes gm-burst { to { opacity: 0; scale: 1.5; } }
@keyframes gm-fade { to { opacity: 0; } }
@keyframes gm-hurt { 30% { box-shadow: inset 0 0 0 4px var(--bad); } }

@media (prefers-reduced-motion: reduce) {
  .gm *, .gm *::before, .gm *::after { animation-duration: 0.001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  .gm-tile.done { animation: none !important; }
}
.gm-type input::placeholder { font-family: var(--font); letter-spacing: 0; font-size: 1rem; }

/* =========================================================================
   หน้าทบทวน (#/review) และแบบทดสอบ (#/quiz) — วางไว้ในไฟล์นี้เพราะเป็นหน้าในกลุ่ม "ฝึก"
   และไม่ต้องเพิ่มลิงก์ CSS ใน index.html (ทุกตัวเลือกขึ้นต้นด้วย .view-review / .view-quiz)
   ========================================================================= */
/* --- ทบทวน: ไม่มีการ์ดค้าง = สถานะว่างสีกลางๆ (ไม่ใช้ตัวเลข 0 สีแดง) --- */
.view-review .review-grid h2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.view-review .due-num { color: var(--text); }
.view-review .rv-empty { display: grid; gap: 6px; justify-items: start; }
.view-review .rv-ok {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok);
}
.view-review .rv-ok svg { width: 26px; height: 26px; }
.view-review .rv-empty-head { margin: 4px 0 0; font-weight: 700; font-size: 1.08rem; }
.view-review .rv-empty p { margin: 0; }
.view-review .rv-go-new { margin-top: 6px; min-height: 44px; white-space: normal; }
.view-review .rv-arrow::after { content: "→"; }
@media (max-width: 720px) { .view-review .rv-arrow::after { content: "↓"; } }
.view-review .rv-none .review-new { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.view-review .rv-flash { animation: rv-flash 1.2s ease; }
@keyframes rv-flash { 0%, 60% { box-shadow: 0 0 0 4px var(--focus); } }
.view-review .review-new p { margin: 0; }
.view-review .rv-label { font-weight: 700; color: var(--text); }
.view-review .review-new select { max-width: 100%; box-sizing: border-box; min-height: 44px; }
.view-review .review-grid > .card { min-width: 0; }
.view-review .review-grid .btn-lg { white-space: normal; }
.view-review details.how > summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; gap: 8px; list-style: none; }
.view-review details.how > summary::-webkit-details-marker { display: none; }
.view-review details.how > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
.view-review details.how[open] > summary::before { transform: rotate(90deg); }
.view-review details.how[open] > summary { margin-bottom: 8px; }
.view-review .page-actions .seg button { min-height: 40px; }

/* --- แบบทดสอบ: ปุ่มหลักปุ่มเดียว + ตั้งค่าเพิ่มเติมพับไว้ --- */
.view-quiz .qz-quick, .view-quiz .qz-more { max-width: 640px; }
.view-quiz .qz-quick {
  display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; margin-bottom: 14px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.view-quiz .qz-quick-text { flex: 1 1 260px; min-width: 0; }
.view-quiz .qz-quick h2 { margin: 0 0 4px; font-size: 1.15rem; }
.view-quiz .qz-quick p { margin: 0; }
.view-quiz .qz-go { flex: 0 0 auto; min-height: 48px; }
.view-quiz .qz-more { padding: 0; }
.view-quiz .qz-more > summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 14px 20px; min-height: 48px;
  cursor: pointer; list-style: none; border-radius: var(--radius);
}
.view-quiz .qz-more > summary::-webkit-details-marker { display: none; }
.view-quiz .qz-more > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; display: inline-block; }
.view-quiz .qz-more[open] > summary::before { transform: rotate(90deg); }
.view-quiz .qz-more-title { font-weight: 700; }
.view-quiz .qz-more .quiz-setup { padding: 0 20px 20px; max-width: none; }
.view-quiz .quiz-setup, .view-quiz .field { min-width: 0; }
.view-quiz .quiz-setup select { width: 100%; max-width: 100%; box-sizing: border-box; min-height: 44px; }
.view-quiz .field-label { font-weight: 700; }
.view-quiz .mode-opt { min-height: 44px; }
.view-quiz .mode-opt.disabled { opacity: 1; color: var(--muted); border-style: dashed; background: var(--surface-2); }
.view-quiz .quiz-setup .seg button { min-height: 40px; }
@media (max-width: 520px) {
  .view-quiz .qz-go { width: 100%; }
  .view-quiz .qz-more > summary { padding: 14px 16px; }
  .view-quiz .qz-more .quiz-setup { padding: 0 16px 16px; }
}

/* ---------- ผลตรวจคำที่พิมพ์ (ใช้ร่วม: แบบทดสอบ ผันคำ ฟังแล้วพิมพ์ ฝึกพูด — JP.text.diffMarkHtml / errorChipsHtml) ---------- */
.feedback.near { background: var(--warn-soft); }
.feedback.near .fb-head { color: var(--warn); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.dm { font-family: var(--font-jp); font-size: 1.15em; overflow-wrap: anywhere; }
.dm mark, .dm ins { text-decoration: none; border-radius: 4px; padding: 0 2px; font-weight: 700; }
/* ตัวที่ขาดไป = กรอบประ · ตัวที่พิมพ์ผิด = ขีดเส้นใต้หนา · ตัวที่พิมพ์เกิน = ตัวเล็กขีดฆ่า */
.dm .dm-miss { background: var(--surface); color: var(--warn); outline: 2px dashed var(--warn); outline-offset: -1px; }
.dm .dm-sub { background: var(--surface); color: var(--bad); box-shadow: inset 0 -3px 0 var(--bad); }
.dm .dm-extra { background: transparent; color: var(--muted); font-weight: 400; font-size: 0.75em; text-decoration: line-through; vertical-align: super; }
.err-chip {
  display: inline-block; margin: 2px 2px 0 0; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; line-height: 1.6;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); white-space: nowrap;
}
.err-chip.err-length, .err-chip.err-sokuon { border-color: var(--warn); color: var(--warn); }
.err-chip.err-voicing, .err-chip.err-yoon, .err-chip.err-n { border-color: var(--indigo); color: var(--indigo); }
.qz-typed { display: grid; gap: 4px; justify-items: center; text-align: center; max-width: 100%; }
.qz-typed-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; max-width: 100%; }
.qz-tip { margin: 2px 0 0; max-width: 46ch; color: var(--text); }
.qz-type-tip { margin: 6px 0 0; text-align: center; }
.qz-other {
  display: flex; align-items: flex-start; gap: 6px; padding: 8px 10px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.qz-other[hidden] { display: none; }
.qz-other svg { flex: none; width: 18px; height: 18px; color: var(--indigo); margin-top: 2px; }
/* หน้าจบ: เพิ่มคำที่ผิดเข้าทบทวนเอง (ไม่สร้างการ์ดเงียบๆ) */
.add-wrong { margin-top: 10px; display: grid; gap: 6px; justify-items: start; }
.add-wrong p { margin: 0; }
.add-wrong .btn { white-space: normal; min-height: 44px; }
/* ป๊อปอัปเตือนงบการ์ดใหม่ */
.nb-confirm h2 { margin: 0 0 8px; font-size: 1.15rem; }
.nb-confirm p { margin: 0 0 8px; }
.nb-forecast { font-weight: 700; color: var(--text); }
.nb-actions { flex-wrap: wrap; margin-top: 12px; }
.nb-actions .btn { white-space: normal; min-height: 44px; }
.view-review .rv-comeback { margin: 4px 0 10px; text-align: left; }
/* ปุ่ม "ข้อถัดไป" ในกล่องเฉลย — ติดขอบล่างในโหมดรอบฝึก (.sticky-actions ของ style.css) */
.feedback .qz-next-bar { justify-self: stretch; display: flex; justify-content: center; }
/* แถบปุ่มติดขอบล่างในกล่องเฉลย: พื้นสีเดียวกับกล่อง */
.feedback.ok .qz-next-bar { background: var(--ok-soft); }
.feedback.bad .qz-next-bar { background: var(--bad-soft); }
.feedback.near .qz-next-bar { background: var(--warn-soft); }
/* ===== css/views/stats.css ===== */
/* สไตล์เฉพาะหน้า สถิติและจุดอ่อน (#/stats) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืด และจอกว้าง 360px */

/* ---------- แท็บของหน้า (ภาพรวม / วิเคราะห์จุดอ่อน) — ใช้ร่วมกับ #/insights ---------- */
.pg-tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.pg-tabs a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; margin-bottom: -1px;
  color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.pg-tabs a:hover { color: var(--text); }
.pg-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.pg-tabs a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

.st-page h3 { font-size: 1.02rem; margin: 0 0 0.35em; }
.st-page .section-head { margin-top: 2em; }
.st-intro { margin-bottom: 8px; }
.st-intro .btn-row { margin-top: 10px; }
.st-note { margin: 10px 0 0; }
.st-of { font-size: 1rem; color: var(--muted); font-weight: 600; }
.st-tiles { margin-top: 0; }

/* ---------- เลย์เอาต์ ---------- */
.st-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.st-cols-exam { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.st-chart-card { min-width: 0; }
.st-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.st-card-head h3 { margin: 0; }
.st-chart { width: 100%; min-height: 60px; overflow: hidden; }
.st-svg { display: block; overflow: visible; }
.st-table-card { padding: 6px 4px; overflow-x: auto; margin-bottom: 14px; }

/* ---------- องค์ประกอบในกราฟ SVG ---------- */
.st-grid { stroke: var(--border); stroke-width: 1; }
.st-base { stroke: var(--border-strong); stroke-width: 1; }
.st-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.st-bar { fill: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.st-bar.met { fill: var(--accent); }
.st-bar.now { stroke: var(--text); stroke-width: 1; }
.st-hit { fill: transparent; cursor: crosshair; }
.st-goal { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.st-goal-label { fill: var(--warn); font-size: 11px; font-weight: 600; font-family: var(--font); }
.st-pass { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.st-pass-label { fill: var(--warn); font-size: 11px; font-weight: 600; font-family: var(--font); }
.st-line { fill: none; stroke: var(--indigo); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.st-dot { stroke: var(--surface); stroke-width: 2; }
.st-dot.pass { fill: var(--ok); }
.st-dot.fail { fill: var(--bad); }
.st-val { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); }
.st-hm { fill: var(--surface-3); }
.st-hm.l1 { fill: color-mix(in srgb, var(--accent) 25%, var(--surface-3)); }
.st-hm.l2 { fill: color-mix(in srgb, var(--accent) 50%, var(--surface-3)); }
.st-hm.l3 { fill: color-mix(in srgb, var(--accent) 75%, var(--surface-3)); }
.st-hm.l4 { fill: var(--accent); }
.st-hm.today { stroke: var(--text); stroke-width: 1.2; }
.st-hm:hover { stroke: var(--text); stroke-width: 1.5; }

/* คำอธิบายสัญลักษณ์ */
.st-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 8px; }
.st-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.st-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.st-key.bar { background: color-mix(in srgb, var(--accent) 45%, var(--surface-3)); }
.st-key.met { background: var(--accent); }
.st-key.goal, .st-key.pass-line { height: 0; width: 16px; border-top: 2px dashed var(--warn); border-radius: 0; }
.st-key.dot { width: 10px; height: 10px; border-radius: 50%; }
.st-key.dot.pass { background: var(--ok); }
.st-key.dot.fail { background: var(--bad); }
.st-hm-scale { display: inline-flex; gap: 3px; }
.st-hm-scale i { width: 11px; height: 11px; border-radius: 2px; background: var(--surface-3); }
.st-hm-scale i.l1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface-3)); }
.st-hm-scale i.l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface-3)); }
.st-hm-scale i.l3 { background: color-mix(in srgb, var(--accent) 75%, var(--surface-3)); }
.st-hm-scale i.l4 { background: var(--accent); }

/* tooltip ลอยตามเมาส์ */
.st-tip {
  position: fixed; z-index: 60; max-width: min(280px, calc(100vw - 16px)); pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 0.82rem; line-height: 1.4;
  box-shadow: var(--shadow-lg);
}
.st-tip[hidden] { display: none; }

/* ---------- วันในสัปดาห์ ---------- */
.st-week p { margin: 0 0 10px; }
.st-wd { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; height: 130px; align-items: end; }
.st-wd-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; cursor: default; }
.st-wd-bar { display: block; width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--indigo) 55%, var(--surface-3)); }
.st-wd-bar.best { background: var(--indigo); }
.st-wd-lbl { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.st-wd-col > .st-wd-bar { flex-shrink: 1; max-height: calc(100% - 20px); }

/* ---------- ความคืบหน้ารายระดับ ---------- */
.st-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.st-level { padding: 16px; display: grid; gap: 12px; align-content: start; }
.st-level.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.st-level-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.st-level-head .small { white-space: nowrap; }
.st-level-head > div { display: grid; line-height: 1.25; flex: 1; min-width: 96px; }
.st-level-head strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.st-level-head .btn { flex-shrink: 0; }
.st-more-levels { margin-top: 12px; }
.st-more-levels > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-height: 44px; cursor: pointer; font-weight: 700; color: var(--accent); }
.st-more-levels > summary .muted { font-weight: 400; font-size: 0.88rem; }
.st-more-levels[open] > summary { margin-bottom: 8px; }
.st-ring {
  --p: 0; width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0);
}
.st-ring b { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: 0.9rem; }
.st-level-rows { display: grid; gap: 7px; }
.st-lrow { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 0.82rem; cursor: default; }
.st-lrow-name { color: var(--muted); }
.st-lrow-num { font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.st-meter { display: block; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.st-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.st-meter.sm { height: 6px; }
.st-meter > span.good, .st-grp-bar > span.good { background: var(--ok); }
.st-meter > span.mid, .st-grp-bar > span.mid { background: var(--warn); }
.st-meter > span.low, .st-grp-bar > span.low { background: var(--bad); }

/* ---------- SRS ---------- */
.st-srs-sum { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.st-chipstat {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 0.88rem;
}
.st-chipstat b { font-variant-numeric: tabular-nums; }
.st-boxes { display: grid; gap: 6px; margin-top: 8px; }
.st-box-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 48px; align-items: center; gap: 8px; font-size: 0.83rem; cursor: default; }
.st-box-name { color: var(--muted); }
.st-box-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.st-hbar { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--surface-2); }
.st-hbar > span { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 0; }
.st-hbar > span.b0 { background: var(--faint); }
.st-hbar > span.b1 { background: var(--warn); }
.st-hbar > span.b2 { background: var(--ok); }
.st-fc { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; height: 170px; align-items: end; margin-top: 8px; }
.st-fc-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; min-width: 0; cursor: default; }
.st-fc-bar { display: block; width: 100%; max-width: 22px; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--indigo) 55%, var(--surface-3)); max-height: calc(100% - 38px); }
.st-fc-bar.now { background: var(--accent); }
.st-fc-num { font-size: 0.68rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; }
.st-fc-lbl { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }

/* ตาราง */
.st-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.st-table th, .st-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.st-table thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.st-table tbody tr:last-child th, .st-table tbody tr:last-child td { border-bottom: none; }
.st-secpill { display: inline-block; margin: 2px 8px 2px 0; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.st-secpill b { color: var(--text); }

/* ---------- ข้อสอบจำลอง ---------- */
.st-exam-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.st-tab { cursor: pointer; border: 1px solid var(--border); font: inherit; font-size: 0.88rem; font-weight: 700; }
.st-tab.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.st-tab .muted { font-weight: 400; }
.st-exam-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.st-mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.st-mini { padding: 12px 14px; display: grid; gap: 2px; }
.st-mini strong { font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.st-mini span { font-size: 0.8rem; color: var(--muted); }
.st-trend { font-style: normal; font-weight: 700; white-space: nowrap; }
.st-trend.up { color: var(--ok); }
.st-trend.down { color: var(--bad); }
.st-grp { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: default; }
.st-grp:last-child { border-bottom: none; padding-bottom: 0; }
.st-grp-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; line-height: 1.35; }
.st-grp-top > b { font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-grp-bar { position: relative; display: block; height: 8px; border-radius: 999px; background: var(--surface-3); }
.st-grp-bar > span { display: block; height: 100%; border-radius: inherit; }
.st-grp-bar > i { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--text); border-radius: 1px; transform: translateX(-1px); }
.st-badtxt { color: var(--bad); }

/* ---------- จุดอ่อน ---------- */
.st-reco-card { margin-bottom: 14px; }
.st-reco { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.st-reco-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; height: 100%;
  transition: border-color 0.15s;
}
.st-reco-item:hover { border-color: var(--accent); }
.st-reco-glyph {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-size: 1.3rem;
}
.st-reco-text { display: grid; gap: 2px; min-width: 0; flex: 1; line-height: 1.4; }
.st-reco-text b { overflow-wrap: anywhere; }
.st-reco-go { color: var(--muted); flex-shrink: 0; display: inline-flex; }
.st-weak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 14px; margin-bottom: 14px; }
.st-weak-list { display: grid; gap: 2px; margin-top: 6px; }
.st-weak-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 56px auto; align-items: center; gap: 8px;
  padding: 8px 6px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.88rem;
}
.st-weak-row:hover { background: var(--surface-2); }
.st-weak-row > b { font-variant-numeric: tabular-nums; text-align: right; min-width: 38px; }
.st-weak-name { display: grid; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.st-ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-weak-row:has(> .st-weak-name + b) { grid-template-columns: auto minmax(0, 1fr) auto; }

.st-wrong { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.st-wcard {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text); text-decoration: none; min-width: 0;
}
.st-wcard:hover { border-color: var(--accent); }
.st-wcard-front { font-size: 1.35rem; font-weight: 600; flex-shrink: 0; max-width: 45%; overflow-wrap: anywhere; line-height: 1.25; }
.st-wcard-front.long { font-size: 0.95rem; max-width: 50%; }
.st-wcard-body { display: grid; gap: 4px; min-width: 0; }
.st-wcard-body > .small { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.st-wcard-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- แผนวันนี้ (JP.today) / รูปแบบข้อผิด / ข้อสอบที่มีบทเคยเห็น ---------- */
.st-reco-num { font-family: var(--font); font-size: 1.05rem; font-weight: 700; }
.st-reco-num svg { width: 20px; height: 20px; }
.st-reco-item.st-done { background: var(--surface); }
.st-reco-item.st-done .st-reco-num { background: var(--ok-soft); color: var(--ok); }
.st-reco-item.st-done .st-reco-text b { color: var(--muted); font-weight: 600; }
.st-pattern-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-bottom: 14px; align-items: start; }
.st-pattern-grid > .card { min-width: 0; }
.st-seen-pill { white-space: nowrap; }
.st-seen-pill.st-seen-warn { background: var(--warn-soft); color: var(--warn); }
.st-seen-note { margin: 8px 0 0; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 860px) {
  .st-cols, .st-cols-exam { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .st-page .card { padding: 14px; }
  .st-table-card { padding: 4px 2px; }
  .st-table th, .st-table td { padding: 8px 7px; }
  .st-hide-sm { display: none; }
  .st-reco { grid-template-columns: minmax(0, 1fr); }
  .pg-tabs a { flex: 1; justify-content: center; padding: 8px 10px; }
  .st-intro .btn { flex: 1 1 auto; }
  .st-wrong { grid-template-columns: minmax(0, 1fr); }
  .st-fc-lbl, .st-fc-num { font-size: 0.6rem; }
  .st-lrow { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .st-mini strong { font-size: 1.2rem; }
}

/* ---------- ประเภทโจทย์ที่ควรฝึก (ข้อสอบจำลองแยกตามประเภท) ---------- */
.st-types { margin-bottom: 14px; }
.st-types-sum { margin: 0 0 4px; }
.st-types-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 18px; }
.st-types-few { margin-top: 10px; }
.st-types-few > summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.st-types-few[open] > summary { margin-bottom: 2px; }

/* จอแคบ: ไทล์สรุปมี 4 ช่อง — จัด 2×2 แทน 3+1 เพื่อไม่ให้ป้ายตัดคำกลางคำ */
@media (max-width: 640px) {
  .stat-grid.st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 861px) {
  .stat-grid.st-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* ===== css/views/speak.css ===== */
/* สไตล์เฉพาะหน้า ฝึกพูด (シャドーイング) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืดและจอ 360px */

/* ---------- หน้าตั้งค่า ---------- */
.sp-notice { margin: 0 0 16px; }
.sp-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 20px; align-items: start; }
.sp-setup { max-width: none; }
.sp-setup .mode-opt { min-width: 0; }
.sp-opt-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.sp-opt-text b { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-opt-text small { font-size: 0.85rem; }
.sp-pool { margin: 0; min-height: 1.4em; }
.sp-side { display: grid; gap: 16px; min-width: 0; }
.sp-side h2 { margin: 0 0 10px; font-size: 1.02rem; }
.sp-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sp-stat-grid > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 2px; }
.sp-stat-grid b { font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--text); }
.sp-stat-grid span { font-size: 0.82rem; color: var(--muted); }
.sp-help summary { cursor: pointer; font-weight: 700; }
.sp-help ol, .sp-tips ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.92rem; }
.sp-tips ul { margin-top: 0; }
.sp-help code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; padding: 0 5px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}

/* ---------- การ์ดฝึก ---------- */
.sp-session { max-width: 720px; margin: 0 auto; }
.sp-session > .sp-notice { margin: 8px 0 0; }
.sp-card { margin-top: 10px; padding: 22px 22px 20px; display: grid; gap: 16px; }
.sp-card > * { min-width: 0; }
.sp-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sp-text { display: grid; justify-items: center; gap: 6px; text-align: center; }
.sp-sentence {
  font-size: 1.5rem; font-weight: 600; line-height: 2.2; overflow-wrap: anywhere; max-width: 100%;
  transition: filter 0.2s;
}
.sp-sentence.is-hidden, .sp-romaji.is-hidden { filter: blur(9px); user-select: none; pointer-events: none; }
.sp-romaji { overflow-wrap: anywhere; max-width: 100%; }
.sp-th { font-size: 1rem; color: var(--text); }
.sp-word .jp { font-weight: 600; }

.sp-controls { display: grid; justify-items: center; gap: 12px; }
.sp-listen { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sp-listen .btn.playing { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.sp-mic {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 116px; height: 116px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  background: var(--indigo-soft); color: var(--indigo); font-weight: 700; font-size: 0.82rem; line-height: 1.25;
  padding: 8px; text-align: center; transition: transform 0.15s, background 0.15s;
}
.sp-mic:hover { border-color: var(--indigo); }
.sp-mic:active { transform: scale(0.96); }
.sp-mic:disabled { background: var(--surface-2); color: var(--muted); border: 2px dashed var(--border-strong); cursor: not-allowed; }
.sp-mic.listening { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); animation: sp-pulse 1.2s ease-out infinite; }
@keyframes sp-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); }
  100% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--bad) 0%, transparent); }
}

/* สถานะสด */
.sp-live {
  min-height: 1.6em; text-align: center; font-size: 1rem; color: var(--muted); overflow-wrap: anywhere;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px;
}
.sp-live:empty { min-height: 0; display: none; }
.sp-live.hearing { color: var(--text); }
.sp-live.hearing .jp { font-size: 1.15rem; }
.sp-live.bad { color: var(--bad); }
.sp-live.good { color: var(--ok); font-weight: 600; }
.sp-live.turn { color: var(--accent); font-weight: 700; flex-direction: column; }
.sp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: sp-blink 1s infinite; }
@keyframes sp-blink { 50% { opacity: 0.25; } }
.sp-turn {
  display: block; width: min(280px, 100%); height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; position: relative;
}
.sp-turn::after {
  content: ""; position: absolute; inset: 0; background: var(--accent); transform-origin: left;
  animation: sp-turn var(--sp-turn, 3s) linear forwards;
}
@keyframes sp-turn { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .sp-mic.listening, .sp-dot { animation: none; }
  .sp-mic.listening { outline: 3px solid var(--bad); }
}

/* ผลตรวจ */
.sp-result {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center;
  border-radius: 14px; padding: 14px 16px; border: 1px solid var(--border);
}
.sp-result.is-good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); --sp-c: var(--ok); }
.sp-result.is-ok { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); --sp-c: var(--warn); }
.sp-result.is-again { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); --sp-c: var(--bad); }
.sp-score {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--sp-c, var(--accent)) calc(var(--sp-p, 0) * 1%), var(--surface-2) 0);
}
.sp-score b {
  width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800; color: var(--sp-c, var(--text)); font-variant-numeric: tabular-nums;
}
.sp-score small { font-size: 0.7rem; font-weight: 700; margin-top: 0.35em; }
.sp-result-body { display: grid; gap: 6px; min-width: 0; }
.sp-verdict { font-weight: 700; font-size: 1.05rem; color: var(--sp-c, var(--text)); }
.sp-diff {
  font-size: 1.25rem; line-height: 1.9; letter-spacing: 0.03em; overflow-wrap: anywhere; word-break: break-all;
  background: var(--surface); border-radius: var(--radius-sm); padding: 6px 10px;
}
.sp-d-ok { color: var(--ok); }
.sp-d-miss { color: var(--warn); background: var(--warn-soft); border-bottom: 2px dashed var(--warn); border-radius: 3px; padding: 0 1px; }
.sp-d-extra { color: var(--bad); background: var(--bad-soft); text-decoration: line-through; text-decoration-thickness: 2px; border-radius: 3px; padding: 0 1px; }
.sp-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); }
.sp-legend > [class^="sp-d-"] { font-family: var(--font-jp); margin-left: 6px; }
.sp-legend > .sp-d-ok { margin-left: 0; }
.sp-heard { overflow-wrap: anywhere; }

/* ประเมินตัวเอง */
.sp-rate p { margin: 0 0 8px; text-align: center; }
.sp-rate-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sp-rate-btn {
  display: grid; justify-items: center; gap: 2px; padding: 10px 6px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); min-width: 0;
}
.sp-rate-btn:hover { background: var(--surface-2); }
.sp-rate-btn b { font-size: 1rem; }
.sp-rate-btn small { font-size: 0.74rem; color: var(--muted); text-align: center; }
.sp-rate-btn kbd { margin-top: 4px; }
.sp-rate-btn.r-good b { color: var(--ok); }
.sp-rate-btn.r-ok b { color: var(--warn); }
.sp-rate-btn.r-again b { color: var(--bad); }
.sp-rate-btn.r-again { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }

.sp-actions { align-items: center; }
.sp-spacer { flex: 1; }
/* คำใบ้คีย์ลัด: แสดงเฉพาะเครื่องที่มีเมาส์/แป้นพิมพ์ — จอสัมผัสแสดงคำแนะนำแบบแตะแทน */
.sp-keys, .sp-touch { text-align: center; margin-top: 12px; }
.sp-keys, .sp-rate-btn kbd { display: none; }
@media (hover: hover) and (pointer: fine) {
  .sp-keys { display: block; }
  .sp-rate-btn kbd { display: inline-block; }
  .sp-touch { display: none; }
}

/* ---------- สรุปผล ---------- */
.sp-finish { max-width: 720px; }
.sp-review { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; text-align: left; }
.sp-review li {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border-left: 4px solid var(--border-strong);
}
.sp-review li.is-good { border-left-color: var(--ok); }
.sp-review li.is-ok { border-left-color: var(--warn); }
.sp-review li.is-again { border-left-color: var(--bad); }
.sp-review-score { flex: 0 0 auto; min-width: 3.4em; font-weight: 800; font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 4px; }
.is-good .sp-review-score { color: var(--ok); }
.is-ok .sp-review-score { color: var(--warn); }
.is-again .sp-review-score { color: var(--bad); }
.is-skip .sp-review-score { color: var(--muted); }
.sp-review-body { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.9; }
.sp-review-heard { color: var(--muted); }

/* ---------- จอเล็ก ---------- */
@media (max-width: 860px) {
  .sp-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .sp-card { padding: 16px 14px; gap: 14px; }
  .sp-sentence { font-size: 1.25rem; }
  .sp-result { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .sp-legend { justify-content: center; }
  .sp-rate-btn small { display: none; }
  .sp-mic { width: 104px; height: 104px; }
  .sp-review li { flex-wrap: wrap; }
}

/* ---------- หมายเหตุไมโครโฟน (บรรทัดเล็ก) + ตัวเลือกเพิ่มเติม ---------- */
.sp-recnote { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: -6px 0 14px; }
.sp-recnote > svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--indigo); }
.sp-recnote > span { flex: 1 1 220px; min-width: 0; }
@media (min-width: 761px) { .sp-recnote > span { flex: 0 1 auto; } }
.sp-link {
  border: none; background: none; padding: 4px 2px; min-height: 32px; cursor: pointer; font: inherit; font-weight: 600;
  color: var(--indigo); text-decoration: underline; text-underline-offset: 3px;
}
.sp-link:hover { color: var(--accent); }
.sp-help-now { margin: 10px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.sp-empty { margin: 0; }
.sp-more { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.sp-more > summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; padding: 8px 14px;
  cursor: pointer; font-weight: 700; list-style: none; border-radius: 12px;
}
.sp-more > summary::-webkit-details-marker { display: none; }
.sp-more > summary::before {
  content: ""; width: 7px; height: 7px; flex-shrink: 0; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.2s;
}
.sp-more[open] > summary::before { transform: rotate(45deg); }
.sp-more > summary:hover { background: var(--surface-2); }
.sp-more > summary .small { font-weight: 400; }
.sp-more-body { display: grid; gap: 16px; padding: 4px 14px 14px; }
.sp-help summary { padding: 4px 0; }
@media (pointer: coarse) {
  .sp-link { min-height: 44px; }
  .sp-help summary { padding: 11px 0; }
  .sp-setup .seg button, .sp-listen .btn, .sp-actions .btn, .sp-session #quit, #my-play { min-height: 44px; }
}
@media (max-width: 520px) {
  .sp-start-row .btn { flex: 1 1 100%; justify-content: center; }
}

/* คำใบ้ด้านเสียง (ไม่มีผลกับคะแนน) — สไตล์ป้ายอยู่ใน games.css (.err-chip) */
.sp-hint { display: grid; gap: 4px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.sp-hint p { margin: 0; color: var(--text); }
/* ===== css/views/plan.css ===== */
/* สไตล์เฉพาะหน้า แผนสอบ JLPT (#/plan) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืด และจอกว้าง 360px */

.plan-page .section-head { margin-top: 1.6em; }
.plan-intro { margin-bottom: 12px; }

/* ---------- ฟอร์ม ---------- */
.plan-form { max-width: 680px; display: grid; gap: 20px; padding: 20px; }
.plan-label { font-weight: 700; }
.plan-hint { margin: 0; }
.plan-opt-text { display: grid; gap: 4px; min-width: 0; }
.plan-date {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; max-width: 100%; color-scheme: light dark;
}
.plan-days { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-day {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--muted); font-weight: 700; cursor: pointer; font: inherit; font-weight: 700;
}
.plan-day:hover { border-color: var(--accent); }
/* วันที่เลือก: ขอบ accent + พื้นอ่อน (สีทึบสงวนไว้ให้ปุ่มหลัก) */
.plan-day.on { background: var(--accent-soft); border: 2px solid var(--accent); color: var(--accent); }
.plan-day:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.plan-date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.plan-date-th { color: var(--muted); }
.plan-date-th b { color: var(--text); }
.plan-submit .btn-lg { min-width: 12em; }
.plan-preview { display: grid; gap: 8px; }
.plan-preview p { margin: 0; }
.plan-est { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.plan-est > div { display: grid; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.plan-est strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.plan-est span { font-size: 0.8rem; color: var(--muted); }
.plan-verdict { font-weight: 700; padding: 8px 12px; border-radius: var(--radius-sm); border-left: 4px solid; }
.plan-verdict.ok { color: var(--ok); background: var(--ok-soft); }
.plan-verdict.warn { color: var(--warn); background: var(--warn-soft); }
.plan-verdict.bad { color: var(--bad); background: var(--bad-soft); }

/* ---------- ส่วนหัว: นับถอยหลัง ---------- */
.plan-hero { display: flex; align-items: center; gap: 22px; padding: 22px; }
.plan-count {
  flex-shrink: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: var(--accent-soft); color: var(--accent);
}
.plan-count strong { font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.plan-count span { font-weight: 700; }
.plan-hero-body { flex: 1; min-width: 0; }
.plan-hero-body h2 { margin: 0.1em 0 0.15em; }
.plan-hero-body p { margin: 0; }
.plan-status.ok { color: var(--ok); }
.plan-status.warn { color: var(--warn); }
.plan-status.bad { color: var(--bad); }
.plan-status.neutral { color: var(--indigo); }
.plan-overall { display: grid; gap: 6px; margin-top: 12px; }
.plan-big-note { font-weight: 700; color: var(--accent); margin-top: 6px !important; }
.plan-of { font-size: 0.95rem; color: var(--muted); }
.plan-stats { margin-top: 14px; }

/* ---------- วันนี้ / สัปดาห์นี้ ---------- */
.plan-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
.plan-tasks { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plan-task { padding: 12px 14px; }
.plan-task .lesson-title { font-size: 1rem; }
.plan-task.done { opacity: 0.75; }
.plan-task.first { border: 2px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-task.first .lesson-num { background: var(--accent); color: var(--accent-ink); }
.plan-start-tag { display: inline-block; align-self: flex-start; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.plan-task.done .lesson-num { background: var(--ok-soft); color: var(--ok); }
.plan-rest { margin: 0 0 10px; }
.plan-week-card { display: grid; gap: 10px; padding: 16px 18px; }
.plan-week-card p { margin: 0; }
.plan-mock { color: var(--indigo); font-weight: 600; }

.plan-row { display: grid; grid-template-columns: minmax(96px, 9em) minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.plan-row-name { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 600; min-width: 0; }
.plan-row-num { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 4.5em; }

/* ---------- เส้นทางรายสัปดาห์ ---------- */
.plan-details { padding: 0; }
.plan-details > summary { padding: 14px 18px; cursor: pointer; font-weight: 700; color: var(--accent); }
.plan-timeline { list-style: none; margin: 0; padding: 0 18px 16px; display: grid; gap: 0; }
.plan-week { position: relative; padding: 10px 0 10px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.plan-week::before {
  content: ''; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.plan-week.past::before { background: var(--border-strong); }
.plan-week.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.plan-week.buffer { border-left-style: dashed; }
.plan-week.exam::before { background: var(--accent); border-color: var(--accent); border-radius: 3px; }
.plan-week.exam { border-left-color: transparent; }
.plan-week.past .plan-week-sum { color: var(--muted); }
.plan-week-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.plan-week-sum { margin: 4px 0 0; }
.plan-pill-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- ความคืบหน้ารายระดับ ---------- */
.plan-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.plan-level { display: grid; gap: 8px; padding: 14px 16px; }
.plan-level-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.plan-level .plan-row { grid-template-columns: 5.5em minmax(0, 1fr) auto; }

.plan-meta { margin: 8px 0 0; }
.plan-disclaimer { margin-top: 18px; }
.plan-more { margin-top: 1.6em; }
.plan-more > summary { color: var(--text); }
.plan-more > summary .small { font-weight: 400; }
.plan-more-body { padding: 0 18px 16px; }
.plan-details > summary { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; }

@media (max-width: 860px) {
  .plan-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .plan-form { padding: 16px; }
  .plan-est { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-hero { flex-direction: column; align-items: stretch; text-align: left; padding: 18px; gap: 14px; }
  .plan-count { width: auto; height: auto; border-radius: var(--radius-sm); padding: 12px; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
  .plan-count strong { font-size: 2.2rem; }
  .plan-days { gap: 8px; }
  .plan-submit .btn { flex: 1 1 100%; }
  .plan-manage .btn { flex: 1 1 auto; min-height: 44px; }
  .plan-more-body { padding: 0 12px 14px; }
  .plan-row { grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) auto; gap: 8px; }
  .plan-levels { grid-template-columns: minmax(0, 1fr); }
  .plan-timeline { padding: 0 12px 14px; }
}

/* ---------- "วันนี้" จาก JP.today: โครงร่างระหว่างรอ ---------- */
.plan-sk { min-height: 64px; pointer-events: none; }
.plan-sk .lesson-num { background: var(--surface-2); }
.plan-sk-line { display: block; height: 12px; width: 75%; margin: 4px 0; border-radius: 6px; background: var(--surface-2); }
.plan-sk-line.short { width: 45%; }
/* ===== css/views/achievements.css ===== */
/* สไตล์เฉพาะหน้า ความสำเร็จ (#/achievements) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืด และจอกว้าง 360px */

/* ---------- สีของขั้นเหรียญ (ผสมจากตัวแปรสีหลัก) ---------- */
.ach-page .bronze { --tc: color-mix(in srgb, var(--accent) 55%, var(--warn)); }
.ach-page .silver { --tc: color-mix(in srgb, var(--indigo) 50%, var(--muted)); }
.ach-page .gold { --tc: var(--warn); }
.ach-page .bronze, .ach-page .silver, .ach-page .gold { --tc-soft: color-mix(in srgb, var(--tc) 14%, var(--surface)); }

/* ---------- เหรียญ SVG ---------- */
.ach-medal { display: block; flex: none; overflow: visible; }
.ach-ribbon { fill: var(--surface-3); }
.ach-ribbon.r2 { fill: var(--border-strong); }
.ach-disc { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 2; }
.ach-ring { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 3 2.5; }
.ach-glyph { fill: var(--muted); font-family: var(--font-display); font-size: 21px; font-weight: 700; }

.got .ach-ribbon.r1, .ach-sum .ach-ribbon.r1 { fill: color-mix(in srgb, var(--tc) 70%, var(--surface)); }
.got .ach-ribbon.r2, .ach-sum .ach-ribbon.r2 { fill: color-mix(in srgb, var(--tc) 45%, var(--surface)); }
.got .ach-disc, .ach-sum .ach-disc { fill: var(--tc); stroke: color-mix(in srgb, var(--tc) 70%, var(--text)); }
.got .ach-ring, .ach-sum .ach-ring { stroke: color-mix(in srgb, var(--surface) 55%, transparent); stroke-dasharray: none; }
.got .ach-glyph, .ach-sum .ach-glyph { fill: var(--surface); }

/* ---------- ระดับนักเรียน ---------- */
.ach-rank { display: flex; gap: 20px; align-items: center; margin-bottom: 14px; }
.ach-rank-seal {
  flex: none; width: 84px; height: 84px; border-radius: 22px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 2.9rem; font-weight: 700; line-height: 1;
  color: var(--accent-ink); background: var(--accent); box-shadow: var(--shadow); transform: rotate(-4deg);
}
.ach-rank-body { flex: 1; min-width: 0; }
.ach-rank-body h2 { margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ach-rank-jp { font-size: 1rem; font-weight: 600; color: var(--muted); }
.ach-rank-body .progress { margin-bottom: 6px; }
.ach-rank-body p.small { margin: 0; }
.ach-ladder { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; }
.ach-ladder li {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  background: var(--surface-2); color: var(--faint); border: 1px solid var(--border);
}
.ach-ladder li.past { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ach-ladder li.now { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- สรุปจำนวนเหรียญ ---------- */
.ach-summary { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ach-summary .card { padding: 14px 16px; margin: 0; }
.ach-sum-main { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.ach-sum-main strong { font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ach-sum-main strong .muted { font-size: 1.05rem; }
.ach-sum-main > span { font-weight: 600; }
.ach-sum { display: flex; align-items: center; gap: 12px; background: var(--tc-soft); }
.ach-sum > div { display: flex; flex-direction: column; min-width: 0; }
.ach-sum strong { font-size: 1.45rem; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* ---------- ใกล้จะได้ / ได้รับล่าสุด ---------- */
.ach-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; margin-bottom: 6px; }
.ach-mini { margin: 0 0 6px; padding: 14px 16px; }
.ach-mini h3 { font-size: 1rem; margin: 0 0 8px; }
.ach-mini ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.ach-mini li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ach-mini li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ach-mini li b { font-size: 0.95rem; }
.ach-mini li .small.muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ach-mini .progress { height: 6px; margin-top: 3px; }
.ach-pct { font-weight: 700; color: var(--tc); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }

.ach-bar > span { background: var(--tc, var(--accent)); }
.ach-toolbar { margin-top: 18px; }
.ach-filter button { min-height: 40px; }
.ach-near-note { margin: 4px 0 10px; }
.ach-more { margin-top: 14px; }

/* ---------- กลุ่มเหรียญ (พับได้) ---------- */
.ach-group { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ach-group > summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; cursor: pointer;
  list-style: none; font-weight: 700; font-size: 1.05rem; border-radius: inherit;
}
.ach-group > summary::-webkit-details-marker { display: none; }
.ach-group > summary:hover { background: var(--surface-2); }
.ach-group > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ach-gname { flex: 1; min-width: 0; }
.ach-chev { display: inline-flex; color: var(--muted); transition: transform 0.15s; }
.ach-group[open] > .ach-chev, .ach-group[open] > summary .ach-chev { transform: rotate(180deg); }
.ach-group > .ach-grid { padding: 4px 12px 12px; }
.ach-gjp {
  width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
  font-family: var(--font-display); font-size: 1.1rem; background: var(--indigo-soft); color: var(--indigo);
}
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }

.ach-badge { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin: 0; min-width: 0; }
.ach-badge.got { border-color: color-mix(in srgb, var(--tc) 45%, var(--border)); background: linear-gradient(135deg, var(--tc-soft), var(--surface) 70%); }
a.ach-badge { color: var(--text); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
a.ach-badge:hover { border-color: var(--accent); }
a.ach-badge:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ach-badge.fresh { box-shadow: 0 0 0 2px var(--tc), var(--shadow); animation: ach-pop 0.6s ease-out both; }
.ach-icon { flex: none; padding-top: 2px; }
.ach-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ach-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding-right: 26px; }
.ach-title h3 { font-size: 1rem; margin: 0; line-height: 1.35; }
.ach-how { margin: 0; color: var(--muted); }
.ach-date { margin: 2px 0 0; color: var(--muted); }
.ach-prog { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.ach-prog .progress { height: 7px; }
/* ทั้งการ์ดเป็นลิงก์ — "ไปฝึก" เป็นป้ายบอกเท่านั้น (พื้นที่แตะ = ทั้งการ์ด) */
.ach-go { align-self: flex-start; color: var(--accent); font-weight: 700; margin-top: 4px; }
a.ach-badge:hover .ach-go { text-decoration: underline; }
.ach-tier {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
  color: var(--tc); background: var(--tc-soft); border: 1px solid color-mix(in srgb, var(--tc) 35%, transparent);
}

@keyframes ach-pop {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .ach-badge.fresh { animation: none; } }

/* ---------- จอเล็ก ---------- */
@media (max-width: 860px) {
  .ach-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ach-sum-main { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .ach-rank { gap: 14px; align-items: flex-start; }
  .ach-rank-seal { width: 58px; height: 58px; border-radius: 16px; font-size: 2rem; }
  .ach-rank-body h2 { font-size: 1.25rem; }
  .ach-summary { gap: 8px; }
  .ach-sum { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
  .ach-sum strong { font-size: 1.2rem; }
  .ach-ladder li { width: 26px; height: 26px; font-size: 0.9rem; }
  .ach-badge { gap: 10px; padding: 12px; }
  .ach-group > .ach-grid { padding: 4px 8px 10px; }
  .ach-filter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .ach-filter button { min-height: 44px; }
  .ach-more .btn { flex: 1 1 100%; }
  .ach-icon .ach-medal { width: 42px; height: 47px; }
}
/* ===== css/views/insights.css ===== */
/* สไตล์เฉพาะหน้า วิเคราะห์รายบุคคล (#/insights) — ใช้ตัวแปรสีเท่านั้น รองรับโหมดมืด จอกว้าง 360px และการพิมพ์ */

.ins-page h3 { font-size: 1rem; margin: 0.9em 0 0.45em; }
.ins-page .card > h3:first-child { margin-top: 0; }
.ins-head { margin-bottom: 6px; }
.ins-stamp { margin: 0 0 4px; }
.ins-sec { margin-top: 0.4em; }
.ins-tiles { margin-top: 10px; }
.ins-tiles .stat strong { font-size: 1.55rem; }
.ins-na { color: var(--faint); }
.ins-note { margin: 12px 0 0; }
.ins-need { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 0.92rem; }
.ins-need-cell { color: var(--muted); font-size: 0.88rem; }
.ins-good { color: var(--ok); font-weight: 700; }
.ins-bad { color: var(--bad); font-weight: 700; }
.ins-warn-text { color: var(--warn); margin-top: 3px; }
.ins-big { font-size: 2rem; font-weight: 700; margin: 0; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ins-big small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.ins-cite { color: var(--faint); }

/* ---------- เลย์เอาต์ ---------- */
.ins-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.ins-cols-growth { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.ins-chart-card { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.ins-chart { width: 100%; min-height: 40px; }
.ins-radar-card { display: flex; flex-direction: column; align-items: center; }
.ins-radar-card .ins-chart { display: flex; justify-content: center; }
.ins-radar-card p { margin: 4px 0 0; align-self: flex-start; }
.ins-svg { display: block; max-width: 100%; overflow: visible; }

/* ---------- สีของทักษะ (ใช้ตัวแปร --c) ---------- */
.ins-c-vocab { --c: var(--accent); }
.ins-c-kanji { --c: var(--indigo); }
.ins-c-grammar { --c: var(--ok); }
.ins-c-reading { --c: var(--warn); }
.ins-c-listening { --c: color-mix(in srgb, var(--indigo) 50%, var(--accent)); }
.ins-c-kana { --c: var(--muted); }
.ins-c-conjugation { --c: color-mix(in srgb, var(--ok) 50%, var(--indigo)); }
.ins-c-dictation { --c: color-mix(in srgb, var(--warn) 55%, var(--accent)); }
.ins-c-speaking { --c: color-mix(in srgb, var(--ok) 50%, var(--warn)); }
.ins-c-overall { --c: var(--text); }
.ins-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); vertical-align: 0; flex: none; }

/* ---------- องค์ประกอบใน SVG ---------- */
.ins-grid { stroke: var(--border); stroke-width: 1; }
.ins-grid-poly { fill: none; stroke: var(--border); stroke-width: 1; }
.ins-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.ins-axis.strong { fill: var(--text); font-weight: 600; }
.ins-label { fill: var(--text); font-size: 12px; font-family: var(--font); }
.ins-label.strong { font-weight: 700; }
.ins-hit { fill: transparent; }
g:hover > .ins-hit { fill: var(--surface-2); }
.ins-ci { stroke: var(--c); stroke-width: 6; stroke-linecap: round; opacity: 0.35; }
.ins-pt { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.ins-leader { stroke: var(--c); stroke-width: 1; }
.ins-pt-label { fill: var(--text); font-size: 11px; font-family: var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.ins-radar { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.ins-radar-band { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: color-mix(in srgb, var(--accent) 40%, transparent); stroke-width: 1; stroke-dasharray: 4 3; }
.ins-radar-in { fill: var(--surface); fill-opacity: 0.6; stroke: color-mix(in srgb, var(--accent) 40%, transparent); stroke-width: 1; stroke-dasharray: 4 3; }
.ins-fit { fill: none; stroke: var(--indigo); stroke-width: 2; }
.ins-pred { fill: none; stroke: var(--warn); stroke-width: 2; stroke-dasharray: 5 4; }
.ins-obs { fill: color-mix(in srgb, var(--accent) 70%, transparent); stroke: var(--surface); stroke-width: 2; }
.ins-zone-good { fill: var(--ok-soft); }
.ins-zone-label { fill: var(--ok); font-size: 11px; font-weight: 600; font-family: var(--font); }
.ins-ref { stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 4 4; }
.ins-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ins-line.strong { stroke-width: 3; }
.ins-dot { fill: var(--c); stroke: var(--surface); stroke-width: 1.5; }
.ins-target { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 6 4; }
.ins-target-label { fill: var(--warn); font-size: 11px; font-weight: 600; font-family: var(--font); }
.ins-bar { fill: color-mix(in srgb, var(--accent) 70%, var(--surface-3)); }

/* ---------- คำอธิบายสัญลักษณ์ ---------- */
.ins-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); }
.ins-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.ins-legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.ins-k-obs { background: color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 50% !important; width: 10px !important; }
.ins-k-fit { height: 0 !important; border-top: 2px solid var(--indigo); border-radius: 0 !important; }
.ins-k-pred { height: 0 !important; border-top: 2px dashed var(--warn); border-radius: 0 !important; }
.ins-k-mark { width: 2px !important; height: 12px !important; background: var(--muted); border-radius: 0 !important; }
.ins-k-mark.strong { background: var(--text); }
.ins-k-a { background: var(--ok); }
.ins-k-b { background: var(--bad); }
.ins-k-c { background: var(--surface-3); }
.ins-k-zone { background: var(--ok-soft); border: 1px solid var(--ok); }

/* ---------- คำแนะนำ ---------- */
.ins-recs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ins-rec { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; padding: 14px 16px; }
.ins-rec-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.ins-rec h3 { margin: 0 0 4px; font-size: 1rem; }
.ins-rec p { margin: 2px 0; }
.ins-rec-ev { font-size: 0.92rem; }
.ins-rec .pill { margin-right: 4px; }
.ins-rec-go { white-space: nowrap; }

/* ---------- ตาราง ---------- */
.ins-table-card { overflow-x: auto; margin-top: 14px; padding: 8px 6px; }
.ins-cols .ins-table-card { margin-top: 0; }
.ins-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.ins-table caption { text-align: left; padding: 4px 8px 8px; caption-side: top; }
.ins-table th, .ins-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.ins-table thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.ins-table tbody th { font-weight: 600; white-space: nowrap; }
.ins-table .ins-tag { white-space: normal; }
.ins-nw { white-space: nowrap; }
.ins-m-only { display: none; margin-top: 3px; }
.ins-table tbody tr:last-child > * { border-bottom: 0; }
.ins-p { text-align: center !important; font-weight: 600; background: color-mix(in srgb, var(--ok) calc(var(--p) * 38%), transparent); }

/* ---------- โอกาสสอบผ่าน ---------- */
.ins-pass-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.ins-pass { display: flex; flex-direction: column; gap: 6px; padding: 14px; }
.ins-pass-top { display: flex; justify-content: space-between; align-items: baseline; }
.ins-pass-lv { font-weight: 700; font-size: 1.05rem; }
.ins-pass-top strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.ins-pass.good .progress > span { background: var(--ok); }
.ins-pass.mid .progress > span { background: var(--warn); }
.ins-pass.low .progress > span { background: var(--bad); }
.ins-pass-secs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ins-pass-secs li { display: flex; justify-content: space-between; gap: 6px; }
.ins-pass-secs li > span:first-child { color: var(--muted); }
.ins-ok-pill { background: var(--ok-soft); color: var(--ok); }
.ins-pass-ex { margin-top: auto; }

/* ---------- แถบความคืบหน้า/ช่วง ---------- */
.ins-bar-row { margin: 10px 0; }
.ins-bar-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 5px; }
.ins-bar-val { margin-left: auto; font-variant-numeric: tabular-nums; }
.ins-progress > span { background: var(--c); }
.ins-range, .ins-gauge-track, .ins-cal-track, .ins-split { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: visible; }
.ins-range-v { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
.ins-range-ci { position: absolute; top: -3px; bottom: -3px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.ins-gauge { margin: 10px 0; }
.ins-gauge-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--bad); }
.ins-gauge.mid .ins-gauge-fill { background: var(--warn); }
.ins-gauge.good .ins-gauge-fill { background: var(--ok); }
.ins-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--muted); }
.ins-mark.strong { background: var(--text); }
.ins-cal-zone { position: absolute; top: 0; bottom: 0; background: var(--ok-soft); border-left: 1px solid var(--ok); border-right: 1px solid var(--ok); }
.ins-cal-pt { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.ins-split { display: flex; overflow: hidden; gap: 2px; }
.ins-split > span { height: 100%; }
.ins-split-a { background: var(--ok); }
.ins-split-b { background: var(--bad); }

.ins-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.ins-tag.ok { background: var(--ok-soft); color: var(--ok); }
.ins-tag.mid { background: var(--warn-soft); color: var(--warn); }
.ins-tag.low { background: var(--bad-soft); color: var(--bad); }

/* ---------- รายการ ---------- */
.ins-risk { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.ins-risk li { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.ins-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ins-facts li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.ins-facts li > b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ins-facts li > span:not(.ins-key) { flex: 1; }

/* ---------- รูปแบบการฝึก ---------- */
.ins-strip { display: grid; grid-template-columns: repeat(28, minmax(0, 1fr)); gap: 3px; margin-bottom: 12px; }
.ins-strip span { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); }
.ins-strip .l1 { background: color-mix(in srgb, var(--ok) 30%, var(--surface-3)); }
.ins-strip .l2 { background: color-mix(in srgb, var(--ok) 55%, var(--surface-3)); }
.ins-strip .l3 { background: color-mix(in srgb, var(--ok) 80%, var(--surface-3)); }
.ins-strip .l4 { background: var(--ok); }
.ins-mini-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ins-mini-grid > div { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.ins-mini-grid b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ins-mini-grid span { font-size: 0.78rem; color: var(--muted); }

/* ---------- การเติบโต ---------- */
.ins-target-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 8px; }
.ins-date { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); color-scheme: light dark; max-width: 100%; }

/* ---------- ประเมินตนเอง / วิธีวิเคราะห์ ---------- */
.ins-self, .ins-methods details { border-bottom: 1px solid var(--border); padding: 8px 0; }
.ins-self:last-of-type, .ins-methods details:last-child { border-bottom: 0; }
.ins-self summary, .ins-methods summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-weight: 600; list-style: none; }
.ins-self summary::-webkit-details-marker, .ins-methods summary::-webkit-details-marker { display: none; }
.ins-self summary::before, .ins-methods summary::before { content: ""; width: 0; height: 0; border-left: 6px solid var(--muted); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform 0.15s; }
.ins-self[open] summary::before, .ins-methods details[open] summary::before { transform: rotate(90deg); }
.ins-self summary .small { font-weight: 400; color: var(--muted); }
.ins-self ul { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.ins-self label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 0.92rem; }
.ins-self input { margin-top: 4px; accent-color: var(--accent); }
.ins-methods p { margin: 6px 0; }
.ins-refs { margin: 8px 0 0; padding-left: 1.4em; display: grid; gap: 4px; overflow-wrap: anywhere; }
.ins-disclaimer { margin: 0 0 8px; }

/* ---------- ส่วนพับ: การวิเคราะห์เพิ่มเติม / วิธีคำนวณ ---------- */
.ins-more { margin-top: 1.6em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ins-more > summary, .ins-methods-all > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-height: 52px; padding: 10px 16px;
  cursor: pointer; font-weight: 700; list-style: none; border-radius: inherit;
}
.ins-more > summary::-webkit-details-marker, .ins-methods-all > summary::-webkit-details-marker { display: none; }
.ins-more > summary::before, .ins-methods-all > summary::before {
  content: ""; width: 0; height: 0; border-left: 7px solid var(--accent); border-top: 6px solid transparent; border-bottom: 6px solid transparent; transition: transform 0.15s;
}
.ins-more[open] > summary::before, .ins-methods-all[open] > summary::before { transform: rotate(90deg); }
.ins-more > summary:hover, .ins-methods-all > summary:hover { background: var(--surface-2); }
.ins-more > summary > span:first-child { color: var(--accent); }
.ins-more > summary .small, .ins-methods-all > summary .small { font-weight: 400; flex-basis: 100%; padding-left: 17px; }
.ins-more > .ins-sec { padding: 0 16px 16px; }
.ins-foot { margin-top: 2em; }
.ins-methods-all { padding: 0; }
.ins-methods-all > .ins-methods, .ins-methods-all > p, .ins-methods-all > .btn-row { margin-left: 16px; margin-right: 16px; }
.ins-methods-all > .btn-row { margin-bottom: 16px; }

/* ---------- คำแนะนำ ---------- */
.ins-rec.first { border: 2px solid var(--accent); }
.ins-why { margin-top: 4px; }
.ins-why > summary { cursor: pointer; color: var(--indigo); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.ins-why p { margin: 4px 0 0; }
.ins-recs-more { margin-top: 8px; }
.ins-recs-more > summary { cursor: pointer; color: var(--accent); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.ins-rec-go { min-height: 44px; }

/* ---------- ป้าย "ทดลอง" (เนื้อหาที่ยังไม่ได้ตรวจโดยผู้รู้) / ลิงก์แผนวันนี้ ---------- */
.ins-beta { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; line-height: 1.6; vertical-align: 0.15em; white-space: nowrap; background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
h2 .ins-beta, h3 .ins-beta { font-size: 0.7rem; }
.ins-today { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-height: 44px; margin: 0 0 10px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; }
.ins-today[hidden] { display: none; }
.ins-today:hover { border-color: var(--accent); }
.ins-today > span:not(.ins-today-go) { color: var(--muted); font-size: 0.92rem; }
.ins-today-go { margin-left: auto; color: var(--accent); font-weight: 700; }

/* ---------- รูปแบบข้อผิดด้านเสียง (ใช้ในหน้าสถิติด้วย) ---------- */
.ins-snd { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 0; }
.ins-snd-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: 6px 14px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.ins-snd-row:last-child { border-bottom: 0; }
.ins-snd-name { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.ins-snd-cell { display: grid; gap: 0; min-width: 0; line-height: 1.35; font-variant-numeric: tabular-nums; }
.ins-snd-k { font-size: 0.75rem; color: var(--muted); }
.ins-snd-go { min-height: 44px; justify-self: end; grid-column: 4; grid-row: 1; }
.ins-snd-advice { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.ins-snd-typed { white-space: nowrap; }
.ins-snd-advice.ins-warn-text { color: var(--warn); }
.ins-snd-note { margin: 0 0 8px; }
.ins-snd-foot { margin: 8px 0 0; }
.ins-snd-card > h3:first-child, .ins-drill-card > h3:first-child { margin-top: 0; }

/* ---------- ตารางความสับสนคำช่วย ---------- */
.ins-conf-top { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ins-conf-top li { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--bad-soft); color: var(--text); }
.ins-conf-top .jp { font-size: 1.05rem; font-weight: 600; }
.ins-conf-top b { color: var(--bad); font-variant-numeric: tabular-nums; }
.ins-conf-arrow { color: var(--muted); }
.ins-conf-cap { margin: 0 0 4px; }
.ins-conf-wrap { margin: 0 0 10px; padding: 4px 2px; }
.ins-drill-card .btn-row { margin: 0 0 6px; }
.ins-drill-note { margin: 10px 0 0; }
.ins-conf th, .ins-conf td { text-align: center !important; padding: 6px 6px; }
.ins-conf thead th:first-child { text-align: left !important; }
.ins-conf tbody th { text-align: center !important; font-size: 1.05rem; }
.ins-conf .jp { font-weight: 600; }
.ins-cf-0 { color: var(--faint); }
.ins-cf-ok { font-weight: 600; background: color-mix(in srgb, var(--ok) calc(var(--p) * 35%), transparent); }
.ins-cf-bad { font-weight: 700; background: color-mix(in srgb, var(--bad) calc(10% + var(--p) * 45%), transparent); }
.ins-cf-n { color: var(--muted); font-size: 0.82rem; }
.ins-fact-sub { display: block; font-weight: 400; }

/* ---------- ข้อสอบที่มีบทเคยเห็น ---------- */
.ins-seen { line-height: 1.35; }
.ins-seen-note { margin: 10px 0 0; }

/* ---------- หน้าว่าง ---------- */
.ins-empty { text-align: left; max-width: 640px; }
.ins-empty-title { font-size: 1.1rem; margin: 0 0 4px; }
.ins-empty-list { margin: 6px 0 16px; padding-left: 1.3em; display: grid; gap: 4px; }

/* ---------- จอแคบ ---------- */
@media (max-width: 1100px) {
  .ins-pass-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .ins-cols, .ins-cols-growth { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .ins-pass-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ins-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ins-rec { grid-template-columns: auto minmax(0, 1fr); }
  .ins-rec-go { grid-column: 2; justify-self: start; }
  .ins-strip { gap: 2px; }
  .ins-m-only { display: block; }
  .ins-d-only { display: none; }
  .ins-more > .ins-sec { padding: 0 10px 12px; }
  .ins-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ins-empty .btn-row .btn { flex: 1 1 100%; }
  .ins-snd-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ins-snd-name { grid-column: 1 / -1; }
  .ins-snd-go { grid-column: 1 / -1; grid-row: auto; justify-self: start; }
}
@media (max-width: 400px) {
  .ins-pass-grid { grid-template-columns: minmax(0, 1fr); }
  .ins-tiles .stat strong { font-size: 1.3rem; }
  .ins-table th, .ins-table td { padding: 6px 5px; }
}

/* ---------- พิมพ์ / บันทึก PDF ---------- */
@media print {
  body:has(.ins-page) .sidebar, body:has(.ins-page) .topbar, body:has(.ins-page) .scrim, body:has(.ins-page) .skip-link { display: none !important; }
  body:has(.ins-page) .main-col { margin-left: 0 !important; }
  body:has(.ins-page) .container { padding: 0; max-width: none; }
  .ins-noprint, .ins-rec-go, .ins-snd-go { display: none !important; }
  .ins-conf-wrap { overflow: visible; }
  .ins-page .card { box-shadow: none; break-inside: avoid; }
  .ins-sec .section-head { break-after: avoid; }
  .ins-page { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ins-rec { grid-template-columns: auto minmax(0, 1fr); }
}
/* ===== css/views/about.css ===== */
/* สไตล์เฉพาะหน้า เกี่ยวกับแอป (#/about) — ใช้ตัวแปรสีเท่านั้น */
.ab-grid { display: grid; gap: 16px; max-width: 820px; }
.ab-sec { min-width: 0; overflow-wrap: anywhere; }
.ab-sec h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.2rem; }
.ab-sec h3 { margin: 14px 0 6px; font-size: 1rem; }
.ab-sec p { margin: 0 0 10px; line-height: 1.7; }
.ab-sec p:last-child { margin-bottom: 0; }
.ab-sec ul { margin: 0 0 10px; padding-left: 1.25em; display: grid; gap: 6px; line-height: 1.65; }
.ab-sec a { color: var(--indigo); }
.ab-notice { border-left: 4px solid var(--warn); }
.ab-flag { display: inline-grid; place-items: center; vertical-align: -3px; color: var(--bad); }
.ab-flag svg { width: 15px; height: 15px; }
.ab-sec h2 svg { color: var(--bad); }
.ab-sec code { font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }

/* เครดิต */
.ab-credits { list-style: none; padding: 0 !important; }
.ab-credits li { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.ab-credit-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; margin-bottom: 2px; }

/* รายงานที่เก็บไว้ในเครื่อง */
.ab-rep-actions { margin: 10px 0; }
.ab-reps { list-style: none; padding: 0 !important; max-height: 420px; overflow: auto; }
.ab-rep { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.ab-rep-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-rep-top .pill.bad { background: var(--bad-soft); color: var(--bad); }
.ab-rep-id { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; color: var(--text); overflow-wrap: anywhere; }
.ab-rep-ctx { color: var(--text); }
.ab-rep-note { color: var(--muted); }
.ab-empty { margin-top: 6px; }

/* ข้อผิดพลาดของโปรแกรม (JP.errlog) */
.ab-errs { list-style: none; padding: 0 !important; max-height: 460px; overflow: auto; }
.ab-err { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); min-width: 0; }
.ab-err-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-err-kind { background: var(--warn-soft); color: var(--text); }
.ab-err-msg { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.ab-err-meta { overflow-wrap: anywhere; }
.ab-err-stack { font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; }

/* เวอร์ชัน + อัปเดต */
.ab-upd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 480px) {
  .ab-grid { gap: 12px; }
  .ab-rep-actions .btn { flex: 1 1 auto; }
  .ab-err { padding: 8px 10px; }
}
/* ===== css/views/ear.css ===== */
/* หน้าฝึกหูคู่เสียง (#/ear) — ใช้ตัวแปรสีเท่านั้น · ใช้ได้ที่จอ 360px ทั้งสองธีม */
.ear-setup { display: grid; gap: 16px; margin-bottom: 16px; }
.ear-row { display: grid; gap: 6px; }
.ear-row .field-label { font-weight: 700; }
.ear-row .seg button { min-height: 40px; }
.ear-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ear-cat {
  display: grid; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer; font: inherit;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); min-height: 64px; min-width: 0;
}
.ear-cat:hover:not(:disabled) { border-color: var(--accent); }
.ear-cat.on { border-color: var(--accent); background: var(--sel-bg); box-shadow: inset 0 0 0 0.5px var(--accent); }
.ear-cat-name { font-weight: 700; }
.ear-cat-ex { font-family: var(--font-jp); font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.ear-cat-meta { font-size: 0.8rem; color: var(--muted); }
.ear-go { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ear-why h2 { margin: 0 0 8px; font-size: 1.05rem; }
.ear-why-list { margin: 0 0 8px; padding-left: 1.2em; display: grid; gap: 6px; line-height: 1.6; }

/* ระหว่างรอบ */
.ear-card .q-label { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.ear-chip { font-size: 0.78rem; }
.ear-play { position: relative; }
.ear-play.on { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 6px var(--accent); }
.ear-play .kbd-hint { font-size: 0.7rem; }
.ear-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ear-choice { flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; text-align: center; position: relative; color: var(--text); }
.ear-choice kbd { position: absolute; top: 8px; left: 8px; }
.ear-kana { font-family: var(--font-display); font-size: clamp(1.4rem, 1rem + 2.4vw, 2rem); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.ear-word { font-size: 1.15rem; font-weight: 700; }
.ear-mean { font-size: 0.82rem; font-weight: 500; color: var(--muted); overflow-wrap: anywhere; }
.ear-choice.correct .ear-mean, .ear-choice.incorrect .ear-mean { color: inherit; }
.ear-cmp { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.ear-cmp .btn span[lang] { font-family: var(--font-jp); }
.ear-pair { text-align: left; line-height: 1.8; }
.ear-fb-k { font-weight: 700; }
.ear-tip { margin: 0; color: var(--text); max-width: 520px; text-align: left; }

/* หน้าจบ */
.ear-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.92rem; text-align: left; }
.ear-table th, .ear-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.ear-table th { color: var(--muted); font-weight: 600; }
.ear-finish .mistakes li { flex-wrap: wrap; background: var(--surface-2); }
.ear-finish .mistakes li > span:last-child { margin-left: 0; }

@media (max-width: 520px) {
  .ear-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ear-choice { min-height: 88px; padding: 10px 8px; }
  .ear-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ear-cat { padding: 8px 10px; }
  .ear-go .btn { width: 100%; justify-content: center; }
}
/* ===== css/views/numbers.css ===== */
/* หน้าตัวเลขและลักษณนาม (#/numbers) — ใช้ตัวแปรสีเท่านั้น · ใช้ได้ที่จอ 360px ทั้งสองธีม */
.nb-setup { display: grid; gap: 14px; margin-bottom: 18px; }
.nb-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.nb-mode {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
.nb-mode:hover:not(:disabled) { border-color: var(--accent); }
.nb-mode.on { border-color: var(--accent); background: var(--sel-bg); box-shadow: inset 0 0 0 0.5px var(--accent); }
.nb-mode-icon {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-family: var(--font-jp); font-weight: 700; font-size: 1.2rem;
}
.nb-mode-body { display: grid; gap: 2px; min-width: 0; }
.nb-mode-title { font-weight: 700; }
.nb-mode-desc { font-size: 0.86rem; color: var(--muted); overflow-wrap: anywhere; }
.nb-mode-meta { font-size: 0.8rem; color: var(--muted); }
.nb-go { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nb-beta-note { margin: 0; }
.nb-notes h2 { font-size: 1.05rem; margin: 0 0 10px; }
.nb-notes .note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 16px; }
.nb-notes .note-card h3 { margin: 0 0 6px; font-size: 0.98rem; }
.nb-notes .note-card p { margin: 0; line-height: 1.7; }
.nb-table-wrap summary { cursor: pointer; padding: 4px 0; }
.nb-table-scroll { overflow-x: auto; margin-top: 10px; }
.nb-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 520px; }
.nb-table th, .nb-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.nb-table th { color: var(--muted); font-weight: 600; }
.nb-k { font-size: 1.2rem; font-weight: 700; }
.nb-forms { font-size: 0.95rem; }

/* ระหว่างรอบ */
.nb-prompt { margin-bottom: 4px; }
.nb-sub { margin: 0 0 14px; }
.nb-hint { margin: 8px 0 0; }
.nb-obj { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 8px 12px; }
.nb-obj-jp { font-size: 0.8em; color: var(--muted); }
.nb-thai { margin-bottom: 18px; }
.nb-choices .choice { min-height: 56px; }
.nb-ck { font-size: 1.5rem; font-family: var(--font-display); font-weight: 600; }
.nb-cth { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.nb-choices .choice.correct .nb-cth, .nb-choices .choice.incorrect .nb-cth { color: inherit; }
.nb-sent { grid-template-columns: minmax(0, 1fr); }
.nb-s { font-size: 1.15rem; }
.nb-listen-form { display: grid; gap: 12px; justify-items: center; }
.nb-fields { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.nb-num { display: inline-flex; align-items: center; gap: 6px; font-size: 1.15rem; font-weight: 700; }
.nb-num input { width: 5.5em; font-size: 1.2rem; text-align: center; padding: 10px; }
.nb-num input[maxlength="2"] { width: 3.6em; }
.nb-phone input { width: 12em; max-width: 100%; }
.nb-ans { font-size: 1.25rem; font-weight: 700; }
.nb-rule { margin: 0; max-width: 540px; text-align: left; }
.nb-card .feedback.near { padding: 14px; border-radius: 14px; background: var(--warn-soft); }
.nb-card .feedback.near .fb-head { color: var(--warn); }
.nb-finish .mistakes li { background: var(--surface-2); }

@media (max-width: 520px) {
  .nb-modes { grid-template-columns: minmax(0, 1fr); }
  .nb-go .btn { width: 100%; justify-content: center; }
  .nb-form.type-form { flex-direction: column; }
  .nb-form.type-form .btn { min-height: 44px; }
  .nb-num input { min-height: 44px; }
  .nb-choices { grid-template-columns: minmax(0, 1fr); }
}
/* ===== css/views/particles.css ===== */
/* หน้า "ฝึกคำช่วย" (#/particles) — js/views/particles.js · ตัวแปร --particles-css ใช้ตรวจว่าไฟล์นี้โหลดแล้ว (ไม่ต้องโหลดซ้ำ) */
:root { --particles-css: 1; }

.pt-beta, .bd-beta { background: var(--warn-soft); color: var(--text); }
.pt-notice { display: flex; gap: 8px; align-items: flex-start; font-size: 0.92rem; }
.pt-notice svg { flex-shrink: 0; margin-top: 2px; }

.pt-setup { display: grid; gap: 16px; margin-top: 14px; }
.pt-mode { justify-self: start; }
.pt-field { display: grid; gap: 6px; }
.pt-label { font-weight: 700; font-size: 0.92rem; }
.pt-sets { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-set {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600;
}
.pt-set small { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.pt-set.on { border-color: var(--accent); background: var(--sel-bg); }
.pt-set:hover:not(:disabled) { border-color: var(--accent); }
.pt-set:disabled { cursor: not-allowed; color: var(--muted); border-style: dashed; }
.pt-start { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.pt-lesson { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.pt-vt-rule { margin: 0; color: var(--muted); font-size: 0.95rem; }
.pt-also { margin-top: 14px; }

.pt-conf { margin-top: 14px; }
.pt-conf h2 { font-size: 1rem; margin: 0 0 8px; }
.pt-conf ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.pt-conf li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.pt-conf-pair { font-size: 1.15rem; }
.pt-conf-pair b { color: var(--ok); }

/* การ์ดโจทย์ */
.pt-card { text-align: center; }
.pt-set-pill { margin-left: 4px; }
.pt-th { font-size: 1.12rem; font-weight: 600; margin: 6px 0 10px; color: var(--text); }
.pt-q { font-size: clamp(1.35rem, 1.1rem + 1.4vw, 1.9rem); line-height: 2; margin: 4px 0 18px; overflow-wrap: anywhere; }
.pt-q rt { font-size: 0.5em; }
.pt-gap { color: var(--muted); margin-left: 2px; letter-spacing: 0.05em; }
.pt-choices { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.pt-choices .choice { justify-content: center; font-size: 1.35rem; min-height: 54px; }
.pt-choices .choice .jp { font-family: var(--font-display); font-weight: 600; }
.pt-vt-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pt-vt-choices .choice { justify-content: flex-start; font-size: 1.15rem; }
.pt-vt-choices .choice rt { font-size: 0.55em; }
.pt-vt-hint { font-size: 1.3rem; }

.pt-fb { text-align: left; justify-items: stretch; }
.pt-fb .fb-head { text-align: center; }
.pt-fb .romaji { text-align: center; color: var(--muted); }
.pt-alt { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--surface); font-size: 0.95rem; }
.pt-rule { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); border-left: 4px solid var(--indigo); font-size: 0.95rem; line-height: 1.6; }
.pt-fb-actions { flex-wrap: wrap; justify-content: center; }
.pt-vt-pair { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--surface); align-items: baseline; }
.pt-vt-pair dt { font-size: 1.1rem; font-weight: 600; }
.pt-vt-pair dd { margin: 0; color: var(--muted); font-size: 0.9rem; }

.pt-finish .mistakes li { flex-wrap: wrap; }
.pt-finish .mistakes li .jp { font-size: 1.05rem; font-weight: 600; }

@media (max-width: 520px) {
  .pt-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-vt-choices { grid-template-columns: minmax(0, 1fr); }
  .pt-vt-pair { grid-template-columns: minmax(0, 1fr); }
  .pt-start .btn { flex: 1 1 100%; }
  .pt-mode { justify-self: stretch; }
  .pt-mode button { flex: 1; }
}
/* ===== css/views/build.css ===== */
/* หน้า "เรียงประโยค" (#/build) — js/views/build.js · ตัวแปร --build-css ใช้ตรวจว่าไฟล์นี้โหลดแล้ว */
:root { --build-css: 1; }

.bd-notice { display: flex; gap: 8px; align-items: flex-start; font-size: 0.92rem; }
.bd-notice svg { flex-shrink: 0; margin-top: 2px; }
.bd-beta { background: var(--warn-soft); color: var(--text); }
.bd-setup { display: grid; gap: 14px; margin-top: 14px; }
.bd-field { display: grid; gap: 6px; }
.bd-label { font-weight: 700; font-size: 0.92rem; }
.bd-from { margin: 0; }
.bd-start { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.bd-how { margin-top: 14px; }
.bd-how h2 { font-size: 1rem; margin: 0 0 8px; }
.bd-how ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; color: var(--text); }
.bd-also { margin-top: 14px; }

/* การ์ดโจทย์ */
.bd-card { max-width: 720px; margin: 10px auto 0; padding: 22px 20px; text-align: center; }
.bd-th { font-size: 1.2rem; font-weight: 600; margin: 4px 0 14px; }
.bd-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; min-height: 64px;
  padding: 10px; border-radius: 14px; border: 2px dashed var(--border-strong); background: var(--surface-2); margin-bottom: 14px;
}
.bd-line.ok { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.bd-line.bad { border-style: solid; border-color: var(--bad); background: var(--bad-soft); }
.bd-ph { color: var(--muted); font-size: 0.92rem; }
.bd-final { font-size: 1.3rem; color: var(--muted); }
.bd-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 52px; }
.bd-tile {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; min-width: 44px; padding: 4px 12px;
  border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; line-height: 1.6; cursor: pointer;
  box-shadow: 0 1px 0 var(--border);
}
.bd-tile rt { font-size: 0.5em; font-weight: 500; }
.bd-tile:hover { border-color: var(--accent); }
.bd-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.bd-tile.bd-prt { border-color: color-mix(in srgb, var(--indigo) 45%, var(--border-strong)); }
.bd-line .bd-tile { background: var(--surface); }
.bd-ghost { visibility: hidden; cursor: default; }
.bd-actions { margin-top: 14px; }

.bd-fb { text-align: left; justify-items: stretch; }
.bd-fb .fb-head { text-align: center; }
.bd-fb .romaji { text-align: center; color: var(--muted); }
.bd-say { text-align: center; font-size: 1.3rem; line-height: 2; }
.bd-orig { margin: 0; text-align: center; color: var(--muted); }
.bd-orig .jp { color: var(--text); }
.bd-errs { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.bd-answer summary { cursor: pointer; font-weight: 600; }
.bd-answer > div { font-size: 1.25rem; line-height: 2; margin-top: 6px; }
.bd-type { display: grid; gap: 6px; justify-items: stretch; }
.bd-type .type-form { max-width: none; }
.bd-type .type-form input { font-size: 1.05rem; text-align: left; }
.bd-bad-text { color: var(--bad); font-weight: 700; }
.bd-fb-actions { flex-wrap: wrap; justify-content: center; }
.bd-tops { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; }
.bd-finish .mistakes li { flex-wrap: wrap; }
.bd-finish .mistakes li .jp { font-size: 1.05rem; font-weight: 600; }

@media (max-width: 520px) {
  .bd-card { padding: 16px 12px; }
  .bd-tile { font-size: 1.15rem; padding: 4px 10px; min-height: 46px; }
  .bd-start .btn { flex: 1 1 100%; }
}
/* ===== css/views/account.css ===== */
/* บัญชีสมาชิก: ปุ่มโปรไฟล์มุมบน · หน้าต่างเข้าสู่ระบบตอนเปิดแอป · ฟอร์มเข้าสู่ระบบ · หน้าโปรไฟล์ */

/* ---------- ปุ่มโปรไฟล์ ---------- */
.account-btn { display: inline-grid; place-items: center; text-decoration: none; color: var(--text); }
.account-btn[hidden] { display: none; }
.account-btn .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: .95rem; line-height: 1;
}
.account-btn:not(.signed-in) { color: var(--muted); }
.account-btn:hover .avatar { filter: brightness(1.08); }

/* ---------- ฟอร์มเข้าสู่ระบบ ---------- */
.account-box { max-width: 560px; }
.account-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 8px; }
.account-form input {
  flex: 1 1 220px; min-width: 0;
  font: inherit; font-size: 1.05rem;
  padding: 11px 12px; min-height: 46px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: inherit;
}
.account-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.account-form .btn { min-height: 46px; }
.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong, var(--border));
}
.or-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 2px; color: var(--muted); font-size: .9rem; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.mail-sent { text-align: center; padding: 6px 0 2px; }
.mail-sent-icon { font-size: 2.2rem; line-height: 1; margin-bottom: 6px; }
.mail-sent p { margin: 4px 0; }

/* ---------- หน้าต่างเข้าสู่ระบบตอนเปิดแอป (เต็มจอ อยู่เหนือหน้าแนะนำ) ---------- */
html.gate-open, html.gate-open body { overflow: hidden; }
#login-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg, var(--surface-2));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.gate-card {
  width: 100%; max-width: 440px; margin: auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 22px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .12);
}
.gate-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; margin-bottom: 18px; }
.gate-card h1 { font-size: 1.5rem; margin: 0 0 4px; }
.gate-lead { color: var(--muted); margin: 0 0 12px; }
.gate-points { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; font-size: .95rem; }
.gate-points li { color: var(--text); }
.gate-skip { width: 100%; margin-top: 8px; color: var(--muted); }

/* ---------- หน้าโปรไฟล์ ---------- */
.pf-head { display: flex; align-items: center; gap: 16px; }
.pf-avatar {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: 1.8rem; font-weight: 800;
}
.pf-id { min-width: 0; display: grid; gap: 6px; }
.pf-email { font-size: 1.2rem; margin: 0; word-break: break-all; }
.pf-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pf-sync.ok { color: var(--ok); }
.pf-sync.bad { color: var(--bad); }
.pf-sync.busy { color: var(--muted); }
.pf-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.pf-stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.pf-stat-v { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pf-stat-k { font-size: .85rem; color: var(--muted); }
.pf-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pf-sec-head h2 { margin: 0; }
.pf-signin h2 { font-size: 1.1rem; margin-top: 0; }

/* แถบความคืบหน้า */
.pf-bar { flex: 1; min-width: 60px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: block; }
.pf-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ความคืบหน้ารายระดับ */
.pf-levels { display: grid; gap: 8px; }
.pf-level { border: 1px solid var(--border); border-radius: 14px; padding: 0 12px; }
.pf-level.current { border-color: var(--accent); }
.pf-level summary { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; list-style: none; }
.pf-level summary::-webkit-details-marker { display: none; }
.pf-lv { font-weight: 800; width: 2.4em; }
.pf-lv-pct { font-weight: 700; font-variant-numeric: tabular-nums; width: 3.2em; text-align: right; }
.pf-rows { display: grid; gap: 8px; padding: 0 0 12px; }
.pf-row { display: grid; grid-template-columns: 5.5em 1fr auto; align-items: center; gap: 10px; font-size: .92rem; }
.pf-row .pf-bar { height: 6px; }
.pf-row .pf-bar > span { background: var(--ok); }
.pf-row-v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-row-v small { color: var(--muted); }

/* กิจกรรม 12 สัปดาห์ (คอลัมน์ = สัปดาห์, แถว = อาทิตย์–เสาร์) */
.pf-heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; justify-content: start; overflow-x: auto; padding-bottom: 4px; }
.pf-day { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); display: inline-block; }
.pf-day.empty { background: transparent; }
.pf-day.l1 { background: color-mix(in srgb, var(--ok) 30%, var(--surface-2)); }
.pf-day.l2 { background: color-mix(in srgb, var(--ok) 55%, var(--surface-2)); }
.pf-day.l3 { background: color-mix(in srgb, var(--ok) 80%, var(--surface-2)); }
.pf-day.l4 { background: var(--ok); }
.pf-heat-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.pf-heat-legend .pf-day { width: 11px; height: 11px; }
.pf-heat-total { margin-left: auto; }

/* ผลสอบ */
.pf-exams { display: grid; gap: 6px; }
.pf-exam { display: grid; grid-template-columns: 2.6em 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 12px; }
.pf-exam-lv { font-weight: 800; }
.pf-exam-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.pf-pass { background: var(--ok); color: var(--ok-ink, #fff); }
.pf-fail { background: var(--surface-3, var(--border)); }

.pf-danger summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.pf-danger[open] summary { margin-bottom: 8px; }
.bad-text { color: var(--bad); }

@media (max-width: 420px) {
  .pf-avatar { width: 52px; height: 52px; font-size: 1.5rem; }
  .pf-stats { grid-template-columns: 1fr 1fr; }
}
