:root {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6efe7;
  --bg-soft: #eee2d5;
  --panel: rgba(91, 59, 34, 0.045);
  --panel-strong: rgba(91, 59, 34, 0.075);
  --line: rgba(91, 59, 34, 0.17);
  --text: #211811;
  --muted: #6f5d50;
  --sand: #b8752d;
  --sand-bright: #9d5f22;
  --sand-dark: #7d4818;
  --cream: #70461f;
  --shadow: 0 26px 70px rgba(83, 56, 35, 0.13);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at 82% 12%, rgba(194, 129, 46, 0.12), transparent 28rem),
    radial-gradient(circle at 10% 38%, rgba(126, 83, 47, 0.07), transparent 24rem),
    var(--bg);
}

.brand .brand-logo-light { display: none; }
html[data-theme="light"] .brand .brand-logo-dark { display: none; }
html[data-theme="light"] .brand .brand-logo-light { display: block; }

.theme-toggle,
.language-trigger {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  align-self: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.theme-toggle:hover,
.language-trigger:hover,
.language-picker[open] .language-trigger {
  color: var(--text);
  border-color: rgba(239, 215, 195, 0.34);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon-sun { display: none; }
html[data-theme="light"] .theme-icon-sun { display: block; }
html[data-theme="light"] .theme-icon-moon { display: none; }

.language-picker {
  position: relative;
  align-self: center;
  flex: 0 0 auto;
}
.theme-toggle + .language-picker {
  margin-left: -10px;
}
.language-trigger {
  list-style: none;
  user-select: none;
}
.language-trigger::-webkit-details-marker { display: none; }
.language-badge {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: -0.01em;
}
.language-badge[data-locale="en"] { font-size: 0.58rem; letter-spacing: -0.02em; }
.language-badge[data-locale="ko"] { font-size: 0.68rem; }
.language-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 45;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(24, 19, 15, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}
.site-header nav .language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 620;
  line-height: 1.2;
  white-space: nowrap;
}
.site-header nav .language-option:hover {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}
.site-header nav .language-option[aria-current="page"] {
  background: rgba(213, 154, 97, 0.11);
  color: var(--sand-bright);
}
.language-check {
  width: 14px;
  color: var(--sand-bright);
  text-align: center;
  opacity: 0;
}
.language-option[aria-current="page"] .language-check { opacity: 1; }

html[data-theme="light"] .theme-toggle,
html[data-theme="light"] .language-trigger {
  background: rgba(77, 49, 28, 0.035);
}
html[data-theme="light"] .theme-toggle:hover,
html[data-theme="light"] .language-trigger:hover,
html[data-theme="light"] .language-picker[open] .language-trigger {
  border-color: rgba(91, 59, 34, 0.3);
  background: rgba(77, 49, 28, 0.065);
}
html[data-theme="light"] .language-menu {
  background: rgba(255, 250, 245, 0.98);
  box-shadow: 0 18px 42px rgba(83, 56, 35, 0.16);
}
html[data-theme="light"] .site-header nav .language-option:hover {
  background: rgba(77, 49, 28, 0.06);
}
html[data-theme="light"] .site-header nav .language-option[aria-current="page"] {
  background: rgba(194, 129, 46, 0.11);
}

html[data-theme="light"] .terminal,
html[data-theme="light"] .install pre {
  background: #fffaf5;
}
html[data-theme="light"] .agent { color: var(--text); }
html[data-theme="light"] .button.secondary {
  background: rgba(77, 49, 28, 0.035);
}
html[data-theme="light"] .copy-button {
  background: rgba(77, 49, 28, 0.035);
}
html[data-theme="light"] .copy-button:hover {
  border-color: rgba(91, 59, 34, 0.3);
  background: rgba(77, 49, 28, 0.07);
}
html[data-theme="light"] .use-grid article,
html[data-theme="light"] .question-grid article,
html[data-theme="light"] .feature-grid article {
  background: rgba(255, 251, 247, 0.6);
}
html[data-theme="light"] .use-grid article.checkpoint-step {
  background: linear-gradient(160deg, rgba(194, 129, 46, 0.11), rgba(255, 251, 247, 0.72));
}
html[data-theme="light"] .dialog-card {
  background: #fffaf5;
}
html[data-theme="light"] .trigger-list code {
  background: rgba(77, 49, 28, 0.035);
}
html[data-theme="light"] .back-to-top {
  border-color: rgba(91, 59, 34, 0.18);
  background: rgba(255, 250, 245, 0.94);
  color: #70461f;
  box-shadow: 0 14px 36px rgba(83, 56, 35, 0.15);
}
html[data-theme="light"] .back-to-top:hover {
  border-color: rgba(91, 59, 34, 0.34);
  background: rgba(255, 253, 250, 0.99);
}

@media (max-width: 640px) {
  .theme-toggle,
  .language-trigger {
    width: 32px;
    height: 32px;
  }
  .language-menu { min-width: 168px; }
  .theme-toggle + .language-picker { margin-left: -6px; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .language-trigger {
    transition: none;
  }
}
