:root {
  --theme-bg: #09090b;
  --theme-surface: #111113;
  --theme-panel: #18181b;
  --theme-panel-strong: #27272a;
  --theme-field: #000000;
  --theme-text: #f4f4f5;
  --theme-muted: #d4d4d8;
  --theme-faint: #71717a;
  --theme-border: #3f3f46;
  --theme-border-strong: #52525b;
  --theme-primary: #f4f4f5;
  --theme-primary-text: #09090b;
  --theme-shadow: rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --theme-bg: #f3f6fb;
  --theme-surface: #ffffff;
  --theme-panel: #f8fafc;
  --theme-panel-strong: #e8eef7;
  --theme-field: #ffffff;
  --theme-text: #111827;
  --theme-muted: #334155;
  --theme-faint: #64748b;
  --theme-border: #cbd5e1;
  --theme-border-strong: #94a3b8;
  --theme-primary: #1f2937;
  --theme-primary-text: #ffffff;
  --theme-shadow: rgba(15, 23, 42, 0.14);
}

html,
body {
  transition: background-color .18s ease, color .18s ease;
}

.theme-toggle {
  width: 2.35rem;
  min-width: 2.35rem;
  height: 2.35rem;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .65rem;
  border: 1px solid var(--theme-border);
  background: var(--theme-panel);
  color: var(--theme-muted);
  box-shadow: 0 10px 30px var(--theme-shadow);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--theme-panel-strong);
  color: var(--theme-text);
}

.theme-toggle-floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 80;
}

.theme-toggle-below-header {
  top: 4.25rem;
}

html[data-theme="light"] body {
  background: var(--theme-bg) !important;
  color: var(--theme-text) !important;
}

html[data-theme="light"] .bg-black,
html[data-theme="light"] .bg-\[\#050505\],
html[data-theme="light"] .bg-\[\#090909\] {
  background-color: var(--theme-bg) !important;
}

html[data-theme="light"] .bg-zinc-950,
html[data-theme="light"] .bg-zinc-900,
html[data-theme="light"] .bg-zinc-900\/50,
html[data-theme="light"] .bg-black\/25,
html[data-theme="light"] .bg-black\/30 {
  background-color: var(--theme-surface) !important;
}

html[data-theme="light"] .bg-zinc-800,
html[data-theme="light"] .bg-zinc-700 {
  background-color: var(--theme-panel-strong) !important;
}

html[data-theme="light"] .bg-zinc-100 {
  background-color: var(--theme-primary) !important;
}

html[data-theme="light"] .text-black {
  color: var(--theme-primary-text) !important;
}

html[data-theme="light"] .border-zinc-900,
html[data-theme="light"] .border-zinc-800,
html[data-theme="light"] .border-zinc-700,
html[data-theme="light"] .border-zinc-600,
html[data-theme="light"] .border-zinc-500 {
  border-color: var(--theme-border) !important;
}

html[data-theme="light"] .text-zinc-100,
html[data-theme="light"] .text-zinc-200,
html[data-theme="light"] .text-zinc-300 {
  color: var(--theme-text) !important;
}

html[data-theme="light"] .text-zinc-400 {
  color: var(--theme-muted) !important;
}

html[data-theme="light"] .text-zinc-500,
html[data-theme="light"] .text-zinc-600,
html[data-theme="light"] .text-zinc-700 {
  color: var(--theme-faint) !important;
}

html[data-theme="light"] h1,
html[data-theme="light"] h2,
html[data-theme="light"] h3,
html[data-theme="light"] label {
  color: var(--theme-text) !important;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  background-color: var(--theme-field) !important;
  border-color: var(--theme-border) !important;
  color: var(--theme-text) !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: var(--theme-faint) !important;
}

html[data-theme="light"] .top-btn {
  background: var(--theme-surface) !important;
  color: var(--theme-muted) !important;
  border-color: var(--theme-border) !important;
  box-shadow: 0 8px 24px var(--theme-shadow);
}

html[data-theme="light"] .top-btn:hover,
html[data-theme="light"] .hover\:bg-zinc-900:hover,
html[data-theme="light"] .hover\:bg-zinc-800:hover,
html[data-theme="light"] .hover\:bg-zinc-700:hover {
  background: var(--theme-panel-strong) !important;
  color: var(--theme-text) !important;
}

html[data-theme="light"] .hover\:bg-white:hover {
  background: #111827 !important;
}

html[data-theme="light"] .bottom-btn {
  border-color: var(--theme-border) !important;
  box-shadow: none !important;
}

html[data-theme="light"] .glass {
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(12px);
}

html[data-theme="light"] .card,
html[data-theme="light"] .archive-mini {
  background: var(--theme-surface) !important;
  border-color: var(--theme-border) !important;
}

html[data-theme="light"] .archive-mini:hover,
html[data-theme="light"] .template-active {
  background: var(--theme-panel-strong) !important;
  border-color: var(--theme-border-strong) !important;
  color: var(--theme-text) !important;
}

html[data-theme="light"] .help-line {
  border-color: var(--theme-border) !important;
}

html[data-theme="light"] .archive-example-toggle::before,
html[data-theme="light"] .onboarding-dot {
  border-color: #a1a1aa;
  background: transparent;
}

html[data-theme="light"] .archive-example-toggle:hover::before {
  border-color: #71717a;
}

html[data-theme="light"] .archive-example-toggle:focus-visible {
  outline-color: #71717a;
}

html[data-theme="light"] .archive-example-toggle.active::before,
html[data-theme="light"] .onboarding-dot.active {
  border-color: #a1a1aa;
  background: #d4d4d8;
  box-shadow: 0 4px 7px rgba(34, 197, 94, .4), 0 7px 12px rgba(34, 197, 94, .16);
}

html[data-theme="light"] .archive-example-toggle.active:hover::before {
  background: #c4c4ca;
  box-shadow: 0 4px 8px rgba(34, 197, 94, .5), 0 7px 12px rgba(34, 197, 94, .22);
}

html[data-theme="light"] .manager-modal {
  background: rgba(15, 23, 42, 0.35) !important;
}

html[data-theme="light"] .custom-scrollbar::-webkit-scrollbar-thumb,
html[data-theme="light"] textarea::-webkit-scrollbar-thumb {
  background: #94a3b8 !important;
}

html[data-theme="light"] .shadow-black,
html[data-theme="light"] .shadow-black\/20,
html[data-theme="light"] .shadow-black\/30 {
  --tw-shadow-color: var(--theme-shadow) !important;
  --tw-shadow: var(--tw-shadow-colored) !important;
}

html[data-theme="light"] .onboarding-backdrop {
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: blur(2px);
}

html[data-theme="light"] .onboarding-highlight {
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.08),
    0 0 0 5px var(--guide-soft),
    0 8px 28px rgba(15, 23, 42, 0.16);
}

html[data-theme="light"] .onboarding-panel {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 68%, #f1f5f9 100%);
  border-color: color-mix(in srgb, var(--guide-accent) 46%, #cbd5e1);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2),
    0 0 30px var(--guide-soft);
}

html[data-theme="light"] .onboarding-header {
  background: linear-gradient(90deg, var(--guide-soft) 0%, rgba(255, 255, 255, 0.96) 64%, rgba(248, 250, 252, 0.9) 100%);
  border-color: #dbe3ee !important;
}

html[data-theme="light"] .onboarding-stage {
  color: color-mix(in srgb, var(--guide-accent) 78%, #0f172a);
}

html[data-theme="light"] .onboarding-counter {
  color: #334155;
  border-color: color-mix(in srgb, var(--guide-accent) 34%, #cbd5e1);
  background: rgba(255, 255, 255, 0.86);
}

html[data-theme="light"] .onboarding-progress {
  background: #e2e8f0;
}

html[data-theme="light"] .onboarding-title {
  color: #0f172a !important;
}

html[data-theme="light"] .onboarding-copy,
html[data-theme="light"] .onboarding-label {
  color: #334155;
}

html[data-theme="light"] .onboarding-input {
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
  background: rgba(255, 255, 255, 0.96) !important;
}

html[data-theme="light"] .onboarding-input:focus {
  border-color: var(--guide-accent) !important;
  box-shadow: 0 0 0 3px var(--guide-soft);
}

html[data-theme="light"] .onboarding-modality button {
  color: #334155;
  border-color: #cbd5e1;
  background: linear-gradient(145deg, #ffffff, #eef2f7);
}

html[data-theme="light"] .onboarding-modality button[data-onboarding-modality="US"].active {
  color: #ffffff;
  border-color: #dc2626;
  background: linear-gradient(135deg, #b91c1c, #ef4444);
}

html[data-theme="light"] .onboarding-modality button[data-onboarding-modality="CT"].active {
  color: #ffffff;
  border-color: #2563eb;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

html[data-theme="light"] .onboarding-modality button[data-onboarding-modality="MR"].active {
  color: #ffffff;
  border-color: #9333ea;
  background: linear-gradient(135deg, #7e22ce, #a855f7);
}

html[data-theme="light"] .onboarding-flow {
  color: #64748b;
}

html[data-theme="light"] .onboarding-flow span {
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

html[data-theme="light"] .onboarding-flow span:nth-of-type(1) {
  color: #0369a1;
  background: linear-gradient(135deg, #e0f2fe, #ffffff);
}

html[data-theme="light"] .onboarding-flow span:nth-of-type(2) {
  color: #7e22ce;
  background: linear-gradient(135deg, #f3e8ff, #ffffff);
}

html[data-theme="light"] .onboarding-flow span:nth-of-type(3) {
  color: #15803d;
  background: linear-gradient(135deg, #dcfce7, #ffffff);
}

html[data-theme="light"] .onboarding-legend {
  color: #1e293b;
}

html[data-theme="light"] .onboarding-legend > div {
  border-color: #dbe3ee;
  background: linear-gradient(90deg, var(--guide-soft), rgba(255, 255, 255, 0.98) 44%, rgba(248, 250, 252, 0.96));
}

html[data-theme="light"] .onboarding-actions {
  border-color: #dbe3ee;
  background: rgba(248, 250, 252, 0.86);
}

html[data-theme="light"] .onboarding-button {
  color: #334155;
  border-color: #cbd5e1;
  background: linear-gradient(145deg, #ffffff, #e8eef7);
}

html[data-theme="light"] .onboarding-button.primary {
  color: #ffffff;
  border-color: color-mix(in srgb, var(--guide-accent) 70%, #ffffff);
  background: linear-gradient(135deg, var(--guide-accent), var(--guide-accent-2));
  box-shadow: 0 8px 20px var(--guide-soft), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

html[data-theme="light"] .onboarding-error {
  color: #b91c1c;
}

html[data-theme="light"] .modal-primary-action {
  --modal-action-background: linear-gradient(135deg, #1d4ed8, #0f766e);
  --modal-action-border: #1d4ed8;
  --modal-action-shadow: rgba(29, 78, 216, 0.18);
  min-height: 40px;
  background: var(--modal-action-background) !important;
  color: #ffffff !important;
  border: 1px solid var(--modal-action-border) !important;
  border-radius: 8px;
  letter-spacing: 0;
  box-shadow: 0 5px 14px var(--modal-action-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  cursor: pointer;
}

html[data-theme="light"] #addTemplateBtn[data-manager-source="group"] {
  --modal-action-background: linear-gradient(135deg, #047857, #0f766e);
  --modal-action-border: #047857;
  --modal-action-shadow: rgba(4, 120, 87, 0.18);
}

html[data-theme="light"] .modal-primary-action:hover:not(:disabled) {
  background: var(--modal-action-background) !important;
  color: #ffffff !important;
  border-color: var(--modal-action-border) !important;
  filter: brightness(1.05);
}

html[data-theme="light"] .modal-primary-action:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 3px;
}

html[data-theme="light"] .modal-primary-action:disabled {
  background: #e8eef7 !important;
  color: #64748b !important;
  border-color: #cbd5e1 !important;
  box-shadow: none;
  filter: none;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  html[data-theme="light"] .template-manager-actions {
    flex-wrap: wrap;
    padding: 16px;
  }

  html[data-theme="light"] .template-manager-actions > button {
    flex: 1 1 180px;
  }
}
