:root {
  --bg: #dce4e8;
  --card: #f4f7f8;
  --text: #1a2332;
  --muted: #5c6b7a;
  --border: #b7c4ce;
  --accent: #a16207;
  --accent-soft: #fef9c3;
  --you: #0f766e;
  --other: #7c3aed;
  --thai: #9f1239;
  --shadow: 0 12px 36px rgba(26, 35, 50, 0.14);
  --font-display: "Outfit", "Segoe UI", sans-serif;
  --font-thai: "Sarabun", "Segoe UI", sans-serif;
}
html.dark body,
body.dark {
  --bg: #0c1218;
  --card: #121a22;
  --text: #e8eef4;
  --muted: #94a3b8;
  --border: #243040;
  --accent: #fbbf24;
  --accent-soft: #422006;
  --you: #5eead4;
  --other: #c4b5fd;
  --thai: #fb7185;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  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(900px 400px at 0% 0%, rgba(180, 83, 9, 0.18), transparent 55%),
    radial-gradient(800px 360px at 100% 0%, rgba(15, 118, 110, 0.16), transparent 50%),
    linear-gradient(180deg, #cfd8de 0%, var(--bg) 42%, #d5dde2 100%);
  color: var(--text);
}
.wrap { max-width: 960px; margin: 0 auto; }
.tm-hero-dress {
  background:
    radial-gradient(900px 380px at 10% -20%, rgba(251, 191, 36, 0.35), transparent 55%),
    radial-gradient(700px 320px at 100% 10%, rgba(15, 118, 110, 0.35), transparent 52%),
    linear-gradient(145deg, #1c1917 0%, #422006 40%, #a16207 72%, #0f766e 100%) !important;
}
.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, #fff7ed 0%, #fff 50%, #ecfdf5 100%);
  box-shadow: var(--shadow);
}
html.dark .sc-panel,
body.dark .sc-panel {
  background: linear-gradient(160deg, #292524 0%, #0f172a 55%, #134e4a 100%);
  border-color: #334155;
}
.sc-head h2 { margin: 0 0 4px; font-size: 1.15rem; }
.sc-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.sc-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.sc-cat {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
html.dark .sc-cat, body.dark .sc-cat { background: #0f172a; }
.sc-cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
html.dark .sc-cat.active, body.dark .sc-cat.active { color: #1c1917; }

.dress-hub-grid,
#dressGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.dress-hub-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 0 0 12px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
html.dark .dress-hub-card, body.dark .dress-hub-card { background: #0f172a; }
.dress-hub-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.dress-hub-img-wrap {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #1c1917;
}
.dress-hub-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dress-hub-emoji {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 3rem;
}
.dress-hub-emoji-sm {
  font-size: 1.1rem;
  padding: 8px 12px 0;
}
.dress-hub-card .sc-card-en,
.dress-hub-card .sc-card-th,
.dress-hub-card .sc-card-meta {
  padding: 0 12px;
}
.sc-card-en { font-weight: 800; font-size: 0.92rem; }
.sc-card-th { font-family: var(--font-thai); font-size: 0.88rem; color: var(--thai); }
.sc-card-meta { font-size: 0.72rem; color: var(--muted); }
.sc-meta { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }

.sc-back {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 10px;
  padding: 0;
}
.sc-scene-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.sc-scene-emoji { font-size: 2.2rem; }
.sc-scene-titles h2 { margin: 0; font-size: 1.3rem; }
.sc-scene-th {
  margin: 2px 0 0;
  font-family: var(--font-thai);
  color: var(--thai);
  font-weight: 700;
}
.sc-scene-roman {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.dress-hero-img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  display: block;
}
.swim-overview, .dress-overview {
  margin: 10px 0 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
  line-height: 1.45;
}
html.dark .dress-overview, body.dark .dress-overview {
  background: color-mix(in srgb, var(--accent) 14%, #0f172a);
}
.dress-overview .th {
  display: block;
  margin-top: 6px;
  font-family: var(--font-thai);
  color: var(--thai);
}
.sc-tip {
  padding: 10px 12px;
  border-radius: 12px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
html.dark .sc-tip, body.dark .sc-tip {
  background: #064e3b;
  border-color: #059669;
  color: #a7f3d0;
}
.sc-tip .th {
  display: block;
  margin-top: 4px;
  font-family: var(--font-thai);
}
.sc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.sc-tool {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
html.dark .sc-tool, body.dark .sc-tool { background: #0f172a; }
.sc-tool.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
html.dark .sc-tool.accent { color: #1c1917; }
.sc-tool.secondary { opacity: 0.9; }
.sc-status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.dress-section-title {
  margin: 16px 0 8px;
  font-size: 1rem;
}
.dress-highlights {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.dress-card-item {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 6%, #fff);
  cursor: pointer;
}
html.dark .dress-card-item, body.dark .dress-card-item {
  background: color-mix(in srgb, var(--accent) 12%, #0f172a);
}
.dress-card-item.playing { box-shadow: 0 0 0 2px var(--accent); }
.dress-hi-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.swim-tech-en { font-weight: 800; margin-top: 2px; }
.swim-tech-th {
  font-family: var(--font-thai);
  color: var(--thai);
  font-weight: 700;
  font-size: 0.92rem;
}
.swim-tech-detail {
  margin-top: 4px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.swim-tech-detail .th {
  display: block;
  margin-top: 4px;
  font-family: var(--font-thai);
  color: var(--muted);
}

.dress-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.dress-gal-item {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}
html.dark .dress-gal-item, body.dark .dress-gal-item { background: #0f172a; }
.dress-gal-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.dress-gal-item figcaption {
  padding: 8px 10px;
  font-size: 0.85rem;
}
.dress-gal-item .en { display: block; font-weight: 700; }
.dress-gal-item .th {
  display: block;
  font-family: var(--font-thai);
  color: var(--thai);
}

.sc-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.sc-bubble {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
html.dark .sc-bubble, body.dark .sc-bubble { background: #0f172a; }
.sc-bubble.playing { box-shadow: 0 0 0 2px var(--accent); }
.sc-en { font-weight: 700; }
.sc-th {
  font-family: var(--font-thai);
  color: var(--thai);
  margin-top: 2px;
}
.sc-scene-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.sc-scene-links a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.sc-footer {
  margin: 18px 0 80px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
.sc-footer a { color: var(--accent); text-decoration: none; font-weight: 700; }

.mobile-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 40;
}
.dock-link, .dock-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 4px;
}
.dock-ico { font-size: 1.1rem; }
.dock-th { font-family: var(--font-thai); font-size: 0.62rem; }
.dock-lbl { font-size: 0.62rem; font-weight: 700; }
.dock-link.primary { color: var(--accent); }
.sc-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sc-menu-overlay.open { display: flex; }
.sc-menu-sheet {
  width: min(480px, 100%);
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
}
.sc-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.sc-menu-grid a {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  background: #fff;
}
html.dark .sc-menu-grid a, body.dark .sc-menu-grid a { background: #0f172a; }
.sc-menu-grid .th {
  display: block;
  font-family: var(--font-thai);
  font-weight: 700;
}
.sc-menu-grid .en { font-size: 0.8rem; color: var(--muted); }
.sc-menu-close {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-weight: 800;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
html.dark .sc-menu-close { color: #1c1917; }

@media (max-width: 640px) {
  .dress-hero-img { max-height: 220px; }
  #dressGrid { grid-template-columns: 1fr 1fr; }
}
