/* Two explicit visitor palettes. White is the first-visit default; either mode
   preserves a saved device choice without changing editable studio content. */
:root,:root[data-theme="light"] {
  --site-background: #f7f7f2!important;
  --site-surface: #ffffff!important;
  --site-text: #252b25!important;
  --site-muted: #626c61!important;
  --site-accent: #80603b!important;
  --theme-on-accent: #fff8ed;
  --theme-line: rgba(37,43,37,.18);
  --theme-line-soft: rgba(37,43,37,.11);
  --theme-tint: rgba(37,43,37,.05);
  --theme-sun-ink: #302920;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --site-background: #111211!important;
  --site-surface: #1b1e1b!important;
  --site-text: #f1f1e9!important;
  --site-muted: #b4b8ad!important;
  --site-accent: #d3aa7a!important;
  --theme-on-accent: #21170d;
  --theme-line: rgba(229,229,211,.22);
  --theme-line-soft: rgba(229,229,211,.13);
  --theme-tint: rgba(229,229,211,.055);
  --theme-sun-ink: #f1f1e9;
  color-scheme: dark;
}
html[data-theme] {
  /* The canvas behind short pages and overscroll matches the page itself. */
  background: var(--site-background);
  --studio-rule: var(--theme-line);
  --studio-rule-soft: var(--theme-line-soft);
  --studio-tint: var(--theme-tint);
}
html[data-theme] body { color: var(--site-text); }
html[data-theme] :is(.brand-interlude,.studio-marquee) { background: var(--site-background); }
html[data-theme] body .catalog .filter.active,
html[data-theme] body .button-dark,
html[data-theme] .purchase-panel a.button {
  border-color: var(--site-accent);
  background: var(--site-accent);
  color: var(--theme-on-accent);
}
html[data-theme] .catalog .empty { background: var(--site-surface); }
html[data-theme] .compatibility,html[data-theme] body .purchase-panel {
  background: var(--theme-tint);
  border-color: var(--theme-line-soft);
}

/* The header gets a real surface, so every mode stays legible over the scene. */
html[data-theme] body .header.header {
  background: var(--site-background)!important;
  color: var(--site-text)!important;
  border-bottom: 1px solid var(--theme-line-soft)!important;
  box-shadow: none;
}
html[data-theme] body .header.header :is(.brand,.brand-ko,.mobile-menu) {
  color: var(--site-text)!important;
  text-shadow: none;
}
html[data-theme] body .header.header .brand-ko {
  color: var(--site-muted)!important;
  border-color: var(--theme-line);
}
html[data-theme] body .header.header .brand-mark,
html[data-theme] body > footer .brand-mark {
  background: linear-gradient(130deg,transparent 28%,currentColor 29% 62%,transparent 63%);
  border-color: currentColor;
}
html[data-theme] .header-actions { display: flex; align-items: center; gap: 18px; }
html[data-theme] body .header button.mobile-menu {
  color: var(--site-text)!important;
  background: var(--site-surface);
  border-color: var(--theme-line);
}
html[data-theme] body .header button.mobile-menu:hover {
  color: var(--site-text)!important;
  background: var(--theme-tint);
  border-color: var(--theme-line);
}
html[data-theme] body .header button.mobile-menu:focus-visible { outline-color: var(--site-text); }
.theme-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  min-height: 40px;
  border: 1px solid var(--theme-line);
  border-radius: 999px;
  background: var(--site-surface);
}
.theme-switch button {
  min-height: 44px;
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--site-muted);
  font-family: var(--type-body,'Noto Sans KR',sans-serif);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.4;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: none;
}
.theme-switch button > .icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-end: 4px;
  vertical-align: -.06em;
}
.theme-switch button:hover { background: var(--theme-tint); color: var(--site-text); }
.theme-switch button[aria-pressed="true"] {
  background: var(--site-accent);
  color: var(--theme-on-accent);
}
.theme-switch button:focus-visible { outline: 2px solid var(--site-text); outline-offset: 4px; }
body.menu-open .header .theme-switch { display: none; }

/* Navigation and dialogs follow the palette; the attached wordmark explanation
   follows the scene's readable foreground without adding a separate card. */
html[data-theme] #mobile-nav.mobile-nav { background: var(--site-background); color: var(--site-text); }
html[data-theme] #mobile-nav .menu-intro p { color: var(--site-text); }
html[data-theme] #mobile-nav :is(.menu-kicker,.menu-intro-note,.menu-footer) { color: var(--site-muted); }
html[data-theme] #mobile-nav.mobile-nav .menu-links a {
  color: var(--site-text);
  border-color: var(--theme-line);
}
html[data-theme] #mobile-nav.mobile-nav .menu-links a:first-child { border-color: var(--theme-line); }
html[data-theme] #mobile-nav.mobile-nav .menu-links a small,
html[data-theme] #mobile-nav.mobile-nav .menu-links a:after { color: var(--site-muted); }
html[data-theme] #mobile-nav.mobile-nav .menu-links a:is(:hover,:focus-visible),
html[data-theme] #mobile-nav.mobile-nav .menu-links a:is(:hover,:focus-visible):after { color: var(--site-text); }
html[data-theme] #mobile-nav.mobile-nav .menu-links a:focus-visible { outline-color: var(--site-text); }
html[data-theme] #mobile-nav .menu-footer { border-color: var(--theme-line); }
html[data-theme] .hero .hero-meaning-panel {
  color: var(--theme-sun-ink);
}
html[data-theme] .hero .hero-meaning-copy { color: inherit; }
html[data-theme] body #product-dialog {
  background: var(--site-surface);
  color: var(--site-text);
  border-color: var(--theme-line);
}
html[data-theme] body #product-dialog::backdrop { background: rgba(12,14,12,.58); }

/* Preserve the actual shelter and its light/shade transition. Dark mode tints
   only the decorative image/canvas; no text, hit area or 3D state is changed. */
html[data-theme] .hero:not([data-desert-custom="true"]) #hero-title,
html[data-theme] .hero:not([data-desert-custom="true"]) :is(.hero-kicker,.hero-bottom h2,.hero-bottom p,.hero-foot,.hero-foot .scroll-cue span) {
  color: var(--theme-sun-ink);
  text-shadow: none;
}
html[data-theme] .hero:not([data-desert-custom="true"])[data-desert-light="shade"] :is(.hero-bottom h2,.hero-bottom p),
html[data-theme] .hero:not([data-desert-custom="true"])[data-desert-foot="shade"] :is(.hero-foot,.hero-foot .scroll-cue span) { color: #fff8ed; }
html[data-theme] .hero[data-desert-light="shade"] .hero-meaning-panel,
html[data-theme] .hero[data-desert-light="shade"] #hero-title:focus-within { color: #fff8ed; }
html[data-theme="dark"] .desert-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: rgba(9,13,10,.62);
}
html[data-theme="dark"] .hero .hero-world::after {
  background: linear-gradient(180deg,rgba(9,13,10,.64),rgba(9,13,10,.62));
}
html[data-theme] .hero[data-desert-custom="true"] :is(#hero-title,.hero-kicker,.hero-bottom h2,.hero-bottom p,.hero-foot,.hero-foot .scroll-cue span) { color: #fff8ed; }
html[data-theme] .hero[data-desert-custom="true"] .hero-meaning-panel { color: #fff8ed; }
html[data-theme] .hero[data-desert-custom="true"] .hero-world::after {
  background: linear-gradient(180deg,rgba(9,13,10,.62),rgba(9,13,10,.7));
}
html[data-theme="dark"] .brand[data-logo="grnl"] :is(.brand-image,.brand-wordmark) { filter: brightness(0) invert(1); }
html[data-theme="light"] .brand[data-logo="grnl"] :is(.brand-image,.brand-wordmark) { filter: brightness(0); }

@media(max-width:760px) {
  html[data-theme] .header-actions { gap: 9px; }
  .theme-switch { padding: 2px; gap: 0; min-height: 38px; }
  .theme-switch button { padding: 7px 8px; font-size: 9px; }
}
@media(max-width:600px) {
  .theme-switch { min-height: 44px; }
  .theme-switch .theme-label { display: none; }
  .theme-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    width: 44px;
    min-height: 44px;
    padding: 0;
  }
  .theme-switch button > .icon {
    width: 16px;
    height: 16px;
    margin-inline-end: 0;
    vertical-align: baseline;
  }
}
@media(max-width:420px) {
  html[data-theme] .header-actions { gap: 7px; }
  html[data-theme] body .header button.mobile-menu { min-width: 84px; padding-inline: 12px; gap: 12px; }
}
@media(max-width:359px) {
  html[data-theme] .header-actions { gap: 6px; }
  html[data-theme] body .header button.mobile-menu { min-width: 66px; padding-inline: 10px; gap: 8px; }
  html[data-theme] body .header button.mobile-menu .menu-label { font-size: 9px!important; letter-spacing: .08em; }
  html[data-theme] body .header button.mobile-menu .menu-lines,
  html[data-theme] body .header button.mobile-menu .menu-lines .icon { width: 17px; height: 17px; }
}
@media(prefers-reduced-motion:reduce) { .theme-switch button { transition: none; } }
@media(forced-colors:active) {
  html[data-theme] body .header.header,
  html[data-theme] #mobile-nav.mobile-nav,
  html[data-theme] body #product-dialog,
  .theme-switch,.theme-switch button {
    background: Canvas!important;
    color: CanvasText!important;
    border-color: CanvasText!important;
  }
  .theme-switch button[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  html[data-theme] .hero:not([data-desert-custom="true"]) #hero-title,
  html[data-theme] .hero:not([data-desert-custom="true"]) :is(.hero-kicker,.hero-bottom h2,.hero-bottom p,.hero-foot,.hero-foot .scroll-cue span),
  html[data-theme] .hero .hero-meaning-panel,html[data-theme] .hero .hero-meaning-copy { color: CanvasText!important; }
  html[data-theme="dark"] .desert-scene::after { display: none; }
}
