:root {
  color-scheme: light;
  --surface: #ffffff;
  --canvas: #f8fafc;
  --selected: #f1f5f9;
  --text: #111827;
  --secondary: #475569;
  --muted: #64748b;
  --border: #dfe3e8;
  --accent: #1597b5;
  --accent-hover: #1188a4;
  --accent-bg: #f0fbfd;
  --link: #2563eb;
  --purple: #7c3aed;
  --green: #16a34a;
  --success-text: #3f8a60;
  --success-bg: #eef8f1;
  --success-border: #bfe8cf;
  --pending-text: #9a6a32;
  --pending-bg: #fff7e8;
  --completed-text: #6673a5;
  --completed-bg: #f0f2fb;
  --danger-text: #a45454;
  --danger-bg: #fbf0f0;
  --glass: rgba(255, 255, 255, .97);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --surface: #212121;
  --canvas: #181818;
  --selected: #303030;
  --text: #ededed;
  --secondary: #c5c5c5;
  --muted: #a8a8a8;
  --border: #353535;
  --accent: #58c8df;
  --accent-hover: #79d6e8;
  --accent-bg: #2a2a2a;
  --link: #8bb8ff;
  --purple: #c4a0ff;
  --green: #77dca0;
  --success-text: #91dbaf;
  --success-bg: #183a2c;
  --success-border: #2b6144;
  --pending-text: #f0c47e;
  --pending-bg: #3b2e18;
  --completed-text: #b6c2ff;
  --completed-bg: #292f50;
  --danger-text: #efa8a8;
  --danger-bg: #422626;
  --glass: rgba(33, 33, 33, .97);
}
/* Theme controls have the same comfortable touch targets on desktop and mobile. */
html body #sidebar.sidebar { display: flex !important; flex-direction: column; }
.sidebar-top, .sidebar .menu { flex: 0 0 auto; }
.sidebar-footer { flex: 0 0 auto; margin-top: auto; padding-top: 24px; }
.sidebar-session { border-top: 1px solid var(--border); padding: 16px 8px 0; }
.sidebar-session-state { display: flex; align-items: center; gap: 7px; color: var(--success-text); font-size: 12px; }
.sidebar-session-state > span { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: currentColor; }
.sidebar-session-database { margin-top: 6px; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.sidebar-session-mode { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
html body #sidebar .sidebar-signout {
  display: flex; align-items: center; justify-content: flex-start; gap: 9px;
  width: 100%; height: auto; min-height: 44px; margin: 6px 0 0; padding: 10px 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--text); font: inherit; font-size: 13px; font-weight: 400; text-align: left;
}
.sidebar-signout svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-signout:hover { text-decoration: underline; }
.theme-control {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  flex: 0 0 auto; padding: 16px 4px 0;
}
.theme-options {
  display: flex; gap: 2px; padding: 3px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--canvas);
}
html body .theme-option {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.theme-option svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
html body .theme-option[aria-pressed="true"] { background: var(--selected); color: var(--text); }
.theme-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-option:hover { color: var(--text); }
@media (min-width: 1001px) {
  #sidebar.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; align-self: flex-start; }
}
/* Inline login styling and native dialogs also follow the chosen palette. */
#avalon-login { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text); }
html[data-theme="dark"] .primary-btn { background: #087e98; border-color: #087e98; color: #ffffff; }
html[data-theme="dark"] .primary-btn:hover { background: #066a80; }
html[data-theme="dark"] .modal-backdrop,
html[data-theme="dark"] #bookingModal.modal-backdrop,
html[data-theme="dark"] .mobile-overlay { background: rgba(0, 0, 0, .6); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #999999; opacity: 1; }
dialog { color: var(--text) !important; background: var(--surface) !important; border-color: var(--border) !important; }
html[data-theme="dark"] dialog::backdrop { background: rgba(0, 0, 0, .6); }

html[data-theme="dark"] body { background: var(--canvas); }
