﻿:root {
  --bg: #dbeafe;
  --card: #eef6f3;
  --text: #0f172a;
  --muted: #5b6b7c;
  --border: #b5c9c2;
  --accent: #0369a1;
  --accent-soft: #e0f2fe;
  --you: #0369a1;
  --other: #b45309;
  --thai: #be123c;
  --shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
  --font-display: 'Outfit', 'Segoe UI', sans-serif;
  --font-thai: 'Sarabun', 'Segoe UI', sans-serif;
}
html.dark body, body.dark {
  --bg: #0b1220;
  --card: #111827;
  --text: #e5eef7;
  --muted: #94a3b8;
  --border: #1e293b;
  --accent: #38bdf8;
  --accent-soft: #0c4a6e;
  --you: #38bdf8;
  --other: #fb923c;
  --thai: #fb7185;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  font-family: var(--font-display);
  margin: 0;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(1000px 420px at 0% 0%, rgba(45, 212, 191, 0.28), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(251, 146, 60, 0.16), transparent 50%),
    linear-gradient(180deg, #bfdbfe 0%, var(--bg) 45%, #dbeafe 100%);
  color: var(--text);
}
.wrap { max-width: 920px; margin: 0 auto; }

.tm-hero h1 .th {
  display: block;
  font-family: var(--font-thai);
  font-size: 0.72em;
  font-weight: 700;
  opacity: 0.92;
  margin-top: 4px;
}
.tm-lead .th {
  display: block;
  font-family: var(--font-thai);
  margin-top: 4px;
  opacity: 0.9;
}

.sc-panel {
  margin-top: 14px;
  padding: 14px 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #e0f2fe 0%, #fff 55%, #ffedd5 100%);
  box-shadow: var(--shadow);
}
html.dark .sc-panel, body.dark .sc-panel {
  background: linear-gradient(160deg, #0c4a6e 0%, #0f172a 55%, #431407 100%);
  border-color: #334155;
}
.sc-head h2, .sc-scene-titles h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}
.sc-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.sc-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 10px;
}
.sc-cat {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.sc-cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
html.dark .sc-cat, body.dark .sc-cat { background: #1e293b; color: #e2e8f0; }
html.dark .sc-cat.active, body.dark .sc-cat.active { background: var(--accent); color: #0c4a6e; }

.sc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.sc-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 118px;
  padding: 12px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: transform 0.12s, border-color 0.15s;
}
.sc-card:hover { transform: translateY(-2px); border-color: var(--accent); }
html.dark .sc-card, body.dark .sc-card { background: #1e293b; }
.sc-card-emoji { font-size: 1.7rem; line-height: 1; }
.sc-card-en { font-weight: 800; font-size: 0.92rem; }
.sc-card-th { font-family: var(--font-thai); font-weight: 700; font-size: 0.85rem; color: var(--thai); }
.sc-card-meta { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.sc-meta { margin: 10px 0 0; font-size: 0.78rem; color: var(--muted); font-weight: 600; }

.sc-back {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 12px;
}
html.dark .sc-back, body.dark .sc-back { background: #1e293b; color: #e2e8f0; }
.sc-scene-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.sc-scene-emoji { font-size: 2.4rem; line-height: 1; }
.sc-scene-th {
  margin: 2px 0 0;
  font-family: var(--font-thai);
  font-weight: 700;
  color: var(--thai);
  font-size: 1rem;
}
.sc-tip {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.1);
  border: 1px dashed var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.35;
}
.sc-tip .th { display: block; font-family: var(--font-thai); margin-top: 3px; color: var(--muted); }
.sc-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.sc-role {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}
.sc-role.you { background: color-mix(in srgb, var(--you) 18%, #fff); color: var(--you); }
.sc-role.other { background: color-mix(in srgb, var(--other) 18%, #fff); color: var(--other); }

.sc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.sc-tool {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.sc-tool.secondary { opacity: 0.9; }
.sc-tool.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sc-tool[aria-pressed="true"] {
  background: #0369a1;
  border-color: #0369a1;
  color: #fff;
}
html.dark .sc-tool, body.dark .sc-tool { background: #1e293b; color: #e2e8f0; }
html.dark .sc-tool.accent, body.dark .sc-tool.accent,
html.dark .sc-tool[aria-pressed="true"], body.dark .sc-tool[aria-pressed="true"] {
  background: var(--accent);
  color: #0c4a6e;
}
.sc-status {
  min-height: 1.2em;
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.sc-status.ok { color: #15803d; }
.sc-status.bad { color: #b91c1c; }

.sc-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sc-bubble {
  max-width: min(92%, 520px);
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  animation: scIn 0.22s ease;
}
@keyframes scIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
html.dark .sc-bubble, body.dark .sc-bubble { background: #1e293b; }
.sc-bubble.you {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--you) 45%, var(--border));
  background: color-mix(in srgb, var(--you) 10%, #fff);
}
.sc-bubble.other {
  align-self: flex-start;
  border-color: color-mix(in srgb, var(--other) 45%, var(--border));
  background: color-mix(in srgb, var(--other) 10%, #fff);
}
html.dark .sc-bubble.you, body.dark .sc-bubble.you {
  background: color-mix(in srgb, var(--you) 18%, #0f172a);
}
html.dark .sc-bubble.other, body.dark .sc-bubble.other {
  background: color-mix(in srgb, var(--other) 18%, #0f172a);
}
.sc-bubble.playing {
  box-shadow: 0 0 0 2px var(--accent);
}
.sc-who {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
  opacity: 0.8;
}
.sc-bubble.you .sc-who { color: var(--you); }
.sc-bubble.other .sc-who { color: var(--other); }
.sc-en { font-weight: 800; font-size: 0.95rem; line-height: 1.3; }
.sc-th {
  font-family: var(--font-thai);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--thai);
  margin-top: 2px;
  line-height: 1.35;
}
.sc-line-audio {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.sc-line-audio button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}
html.dark .sc-line-audio button, body.dark .sc-line-audio button {
  background: #0f172a;
  color: #e2e8f0;
}

.sc-practice-help {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin: 8px 0;
}
.sc-bank, .sc-built { display: flex; flex-direction: column; gap: 6px; }
.sc-bank { margin-top: 8px; }
.sc-built-item, .sc-bank-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.sc-bank-btn { cursor: pointer; width: 100%; }
.sc-bank-btn:hover { border-color: var(--accent); }
html.dark .sc-built-item, body.dark .sc-built-item,
html.dark .sc-bank-btn, body.dark .sc-bank-btn { background: #1e293b; }
.sc-built-item strong { margin-right: 6px; }
.sc-built-item em {
  display: block;
  font-style: normal;
  font-family: var(--font-thai);
  color: var(--thai);
  font-weight: 700;
  margin-top: 2px;
}
.sc-practice-actions { margin-top: 10px; }
.sc-scene-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sc-scene-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.85rem;
}
.sc-scene-links a:hover { text-decoration: underline; }

.sc-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 18px;
  padding: 12px 4px 8px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.sc-footer a { color: var(--accent); font-weight: 700; text-decoration: none; }

/* Mobile dock (match discover) */
.mobile-dock {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9998;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, #0b1220 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 2px solid color-mix(in srgb, #38bdf8 55%, transparent);
}
.mobile-dock button, .mobile-dock a.dock-link {
  min-height: 56px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  border-radius: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.62rem;
  line-height: 1.1;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-decoration: none;
}
.mobile-dock a.dock-link.primary {
  background: color-mix(in srgb, #0369a1 70%, transparent);
  border-color: #38bdf8;
}
.dock-ico { font-size: 1.1rem; line-height: 1; }
.dock-th { font-family: var(--font-thai); font-size: 0.68rem; }
.dock-lbl { opacity: 0.85; }

.sc-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.55);
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.sc-menu-overlay.open { display: flex; }
.sc-menu-sheet {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 18px 18px 14px 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
html.dark .sc-menu-sheet, body.dark .sc-menu-sheet { background: #0f172a; color: #e2e8f0; }
.sc-menu-sheet h3 { margin: 0 0 12px; font-size: 1rem; }
.sc-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sc-menu-grid a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}
.sc-menu-grid a .th { font-family: var(--font-thai); }
.sc-menu-grid a .en { font-size: 0.75rem; color: var(--muted); }
.sc-menu-close {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 900px) {
  .mobile-dock { display: grid; }
  body { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 640px) {
  body { padding: 10px; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .sc-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}
@media (min-width: 901px) {
  .mobile-dock { display: none !important; }
}






.dictation-page .sc-search {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  box-sizing: border-box;
}
html.dark .dictation-page .sc-search, body.dark .dictation-page .sc-search {
  background: #1e293b;
}
.dictation-page #miniGameOverlay .quiz-sheet {
  width: min(560px, 100%);
}








html.dark 
html.dark




.dictation-page .sc-cat.active, .dictation-page .pr-mode-btn.active {
  background: #059669;
  border-color: #059669;
  color: #fff;
}
.dictation-page .pr-mode-row { display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 4px; }
.dictation-page .pr-mode-btn {
  border:1px solid var(--border); background:#fff; border-radius:999px;
  padding:8px 12px; font-weight:800; font-size:0.8rem; cursor:pointer; font-family:inherit; color:var(--text);
}
html.dark .dictation-page .pr-mode-btn, body.dark .dictation-page .pr-mode-btn { background:#1e293b; }
html.dark .dictation-page .pr-mode-btn.active, body.dark .dictation-page .pr-mode-btn.active {
  background:#34d399; color:#022c22;
}
.dictation-page .pr-featured { border:2px solid #059669 !important; box-shadow:0 0 0 3px rgba(5,150,105,0.15); }
.dictation-page .pr-setup-grid {
  display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:8px; margin:10px 0;
}
.dictation-page .pr-setup-grid label {
  display:flex; flex-direction:column; gap:4px; font-size:0.75rem; font-weight:800; color:var(--muted);
}
.dictation-page .pr-setup-grid select {
  min-height:42px; border-radius:10px; border:1px solid var(--border);
  background:#fff; color:var(--text); font:inherit; font-weight:700; padding:6px 10px;
}
html.dark .dictation-page .pr-setup-grid select, body.dark .dictation-page .pr-setup-grid select { background:#1e293b; }
.dictation-page .pr-cta .sc-tool.accent { background:#059669; border-color:#059669; color:#fff; }

.tm-hero-dictation {
  background:
    radial-gradient(900px 380px at 8% -20%, #e0f2fe, transparent 55%),
    linear-gradient(145deg, #0c4a6e 0%, #0284c7 45%, #0369a1 100%) !important;
}
body.dictation-page .sc-panel {
  background: linear-gradient(160deg, #e0f2fe 0%, #fff 55%, #fff 100%);
}
html.dark body.dictation-page .sc-panel, body.dark.dictation-page .sc-panel {
  background: linear-gradient(160deg, #0c4a6e 0%, #0f172a 55%, #082f49 100%);
}
body.dictation-page .pr-mode-btn.active, body.dictation-page .sc-cat.active {
  background: #0369a1; border-color: #0369a1; color: #fff;
}
body.dictation-page .pr-cta .sc-tool.accent { background: #0369a1; border-color: #0369a1; color:#fff; }
body.dictation-page .pr-featured { border: 2px solid #0369a1 !important; }

