:root {
  --bg: #e8eef7;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --native: #be123c;
  --shadow: 0 10px 32px rgba(15, 23, 42, 0.1);
  --font: "Outfit", "Segoe UI", sans-serif;
  --font-native: "Noto Sans JP", "Noto Sans SC", "Noto Sans KR", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body.locale-hub {
  margin: 0;
  padding: 16px;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 400px at 0% 0%, rgba(99, 102, 241, 0.25), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(244, 63, 94, 0.12), transparent 50%),
    linear-gradient(180deg, #dbe4f5 0%, var(--bg) 50%, #e2e8f0 100%);
  min-height: 100vh;
}
.wrap { max-width: 920px; margin: 0 auto; }
.tm-hero-locale {
  background:
    radial-gradient(800px 340px at 10% -10%, rgba(165, 180, 252, 0.45), transparent 55%),
    linear-gradient(145deg, #1e1b4b 0%, #312e81 40%, #4f46e5 75%, #9f1239 100%) !important;
}
.tm-hero-locale.compact { padding-bottom: 12px; }
.tm-hero h1 .native,
.tm-lead .native {
  display: block;
  font-family: var(--font-native);
  margin-top: 4px;
  opacity: 0.92;
}
.tm-hero h1 .native { font-size: 0.72em; font-weight: 700; }

.lh-panel {
  margin-top: 14px;
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #e0e7ff 0%, #fff 55%, #ffe4e6 100%);
  box-shadow: var(--shadow);
}
.lh-panel h2 { margin: 0 0 12px; font-size: 1.1rem; font-weight: 800; }

.lh-switcher {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.lh-lang {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.lh-lang.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lh-lang .flag { font-size: 1.5rem; }
.lh-lang .en { font-weight: 800; font-size: 0.92rem; }
.lh-lang .nv { font-family: var(--font-native); font-weight: 700; color: var(--native); font-size: 0.88rem; }
.lh-lang .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-style: normal;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}
.lh-lang .badge.live { background: #d1fae5; color: #065f46; }

.lh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.lh-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-height: 110px;
}
.lh-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.lh-card.muted { opacity: 0.72; }
.lh-card .ico { font-size: 1.5rem; }
.lh-card strong { font-weight: 800; }
.lh-card em { font-style: normal; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.lh-meta { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 600; }

/* Locale scenarios: light hub skin only when not glass/dark */
body.locale-scenarios:not(.sc-glass):not(.dark) {
  background:
    radial-gradient(900px 400px at 0% 0%, rgba(99, 102, 241, 0.25), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(244, 63, 94, 0.12), transparent 50%),
    linear-gradient(180deg, #dbe4f5 0%, var(--bg) 50%, #e2e8f0 100%) !important;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-panel.lh-panel {
  background: linear-gradient(160deg, #e0e7ff 0%, #fff 55%, #ffe4e6 100%);
  border-color: var(--border);
}
body.locale-scenarios .sc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card {
  min-height: 110px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: none;
  align-items: flex-start;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.12);
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card-en {
  font-weight: 800;
  font-size: 0.92rem;
  color: #0f172a;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card-th {
  font-family: "Sarabun", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: #64748b;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card-nv {
  font-family: var(--font-native);
  font-weight: 700;
  font-size: 0.85rem;
  color: #be123c;
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-card-meta { font-size: 0.72rem; color: #64748b; }
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-scene.sc-panel {
  background: linear-gradient(160deg, #e0e7ff 0%, #fff 55%, #ffe4e6 100%);
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-bubble {
  border-color: var(--border);
}
body.locale-scenarios:not(.sc-glass):not(.dark) .sc-nv { color: #be123c; }

/* Glass / dark locale scenarios: keep cyan native text (readable on dark bubbles) */
body.locale-scenarios.sc-glass .sc-nv,
body.locale-scenarios.dark .sc-nv,
html.dark body.locale-scenarios .sc-nv,
body.locale-scenarios.sc-glass .sc-card-nv,
body.locale-scenarios.dark .sc-card-nv,
html.dark body.locale-scenarios .sc-card-nv,
body.locale-scenarios.sc-glass .sc-tip .nv,
body.locale-scenarios.dark .sc-tip .nv,
html.dark body.locale-scenarios .sc-tip .nv {
  color: var(--sc-cyan, #22d3ee) !important;
}
body.locale-scenarios.sc-glass .tri-heading .l-nv,
body.locale-scenarios.dark .tri-heading .l-nv,
html.dark body.locale-scenarios .tri-heading .l-nv {
  color: #fda4af;
}

.lh-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.lh-filters input, .lh-filters select, .lh-filters button {
  font-family: inherit;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 0.9rem;
}
.lh-filters input { flex: 1 1 180px; }
.lh-filters button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

.lh-dict { display: flex; flex-direction: column; gap: 8px; }
.lh-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
}
.lh-texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tri-line { display: flex; flex-direction: column; gap: 3px; }
.tri-line .l-en { font-weight: 700; }
.tri-line .l-th { font-family: "Sarabun", sans-serif; font-weight: 700; opacity: 0.92; }
.tri-line .l-nv { font-family: var(--font-native); font-weight: 700; opacity: 0.9; }
.tri-heading { display: flex; flex-direction: column; gap: 2px; margin: 0 0 12px; font-size: 1.05rem; }
.tri-heading .l-th { font-family: "Sarabun", sans-serif; font-size: 0.95em; color: var(--muted); }
.tri-heading .l-nv { font-family: var(--font-native); font-size: 0.95em; color: var(--native); }
.tri-name { display: inline-flex; flex-direction: column; gap: 2px; vertical-align: top; }
.tri-name .l-th { font-family: "Sarabun", sans-serif; font-size: 0.7em; opacity: 0.9; }
.tri-name .l-nv { font-family: var(--font-native); font-size: 0.75em; }
.tri-soft { font-size: 0.78rem; font-weight: 700; color: var(--muted); font-family: "Sarabun", var(--font-native), sans-serif; }
.lh-lang .th-label { font-family: "Sarabun", sans-serif; font-weight: 700; font-size: 0.82rem; color: var(--muted); }

.lh-tri {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.lh-tri .cell { min-width: 0; }
.lh-tri .lbl {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}
.lh-texts .en { font-size: 1.05rem; font-weight: 800; }
.lh-texts .th-word {
  font-family: "Sarabun", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f766e;
}
.lh-texts .native {
  font-family: var(--font-native);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--native);
}
@media (max-width: 700px) {
  .lh-tri { grid-template-columns: 1fr; }
}
.lh-texts .roman { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.lh-texts .cat {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  width: fit-content;
}
.lh-texts .ex { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.lh-texts .ex em {
  display: block;
  font-style: normal;
  font-family: var(--font-native);
  color: var(--native);
  margin-top: 2px;
}
.lh-audio { display: flex; gap: 6px; flex-shrink: 0; }
.lh-play {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.lh-play:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.lh-play.playing { box-shadow: 0 0 0 2px var(--accent); }

.lh-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
  padding: 12px 4px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.lh-footer a { color: var(--accent); font-weight: 700; text-decoration: none; }
.lh-status {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 60;
}
.lh-status.show { opacity: 0.92; }

/* Sticky audio player */
.lh-player {
  position: sticky;
  top: 10px;
  z-index: 40;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #312e81;
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 55%, #4f46e5 100%);
  color: #f8fafc;
  box-shadow: 0 12px 36px rgba(49, 46, 129, 0.35);
}
.lh-player.is-active {
  box-shadow: 0 0 0 2px #a5b4fc, 0 12px 36px rgba(49, 46, 129, 0.4);
}
.lh-player-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.lh-pl-count {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}
.lh-player-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.lh-player-tools .lh-mode {
  flex: 1 1 140px;
}
.lh-player-title {
  font-size: 0.95rem;
  font-weight: 800;
}
.lh-player-title .soft {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.85;
  font-family: "Sarabun", var(--font-native), sans-serif;
}
.lh-mode {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(15, 23, 42, 0.35);
  color: #fff;
  border-radius: 10px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 0.75rem;
  font-family: inherit;
  max-width: 100%;
}
.lh-now {
  margin: 0 0 8px;
  min-height: 1.4em;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}
.lh-player-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.lh-ctrl {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.lh-ctrl:hover { background: rgba(255, 255, 255, 0.22); }
.lh-ctrl.primary {
  background: #fff;
  color: #312e81;
  border-color: #fff;
  min-width: 7.5rem;
}
.lh-ctrl.primary.is-playing {
  background: #fbbf24;
  color: #1e1b4b;
  border-color: #fbbf24;
}
.lh-prog {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 800;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
}
.lh-player-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.75;
}
.lh-row.playing-row {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: #eef2ff;
}
body.locale-dict {
  padding-bottom: 24px;
}

/* 5-item mobile footer dock */
.lh-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 6px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, #1e1b4b 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 2px solid color-mix(in srgb, #818cf8 55%, transparent);
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.25);
}
.lh-mobile-dock .dock-link {
  min-height: 58px;
  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.58rem;
  line-height: 1.05;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-decoration: none;
}
.lh-mobile-dock .dock-link.primary,
.lh-mobile-dock .dock-link.active {
  background: color-mix(in srgb, #4f46e5 75%, transparent);
  border-color: #a5b4fc;
  color: #fff;
}
.lh-mobile-dock .dock-menu {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.45);
}
.lh-mobile-dock .dock-ico { font-size: 1.1rem; line-height: 1; }
.lh-mobile-dock .dock-th {
  font-family: "Sarabun", sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
}
.lh-mobile-dock .dock-lbl {
  opacity: 0.9;
  font-size: 0.58rem;
  font-weight: 800;
}
.lh-mobile-dock .dock-nv {
  font-family: var(--font-native);
  font-size: 0.55rem;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lh-lang-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10020;
  background: rgba(15, 23, 42, 0.55);
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.lh-lang-overlay.open { display: flex; }
/* Sheet stays light even when body/html is dark (avoids white-on-white text) */
.lh-lang-sheet {
  --text: #0f172a;
  --muted: #475569;
  --native: #be123c;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --border: #cbd5e1;
  width: min(480px, 100%);
  background: #fff;
  color: #0f172a;
  border-radius: 18px 18px 14px 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.lh-lang-sheet h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #0f172a;
}
.lh-lang-sheet h3 .l-en { color: #0f172a; }
.lh-lang-sheet h3 .l-th {
  font-family: "Sarabun", sans-serif;
  font-size: 0.9em;
  color: #64748b;
}
.lh-lang-sheet h3 .l-nv {
  font-family: var(--font-native);
  font-size: 0.9em;
  color: #be123c;
}
.lh-lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.lh-lang-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  text-decoration: none;
  color: #0f172a;
  font-weight: 700;
  background: #f8fafc;
}
.lh-lang-item.active {
  border-color: #4f46e5;
  background: #e0e7ff;
}
.lh-lang-item .th {
  font-family: "Sarabun", sans-serif;
  font-size: 0.85rem;
  color: #334155;
}
.lh-lang-item .nv {
  font-family: var(--font-native);
  font-size: 0.85rem;
  color: #be123c;
}
.lh-lang-item .en { font-size: 0.75rem; color: #475569; }
.lh-lang-item em {
  font-style: normal;
  font-size: 0.65rem;
  font-weight: 800;
  color: #4f46e5;
  text-transform: uppercase;
}
.lh-lang-item em.live { color: #0f766e; }
.lh-lang-close {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #e0e7ff;
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 900px) {
  .lh-mobile-dock { display: grid; }
  body.locale-hub {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
  .lh-status { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 901px) {
  .lh-mobile-dock { display: none !important; }
}

body.locale-ja { --font-native: "Noto Sans JP", sans-serif; }
body.locale-zh { --font-native: "Noto Sans SC", sans-serif; }
body.locale-ko { --font-native: "Noto Sans KR", sans-serif; }
body.locale-lo { --font-native: "Noto Sans Lao", "Sarabun", sans-serif; }
body.locale-vi { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-km { --font-native: "Noto Sans Khmer", sans-serif; }
body.locale-my { --font-native: "Noto Sans Myanmar", sans-serif; }
body.locale-ms { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-id { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-fil { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-shn { --font-native: "Noto Sans Thai", "Sarabun", "Outfit", sans-serif; }
body.locale-hi { --font-native: "Noto Sans Devanagari", "Noto Sans", sans-serif; }
body.locale-ar { --font-native: "Noto Naskh Arabic", "Noto Sans Arabic", "Noto Sans", sans-serif; }
body.locale-ar .native,
body.locale-ar .locale-native,
body.locale-ar [lang="ar"] { direction: rtl; unicode-bidi: plaintext; text-align: right; }
body.locale-es,
body.locale-fr,
body.locale-de,
body.locale-pt { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-ru { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-yue { --font-native: "Noto Sans TC", "Noto Sans SC", sans-serif; }
body.locale-khmu { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-hmong { --font-native: "Noto Sans", "Outfit", sans-serif; }
body.locale-isan,
body.locale-kham,
body.locale-paktai { --font-native: "Sarabun", "Noto Sans Thai", sans-serif; }

.tm-nav-langs {
  flex-wrap: wrap;
  max-width: 100%;
  gap: 4px;
}
.tm-nav-langs a {
  font-size: 0.72rem;
  padding: 4px 6px;
}

@media (max-width: 640px) {
  body.locale-hub { padding: 10px; }
  .lh-row { flex-direction: column; }
}
