/* Website/workspace themes. Patient visits retain their own clinic palette. */
.theme-choice {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 44px;
  padding: 6px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.theme-choice-track {
  position: relative;
  display: block;
  width: 64px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  transition: border-color 180ms ease, background 180ms ease;
}

.theme-choice-track::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(37, 34, 31, 0.16), 0 0 0 1px rgba(37, 34, 31, 0.04);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), background 180ms ease;
}

.theme-choice svg {
  position: absolute;
  top: 7px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: color 180ms ease;
}

.theme-choice-sun { left: 7px; }
.theme-choice-moon { left: 39px; }
html[data-site-theme="light"] .theme-choice-track { background: var(--surface-hover); }
html[data-site-theme="light"] .theme-choice-sun { color: var(--accent); }
html[data-site-theme="dark"] .theme-choice-track::before {
  transform: translateX(32px);
  background: #302c27;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
html[data-site-theme="dark"] .theme-choice-moon { color: var(--ink); }
.theme-choice:hover .theme-choice-track { border-color: var(--muted); }
.theme-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .theme-choice-track, .theme-choice-track::before, .theme-choice svg { transition: none; }
}

.public-theme-choice {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 2;
}

.app-sidebar-footer .theme-choice { align-self: flex-start; margin: 0 4px 8px; }
.app-mobile-actions { display: flex; align-items: center; gap: 8px; }
.app-sidebar-collapsed .app-sidebar-footer .theme-choice { display: none; }
.app-shell :is(input, select, textarea) { min-width: 0; }
.app-tabs { overflow-x: auto; overflow-y: hidden; }

html[data-site-theme="light"] {
  color-scheme: light;
  --bg: #faf8f4;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f0ece5;
  --ink: #25221f;
  --muted: #655e56;
  --faint: #746c63;
  --line: rgba(55, 43, 31, 0.15);
  --line-strong: rgba(55, 43, 31, 0.25);
  --accent: #a44329;
  --accent-soft: rgba(164, 67, 41, 0.09);
  --accent-glow: rgba(164, 67, 41, 0.15);
  --cool: #4c7068;
}

html[data-site-theme="light"] .site-atmosphere { opacity: 0.35; }
html[data-site-theme="light"] .site-atmosphere .grain { display: none; }
html[data-site-theme="light"] :is(.pill-nav, .app-mobilebar) {
  background: rgba(250, 248, 244, 0.92);
  box-shadow: 0 8px 32px rgba(55, 43, 31, 0.06);
}
html[data-site-theme="light"] :is(.site-sheet-panel, .app-mobile-sheet, .visits-export-menu, .app-sidebar-edge-toggle) {
  background: var(--bg-elevated);
  box-shadow: 0 16px 44px rgba(55, 43, 31, 0.1);
}
html[data-site-theme="light"] :is(.product-frame, .panel, .about-card, .feature-media) {
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(55, 43, 31, 0.08) !important;
}
html[data-site-theme="light"] .app-sidebar { background: var(--bg-elevated); }
html[data-site-theme="light"] :is(.app-sidebar-link:hover, .app-sidebar-link.app-nav-active) {
  background: var(--surface-hover) !important;
}
html[data-site-theme="light"] :is(.pill-nav-link:hover, .pill-nav-link.is-active, .site-sheet-link:hover) {
  background: var(--surface-hover);
}
html[data-site-theme="light"] .demo-label { background: var(--surface); }
html[data-site-theme="light"] :is(.btn-primary, .site-sheet-link.is-primary) {
  background: var(--ink);
  color: #fff;
}
html[data-site-theme="light"] .btn-primary:hover { background: #443b34; }
html[data-site-theme="light"] .btn-danger {
  color: #a5263c;
  background: #fff0f2;
  border-color: #e6b8c0;
}
html[data-site-theme="light"] .visits-input { color-scheme: light; background: var(--surface); }
html[data-site-theme="light"] :is(input, textarea)::placeholder { color: var(--faint); opacity: 1; }
html[data-site-theme="light"] .form-pick-list label { color: var(--ink); }

/* Existing templates use Tailwind's dark-palette utilities, including in JS. */
html[data-site-theme="light"] [class*="text-[#e2dfd8]/"] { color: var(--muted) !important; }
html[data-site-theme="light"] [class~="bg-[#d97757]"] { color: #fff !important; }
html[data-site-theme="light"] [class~="bg-[#d97757]"] * { color: inherit !important; }
html[data-site-theme="light"] :is([class~="bg-white/10"], [class~="bg-white/15"]) { background-color: var(--surface-hover); }
html[data-site-theme="light"] [class~="bg-black/30"] { background-color: var(--surface); }
html[data-site-theme="light"] [class~="text-white"] { color: var(--ink); }
html[data-site-theme="light"] :is([class~="text-white/50"], [class~="text-white/90"]) { color: var(--muted); }
html[data-site-theme="light"] [class~="border-white/10"] { border-color: var(--line); }
html[data-site-theme="light"] :is([class~="bg-[#282725]/45"], [class~="bg-[#282725]/60"], [class~="bg-[#211f1d]"]) {
  background-color: var(--surface) !important;
}
html[data-site-theme="light"] [class~="bg-[#1e1d1b]/60"] { background-color: var(--bg) !important; }
html[data-site-theme="light"] :is([class~="bg-[#312f2c]/60"], [class~="bg-[#3a3835]"], [class~="bg-[#3b3a37]"]) {
  background-color: var(--surface-hover) !important;
}
html[data-site-theme="light"] [class~="bg-[#e2dfd8]/35"] { background-color: var(--faint); }
html[data-site-theme="light"] .hero-mode-btn[aria-selected="true"] {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
html[data-site-theme="light"] .hero-dot { background: var(--muted); }
html[data-site-theme="light"] .typing-dot { background: var(--muted); }
html[data-site-theme="light"] .app-sidebar-link[title]:hover::after {
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(55, 43, 31, 0.1);
}

html[data-site-theme="light"] :is([class*="text-emerald-"], [class*="text-green-"]) { color: #17613a !important; }
html[data-site-theme="light"] :is([class*="bg-emerald-9"], [class*="bg-green-9"], .visits-chip-done, .visits-chip-ok) {
  background: #eaf5ed; border-color: #afcfb9; color: #17613a;
}
html[data-site-theme="light"] :is([class*="text-amber-"], [class*="text-yellow-"], [class*="text-orange-"]) { color: #825400 !important; }
html[data-site-theme="light"] :is([class*="bg-amber-9"], [class*="bg-yellow-9"], [class*="bg-orange-9"], .visits-chip-amber) {
  background: #fff5da; border-color: #ddc588; color: #825400;
}
html[data-site-theme="light"] :is([class*="text-rose-"], [class*="text-red-"]) { color: #a5263c !important; }
html[data-site-theme="light"] :is([class*="bg-rose-9"], [class*="bg-red-9"], .visits-chip-rose, .visits-delete) {
  background: #fff0f2; border-color: #e6b8c0; color: #a5263c;
}
html[data-site-theme="light"] :is([class*="text-sky-"], [class*="text-blue-"]) { color: #185b83 !important; }
html[data-site-theme="light"] :is([class*="bg-sky-9"], [class*="bg-blue-9"], .visits-chip-sky) {
  background: #eaf4fb; border-color: #b5d1e2; color: #185b83;
}
html[data-site-theme="light"] .visits-export summary { color: #fff; }

@media (max-width: 900px) {
  .public-theme-choice { top: 16px; right: 16px; }
}
