/* Light / dark / auto theme — resolved via html[data-resolved-theme]. */

html[data-resolved-theme="dark"] {
  color-scheme: dark;
}

html[data-resolved-theme="light"] {
  color-scheme: light;
}

/* --- App shell --- */
html[data-resolved-theme="dark"] body {
  background-color: #0b1220;
  color: #e2e8f0;
}

html[data-resolved-theme="dark"] header {
  background-color: #111827 !important;
  border-color: #1f2937 !important;
}

html[data-resolved-theme="dark"] header a,
html[data-resolved-theme="dark"] header summary {
  color: #cbd5e1 !important;
}

html[data-resolved-theme="dark"] header a:hover,
html[data-resolved-theme="dark"] header summary:hover {
  color: #f8fafc !important;
  background-color: #1f2937 !important;
}

html[data-resolved-theme="dark"] header .text-slate-900,
html[data-resolved-theme="dark"] header a.shrink-0 {
  color: #f8fafc !important;
}

html[data-resolved-theme="dark"] header .text-slate-500 {
  color: #94a3b8 !important;
}

html[data-resolved-theme="dark"] header button,
html[data-resolved-theme="dark"] header .border-slate-300 {
  border-color: #334155 !important;
  color: #e2e8f0;
}

html[data-resolved-theme="dark"] header button:hover {
  background-color: #1f2937 !important;
}

/* Keep primary nav menus readable/wide (Bootstrap reboot from Messages must not own these). */
header nav details > div {
  min-width: 14rem;
  width: max-content;
  max-width: 18rem;
  z-index: 50;
}

html[data-resolved-theme="dark"] header nav details > div,
html[data-resolved-theme="dark"] header details > div {
  background-color: #111827 !important;
  border-color: #1f2937 !important;
  color: #e5e7eb;
}

html[data-resolved-theme="dark"] header details a:hover {
  background-color: #1f2937 !important;
}

/* --- Surfaces --- */
html[data-resolved-theme="dark"] .bg-white {
  background-color: #111827 !important;
}

html[data-resolved-theme="dark"] .bg-slate-50 {
  background-color: #0b1220 !important;
}

html[data-resolved-theme="dark"] .bg-slate-100,
html[data-resolved-theme="dark"] .bg-slate-50\/70,
html[data-resolved-theme="dark"] .hover\:bg-slate-50:hover,
html[data-resolved-theme="dark"] .hover\:bg-slate-100:hover {
  background-color: #1f2937 !important;
}

html[data-resolved-theme="dark"] a.bg-slate-900,
html[data-resolved-theme="dark"] button.bg-slate-900,
html[data-resolved-theme="dark"] .bg-slate-900.px-4,
html[data-resolved-theme="dark"] .bg-slate-900.px-3 {
  background-color: #e2e8f0 !important;
  color: #0f172a !important;
}

html[data-resolved-theme="dark"] a.bg-slate-900:hover,
html[data-resolved-theme="dark"] button.bg-slate-900:hover,
html[data-resolved-theme="dark"] .hover\:bg-slate-800:hover {
  background-color: #cbd5e1 !important;
}

html[data-resolved-theme="dark"] .text-slate-900,
html[data-resolved-theme="dark"] .text-slate-950 {
  color: #f1f5f9 !important;
}

html[data-resolved-theme="dark"] .text-slate-700,
html[data-resolved-theme="dark"] .text-slate-800 {
  color: #cbd5e1 !important;
}

html[data-resolved-theme="dark"] .text-slate-600,
html[data-resolved-theme="dark"] .text-slate-500,
html[data-resolved-theme="dark"] .text-slate-400 {
  color: #94a3b8 !important;
}

html[data-resolved-theme="dark"] .border-slate-100,
html[data-resolved-theme="dark"] .border-slate-200,
html[data-resolved-theme="dark"] .border-slate-300 {
  border-color: #1f2937 !important;
}

html[data-resolved-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
html[data-resolved-theme="dark"] .divide-y > :not([hidden]) ~ :not([hidden]) {
  border-color: #1f2937 !important;
}

html[data-resolved-theme="dark"] .bg-emerald-50 {
  background-color: #052e1c !important;
  border-color: #065f46 !important;
  color: #a7f3d0 !important;
}

html[data-resolved-theme="dark"] .text-emerald-800,
html[data-resolved-theme="dark"] .text-emerald-900 {
  color: #a7f3d0 !important;
}

html[data-resolved-theme="dark"] .border-emerald-200 {
  border-color: #065f46 !important;
}

html[data-resolved-theme="dark"] .bg-amber-50 {
  background-color: #422006 !important;
  border-color: #92400e !important;
  color: #fde68a !important;
}

html[data-resolved-theme="dark"] .text-amber-900,
html[data-resolved-theme="dark"] .text-amber-950 {
  color: #fde68a !important;
}

html[data-resolved-theme="dark"] .border-amber-200 {
  border-color: #92400e !important;
}

html[data-resolved-theme="dark"] input,
html[data-resolved-theme="dark"] textarea,
html[data-resolved-theme="dark"] select {
  background-color: #0b1220;
  color: #e2e8f0;
  border-color: #334155;
}

html[data-resolved-theme="dark"] pre,
html[data-resolved-theme="dark"] code {
  background-color: #020617;
  color: #e2e8f0;
}

html[data-resolved-theme="dark"] .bg-slate-900 pre,
html[data-resolved-theme="dark"] pre.bg-slate-900 {
  background-color: #020617 !important;
  color: #e2e8f0 !important;
}

/* House / floor plan SVG stays readable in dark */
html[data-resolved-theme="dark"] .spatial-house {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(56, 189, 248, 0.08), transparent 45%),
    linear-gradient(165deg, #0f172a 0%, #111827 50%, #0b1220 100%);
  border-color: #1f2937;
  color: #e2e8f0;
}

/* Inline SVG fills need !important to beat presentation style= attributes */
html[data-resolved-theme="dark"] .spatial-room {
  fill: rgba(51, 65, 85, 0.92) !important;
  stroke: rgba(148, 163, 184, 0.75) !important;
}

html[data-resolved-theme="dark"] .spatial-room--outer {
  fill: rgba(30, 41, 59, 0.95) !important;
  stroke: rgba(100, 116, 139, 0.8) !important;
}

html[data-resolved-theme="dark"] .spatial-room--restricted {
  fill: rgba(120, 53, 15, 0.55) !important;
  stroke: rgba(251, 191, 36, 0.65) !important;
}

html[data-resolved-theme="dark"] .spatial-room--occupied {
  fill: rgba(6, 95, 70, 0.55) !important;
  stroke: rgba(52, 211, 153, 0.85) !important;
}

html[data-resolved-theme="dark"] .spatial-room-label {
  background: rgba(15, 23, 42, 0.78);
}

html[data-resolved-theme="dark"] .spatial-room-label__name {
  color: #f1f5f9;
}

html[data-resolved-theme="dark"] .spatial-room-label__meta {
  color: #94a3b8;
}

html[data-resolved-theme="dark"] .spatial-door__label,
html[data-resolved-theme="dark"] .spatial-presence-marker__label {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.9);
}

html[data-resolved-theme="dark"] .spatial-presence-marker__dot {
  background: #e2e8f0;
  border-color: #0f172a;
}

/* Theme switcher */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0.15rem;
  border-radius: 0.5rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

html[data-resolved-theme="dark"] .theme-switcher {
  border-color: #334155;
  background: #0b1220;
}

.theme-switcher__btn {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  border-radius: 0.375rem;
  cursor: pointer;
}

.theme-switcher__btn:hover {
  color: #0f172a;
}

html[data-resolved-theme="dark"] .theme-switcher__btn:hover {
  color: #f8fafc;
}

.theme-switcher__btn[aria-pressed="true"] {
  background: #0f172a;
  color: #f8fafc;
}

html[data-resolved-theme="dark"] .theme-switcher__btn[aria-pressed="true"] {
  background: #e2e8f0;
  color: #0f172a;
}
