/* ============================================================
   GARUDA — Dual-Theme Design System
   Light (Soft UI) default · Dark (Apple HIG) via [data-theme="dark"]
   ============================================================ */

/* Disable browser text-selection highlight globally */
::selection      { background: transparent; }
::-moz-selection { background: transparent; }

/* ── Light theme (default) ──────────────────────────────── */
:root {
  --bg:        #F4F5F7;
  --surface:   #FFFFFF;
  --surface-2: #F0F1F4;
  --surface-3: #E4E6EB;
  --glass:     rgba(255,255,255,0.70);
  --glass-h:   rgba(255,255,255,0.92);
  --border:    rgba(0,0,0,0.06);
  --border-2:  rgba(0,0,0,0.04);

  --accent:    #4F7EFF;
  --accent-d:  rgba(79,126,255,0.10);
  --danger:    #EF4444;
  --danger-d:  rgba(239,68,68,0.10);
  --success:   #22C55E;
  --warn:      #F59E0B;
  --warn-d:    rgba(245,158,11,0.10);
  --mk-orange: #E8854A;
  --purple:    #7C3AED;
  --accent-mint:   #BCF0DA;
  --accent-purple: #E0D8F7;

  --t1: #1A1D23;
  --t2: #6B7280;
  --t3: #9CA3AF;
  --t4: #D1D5DB;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display",
          "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Menlo", ui-monospace, monospace;

  --r:    8px;
  --r-sm: 6px;
  --r-lg: 14px;
  --r-xl: 22px;

  --shadow:      0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-sm:   0 2px 6px rgba(0,0,0,0.06);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.03);
  --shadow-inset:inset 0 2px 6px rgba(0,0,0,0.06);
  --trans: 0.2s ease;

  /* Theme-aware glass/overlay values */
  --header-bg:        rgba(255,255,255,0.85);
  --header-border:    rgba(0,0,0,0.06);
  --nav-bg:           rgba(255,255,255,0.85);
  --nav-border:       rgba(0,0,0,0.08);
  --nav-pill:         rgba(0,0,0,0.07);
  --nav-item-color:   rgba(0,0,0,0.35);
  --nav-item-active:  #1A1D23;
  --btn-ghost-bg:     rgba(0,0,0,0.05);
  --btn-ghost-hover:  rgba(0,0,0,0.09);
  --overlay-bg:       rgba(0,0,0,0.45);
  --room-bg:          rgba(0,0,0,0.05);
  --console-color:    #2d7a2d;
  --table-hover:      rgba(0,0,0,0.02);
  --log-color:        #1a5230;
  --grid-line:        rgba(0,0,0,0.035);
  --grid-base:        #F4F5F7;
}

/* ── Dark theme override ─────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #000000;
  --surface:   #1C1C1E;
  --surface-2: #2C2C2E;
  --surface-3: #3A3A3C;
  --glass:     rgba(28,28,30,0.72);
  --glass-h:   rgba(28,28,30,0.92);
  --border:    rgba(255,255,255,0.08);
  --border-2:  rgba(255,255,255,0.06);

  --accent:    #0A84FF;
  --accent-d:  rgba(10,132,255,0.12);
  --danger:    #FF453A;
  --danger-d:  rgba(255,69,58,0.12);
  --success:   #30D158;
  --warn:      #FF9F0A;
  --warn-d:    rgba(255,159,10,0.12);
  --purple:    #BF5AF2;
  --accent-mint:   #30D158;
  --accent-purple: rgba(191,90,242,0.20);

  --t1: #F5F5F7;
  --t2: #A1A1A6;
  --t3: #6E6E73;
  --t4: #48484A;

  --shadow:      0 8px 32px rgba(0,0,0,0.65);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.35);
  --shadow-card: none;
  --shadow-inset:none;

  --header-bg:        rgba(0,0,0,0.80);
  --header-border:    rgba(255,255,255,0.06);
  --nav-bg:           rgba(28,28,30,0.78);
  --nav-border:       rgba(255,255,255,0.10);
  --nav-pill:         rgba(255,255,255,0.10);
  --nav-item-color:   rgba(255,255,255,0.35);
  --nav-item-active:  #FFFFFF;
  --btn-ghost-bg:     rgba(255,255,255,0.06);
  --btn-ghost-hover:  rgba(255,255,255,0.10);
  --overlay-bg:       rgba(0,0,0,0.55);
  --room-bg:          rgba(255,255,255,0.04);
  --console-color:    rgba(48,209,88,0.85);
  --table-hover:      rgba(255,255,255,0.03);
  --log-color:        rgba(48,209,88,0.85);
  --grid-line:        rgba(255,255,255,0.03);
  --grid-base:        #08080d;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Background ────────────────────────────────────────────
      html: solid base fills overscroll/rubber-band areas
      body: transparent so body::before isn't covered
      body::before: position:fixed grid — never scrolls        ── */
html {
  background-color: var(--grid-base, #F4F5F7);
  overflow-x: auto;
  scrollbar-width: none;
}
body { background: transparent; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--grid-base, #F4F5F7);
  background-image:
    linear-gradient(var(--grid-line, rgba(0,0,0,0.035)) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line, rgba(0,0,0,0.035)) 1px, transparent 1px);
  background-size: 44px 44px;
}

body {
  color: var(--t1);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: auto;
  scrollbar-width: none;
}

/* Scrollbar — thin style */
::-webkit-scrollbar { width: 0; height: 0; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--t4); }

/* ── Utilities ─────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.col    { flex-direction: column; }
.center { display: flex; align-items: center; justify-content: center; }
.grow   { flex: 1; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* ── Typography — Apple SF Pro weights ─────────────────── */
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.15; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }

.overline {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--t3);
}

.hero-title {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(135deg, #f5f5f7 0%, #86868b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Frosted glass surface ─────────────────────────────── */
.glass {
  background: var(--glass);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid var(--border);
}

/* ── Universal card ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 18px;
}

/* ── Buttons — macOS rounded rect ──────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--r);
  padding: 8px 18px;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: opacity var(--trans), transform 0.1s ease, background var(--trans);
  white-space: nowrap; letter-spacing: -0.1px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0977e6; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e63e35; }
.btn-ghost    {
  background: var(--btn-ghost-bg);
  color: var(--t1);
  border: 0.5px solid var(--border);
}
.btn-ghost:hover { background: var(--btn-ghost-hover); }
/* Sign Out — subtle red tint */
#header .btn-ghost[onclick*="logout"],
.hud-signout { color: rgba(255,69,58,0.70); }
#header .btn-ghost[onclick*="logout"]:hover { background: rgba(255,69,58,0.12); color: #ff453a; border-color: rgba(255,69,58,0.25); }
.btn-link  { background: none; color: var(--accent); padding: 4px 8px; font-size: 13px; }
.btn-link:hover { opacity: 0.75; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ── Inputs — macOS text field ─────────────────────────── */
.input, .select {
  background: rgba(255,255,255,0.05);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  color: var(--t1);
  font-family: var(--font); font-size: 14px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--trans), background var(--trans), box-shadow var(--trans);
  -webkit-appearance: none;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  background: rgba(10,132,255,0.06);
  box-shadow: 0 0 0 3px rgba(10,132,255,0.15);
}
.input::placeholder { color: var(--t3); }
.input-label {
  font-size: 12px; color: var(--t2);
  display: block; margin-bottom: 6px;
  font-weight: 500;
}
.input-group { display: flex; flex-direction: column; gap: 4px; }

/* ── Autofill fix ──────────────────────────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  -webkit-text-fill-color: var(--t1) !important;
  caret-color: var(--t1);
  transition: background-color 5000s ease-in-out 0s;
}
.login-card input:-webkit-autofill,
.lv-panel input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #1C1C1E inset !important;
}
[data-theme="light"] .login-card input:-webkit-autofill,
[data-theme="light"] .lv-panel input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  -webkit-text-fill-color: var(--t1) !important;
}

/* ── Mode badge — header pill ──────────────────────────── */
.mode-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 980px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.1px;
  font-family: var(--font);
  cursor: default; user-select: none;
  border: 0.5px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--t2);
}
.mode-pill.active         { background: var(--danger-d); border-color: rgba(255,69,58,0.25); color: var(--danger); }
.mode-pill.active.blue    { background: var(--accent-d); border-color: rgba(10,132,255,0.25); color: var(--accent); }
.mode-pill.active.yellow  { background: var(--warn-d);   border-color: rgba(255,159,10,0.25); color: var(--warn); }

/* ── Mode row — macOS Settings toggle row ──────────────── */
.mode-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer; user-select: none;
  background: transparent;
  transition: background var(--trans);
}
.mode-row:hover { background: rgba(255,255,255,0.04); }
.mode-row-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  font-size: 13px; line-height: 1;
  transition: background var(--trans);
}
.mode-row-label {
  flex: 1;
  font-family: var(--font); font-size: 13px; font-weight: 400;
  color: var(--t2);
  transition: color var(--trans);
}

/* macOS toggle switch — exact 51×31 dimensions */
.mode-toggle {
  width: 51px; height: 31px; border-radius: 15.5px;
  background: var(--surface-3); flex-shrink: 0;
  position: relative;
  transition: background 0.25s ease;
}
.mode-toggle.on { background: var(--success); }
.mode-toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: transform 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.mode-toggle.on::after { transform: translateX(20px); }

/* Active states */
.mode-row.on                { background: rgba(48,209,88,0.06); }
.mode-row.on .mode-row-icon { background: rgba(48,209,88,0.15); }
.mode-row.on .mode-row-label{ color: var(--t1); }
.mode-row.on .mode-toggle   { background: var(--success); }
.mode-row.on.mode-danger                { background: rgba(255,69,58,0.06); }
.mode-row.on.mode-danger .mode-row-icon { background: rgba(255,69,58,0.15); }
.mode-row.on.mode-danger .mode-toggle   { background: var(--danger); }
.mode-row.on.mode-warn                  { background: rgba(255,159,10,0.06); }
.mode-row.on.mode-warn .mode-row-icon   { background: rgba(255,159,10,0.15); }
.mode-row.on.mode-warn .mode-toggle     { background: var(--warn); }
.mode-row.on.mode-purple                { background: rgba(191,90,242,0.06); }
.mode-row.on.mode-purple .mode-row-icon { background: rgba(191,90,242,0.15); }
.mode-row.on.mode-purple .mode-toggle   { background: var(--purple); }
.mode-row.on.mode-muted                 { background: rgba(161,161,166,0.06); }
.mode-row.on.mode-muted .mode-row-icon  { background: rgba(161,161,166,0.15); }
.mode-row.on.mode-muted .mode-toggle    { background: var(--t2); }

/* ── Readout stats ─────────────────────────────────────── */
.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.readout-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--r);
}
.readout-label {
  font-family: var(--font); font-size: 10px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--t3);
}
.readout-val {
  font-family: var(--mono); font-size: 18px; font-weight: 300;
  color: var(--t1); line-height: 1; letter-spacing: -0.5px;
}
.readout-unit {
  font-family: var(--font); font-size: 10px;
  color: var(--t3); margin-left: 3px;
}

/* ── Toggle (standalone) ───────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-info span:first-child { font-size: 14px; font-weight: 500; }
.toggle-info span:last-child  { font-size: 12px; color: var(--t3); }
.toggle {
  width: 51px; height: 31px; border-radius: 15.5px;
  background: var(--surface-3); cursor: pointer;
  position: relative; flex-shrink: 0;
  transition: background 0.25s ease;
  border: none;
}
.toggle.on { background: var(--success); }
.toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: transform 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.toggle.on::after { transform: translateX(20px); }

/* ── App shell ──────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#app.logged-in #login-screen { display: none; }
#app:not(.logged-in) #app-shell { display: none; }
#app.logged-in .wv-docs-btn { display: none; }
#header { display: none !important; }
#top-hud { display: none; }

/* ── Login ──────────────────────────────────────────────── */
#login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
  position: relative;
  background: transparent; /* let body::before grid show through */
}

/* Full-screen centered content */
.login-center {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px 80px;
  overflow-y: auto;
  gap: 0;
}

/* Hero wordmark */
.login-hero {
  text-align: center;
  margin-bottom: 52px;
}
.login-wordmark {
  font-size: 80px;
  font-weight: 100;
  font-family: "Palatino Linotype", "Palatino", "Book Antiqua", Georgia, serif;
  letter-spacing: 8px;
  text-transform: uppercase;
  line-height: 1;
  color: var(--t1);
}
.login-subtitle {
  font-size: 11px;
  color: var(--t3);
  margin-top: 16px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-family: var(--mono);
}

.login-prompt {
  margin-top: 32px;
  font-size: 13px;
  color: var(--t4);
  text-align: center;
}

/* Backend config — floating bottom-right corner */
.login-corner {
  position: absolute;
  bottom: 24px; right: 24px;
  display: flex; align-items: center; gap: 6px;
  z-index: 10;
}
#backend-status {
  font-size: 11px; color: var(--t3);
  display: flex; align-items: center; gap: 5px;
}
#backend-status .bk-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--t4);
}
#backend-status .bk-dot.ok { background: var(--success); }

/* Profile circles */
#profile-cards {
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 36px;
  max-width: 720px;
}

.profile-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  cursor: pointer;
  transition: transform var(--trans), opacity var(--trans);
}
.profile-card:hover { transform: translateY(-4px); }
.profile-card:hover .profile-avatar { box-shadow: 0 12px 40px rgba(0,0,0,0.5); }

.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; color: #fff;
  transition: box-shadow var(--trans), transform var(--trans);
  flex-shrink: 0;
}
.profile-avatar.admin-av {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--t3);
  font-size: 24px;
}
.profile-card .profile-name {
  font-size: 13px; font-weight: 500; color: var(--t2);
  text-align: center;
}

/* Login panel */
#login-panel {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 0;
}
.login-panel-header {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; margin-bottom: 32px; text-align: center;
}
.login-panel-header .lp-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  margin-bottom: 4px;
}
.login-panel-header h2 { font-size: 22px; letter-spacing: -0.4px; }
.login-panel-header p  { color: var(--t3); font-size: 13px; }

.login-fields { display: flex; flex-direction: column; gap: 12px; }
.login-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.login-back { margin-top: 12px; text-align: center; }

/* OTP screen */
#admin-otp-screen {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column;
  align-items: center; gap: 24px; text-align: center;
}
.otp-header h2 { font-size: 22px; letter-spacing: -0.4px; margin-bottom: 6px; }
.otp-header p  { color: var(--t3); font-size: 13px; }
.otp-input-group { width: 100%; }
#admin-otp-input {
  text-align: center;
  letter-spacing: 10px;
  font-size: 28px;
  font-family: var(--mono);
  padding: 14px;
}

/* Forgot password */
#forgot-screen {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 16px;
  text-align: center;
}
#forgot-screen h2 { margin-bottom: 4px; }

/* Status messages */
.msg { font-size: 12px; padding: 8px 12px; border-radius: var(--r); }
.msg.ok  { background: rgba(48,209,88,0.12); color: var(--success); }
.msg.err { background: var(--danger-d); color: var(--danger); }

/* ── App shell layout ───────────────────────────────────── */
#app-shell { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Header — macOS toolbar style */
#header {
  height: 52px;
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--header-border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  flex-shrink: 0; position: relative; z-index: 5;
}
.header-brand {
  font-weight: 600; font-size: 16px; letter-spacing: -0.3px;
  color: var(--t1);
}
#header-pills { display: flex; gap: 6px; margin-left: 16px; }
#header-right  { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.hdr-status { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--t3); }
.hdr-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--t4);
}
.hdr-dot.online { background: var(--success); }
.hdr-dot.alert  { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.2; } }
.hdr-user { font-size: 13px; color: var(--t2); }

/* Floating top HUD bar — Dynamic Island */
#top-hud {
  position: fixed;
  top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 80;
  align-items: center; gap: 14px;
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px 5px 16px;
  box-shadow:
    0 10px 24px rgba(0,0,0,0.14),
    0 2px 6px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
  white-space: nowrap;
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease,
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: default;
}
[data-theme="dark"] #top-hud {
  border-color: rgba(255,255,255,0.14);
  box-shadow:
    0 14px 28px rgba(0,0,0,0.18),
    0 3px 8px rgba(0,0,0,0.12),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.10);
}
/* Dynamic Island — alert state */
#top-hud.di-alert {
  background: rgba(255, 69, 58, 0.12);
  border-color: rgba(255, 69, 58, 0.38);
  box-shadow:
    0 10px 24px rgba(255,69,58,0.22),
    0 2px 6px rgba(255,69,58,0.14),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: di-alert-pulse 1.1s ease-in-out infinite;
}
[data-theme="light"] #top-hud.di-alert {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.30);
}
/* Dynamic Island — thinking state (Narada / Chat loading) */
@keyframes di-think-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
#top-hud.di-thinking {
  border-color: rgba(79, 126, 255, 0.38);
  animation: di-think-jiggle 1.35s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
#top-hud.di-thinking .hud-brand {
  animation: di-think-pulse 1.1s ease-in-out infinite;
}
#top-hud.di-voice {
  border-color: rgba(48,209,88,0.30);
  animation: di-voice-jiggle 1.45s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
#top-hud.di-voice #hud-dot {
  animation: di-voice-dot 0.9s ease-in-out infinite;
}
#top-hud.di-idle #hud-label {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  #top-hud:hover {
    transform: translateX(-50%) scale(1.014);
    box-shadow:
      0 12px 26px rgba(0,0,0,0.14),
      0 3px 8px rgba(0,0,0,0.08),
      inset 0 1px 0 rgba(255,255,255,0.08);
  }
  [data-theme="dark"] #top-hud:hover {
    box-shadow:
      0 14px 28px rgba(0,0,0,0.22),
      0 3px 8px rgba(0,0,0,0.14),
      0 0 0 1px rgba(255,255,255,0.05),
      inset 0 1px 0 rgba(255,255,255,0.12);
  }
}
@keyframes di-alert-pulse {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  20% { transform: translateX(-50%) translateY(-0.5px) scale(1.012); }
  45% { transform: translateX(-50%) translateY(0) scale(1.024); }
  70% { transform: translateX(-50%) translateY(-0.5px) scale(1.01); }
}
@keyframes di-think-jiggle {
  0%, 100% {
    transform: translateX(-50%) translateY(0) scale(1);
    box-shadow: 0 10px 24px rgba(79,126,255,0.14), 0 2px 6px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
  }
  18% {
    transform: translateX(-50%) translateY(-0.5px) scale(1.01);
  }
  42% {
    transform: translateX(-50%) translateY(0) scale(1.02);
    box-shadow: 0 14px 30px rgba(79,126,255,0.20), 0 3px 8px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.08);
  }
  68% {
    transform: translateX(-50%) translateY(-0.35px) scale(1.008);
  }
}
@keyframes di-voice-jiggle {
  0%, 100% {
    transform: translateX(-50%) translateY(0) scale(1);
    box-shadow: 0 10px 24px rgba(48,209,88,0.12), 0 2px 6px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
  }
  22% {
    transform: translateX(-50%) translateY(-0.35px) scale(1.012);
  }
  48% {
    transform: translateX(-50%) translateY(0) scale(1.018);
    box-shadow: 0 14px 28px rgba(48,209,88,0.18), 0 3px 8px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.08);
  }
  72% {
    transform: translateX(-50%) translateY(-0.25px) scale(1.006);
  }
}
@keyframes di-voice-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.55); opacity: 0.5; }
}
.hud-brand {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: 3px; color: var(--t1);
}
.hud-status {
  display: flex; align-items: center; gap: 5px;
  max-width: 200px; overflow: hidden; opacity: 1;
  transition: max-width 0.3s ease 0.08s, opacity 0.2s ease 0.05s;
}
/* Collapse hud-status when DI shows animated content */
#top-hud:not(.di-idle) .hud-status {
  max-width: 0; opacity: 0;
  transition: max-width 0.2s ease, opacity 0.15s ease;
}
#hud-label { font-size: 11px; color: var(--t3); font-family: var(--mono); }
.hud-right { display: flex; align-items: center; gap: 10px; margin-left: 4px; }

/* ── Dynamic Island expanded content ──────────────────── */
.di-live {
  display: flex; align-items: center; gap: 6px;
  max-width: 0; overflow-x: clip; overflow-y: visible; opacity: 0;
  transition: max-width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease;
}
.di-cnt { display: none; align-items: center; gap: 5px; white-space: nowrap; }
.di-lbl { font-size: 11px; font-weight: 500; font-family: var(--mono); color: var(--t2); }

/* State — alert */
#top-hud.di-alert    .di-live         { max-width: 120px; opacity: 1; }
#top-hud.di-alert    .di-cnt-alert    { display: flex; }
/* State — thinking */
#top-hud.di-thinking .di-live         { max-width: 72px;  opacity: 1; }
#top-hud.di-thinking .di-cnt-think    { display: flex; }
/* State — all clear */
#top-hud.di-allclear .di-live         { max-width: 120px; opacity: 1; }
#top-hud.di-allclear .di-cnt-allclear { display: flex; }
/* State — voice */
#top-hud.di-voice    .di-live         { max-width: 95px;  opacity: 1; }
#top-hud.di-voice    .di-cnt-voice    { display: flex; }

/* Pulsing pip — red (alert), green (allclear), yellow (night presence) */
.di-pip {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  margin-left: 3px; /* prevent left clip when pip scales during overflow-x:clip animation */
}
.di-pip.di-r {
  background: var(--danger);
  animation: di-pip-pulse 0.9s ease-in-out infinite;
}
.di-pip.di-g {
  background: var(--success);
  animation: di-pip-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.di-pip.di-y {
  background: var(--warn);
  animation: di-pip-pulse 1.3s ease-in-out infinite;
}
@keyframes di-pip-pulse { 0%,100%{opacity:1;transform:scale(1);}  50%{opacity:0.35;transform:scale(1.6);} }
@keyframes di-pip-pop   { from{transform:scale(0);opacity:0;} to{transform:scale(1);opacity:1;} }

/* State — night presence (yellow) */
#top-hud.di-yellow {
  background: rgba(255, 159, 10, 0.12);
  border-color: rgba(255, 159, 10, 0.38);
  box-shadow:
    0 10px 24px rgba(255,159,10,0.20),
    0 2px 6px rgba(255,159,10,0.12),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: di-yellow-pulse 1.4s ease-in-out infinite;
}
[data-theme="light"] #top-hud.di-yellow {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.30);
}
@keyframes di-yellow-pulse {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  20% { transform: translateX(-50%) translateY(-0.5px) scale(1.010); }
  50% { transform: translateX(-50%) translateY(0) scale(1.018); }
  70% { transform: translateX(-50%) translateY(-0.5px) scale(1.008); }
}
#top-hud.di-yellow .di-live    { max-width: 160px; opacity: 1; }
#top-hud.di-yellow .di-cnt-night { display: flex; }

/* Bouncing dots — thinking */
.di-bdot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  animation: di-bdot-bounce 0.95s ease-in-out infinite;
}
.di-bdot:nth-child(2) { animation-delay: 0.16s; }
.di-bdot:nth-child(3) { animation-delay: 0.32s; }
@keyframes di-bdot-bounce {
  0%,100% { transform: translateY(0);    opacity: 1; }
  50%     { transform: translateY(-4px); opacity: 0.45; }
}

/* Voice waveform bars */
.di-vbar {
  width: 3px; border-radius: 99px; flex-shrink: 0;
  background: var(--success);
  animation: di-vbar-wave 0.85s ease-in-out infinite;
}
.di-vbar:nth-child(1) { height: 7px;  animation-delay: 0s;    }
.di-vbar:nth-child(2) { height: 13px; animation-delay: 0.12s; }
.di-vbar:nth-child(3) { height: 9px;  animation-delay: 0.24s; }
.di-vbar:nth-child(4) { height: 15px; animation-delay: 0.36s; }
.di-vbar:nth-child(5) { height: 7px;  animation-delay: 0.18s; }
@keyframes di-vbar-wave {
  0%,100% { transform: scaleY(1);   opacity: 0.65; }
  50%     { transform: scaleY(1.9); opacity: 1; }
}

/* All-clear DI border glow */
#top-hud.di-allclear {
  border-color: rgba(52,199,89,0.4);
  box-shadow:
    0 0 0 1px rgba(52,199,89,0.18),
    0 10px 24px rgba(0,0,0,0.14),
    0 2px 6px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.hud-user-lbl { font-size: 11px; color: var(--t2); }
.hud-signout {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 999px; cursor: pointer;
  color: rgba(255,69,58,0.68);
  padding: 0; transition: color 0.15s, background 0.15s, transform 0.15s;
}
.hud-signout svg { width: 15px; height: 15px; }
.hud-signout:hover { color: var(--danger); background: rgba(255,69,58,0.08); }
.hud-signout:active { transform: scale(0.96); }

/* Body */
#body { flex: 1; display: flex; overflow: hidden; }

/* Main */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 80px;
  position: relative;
}
#main.dash-active {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ── iOS Bottom Navigation — Dock style ─────────────────── */
#ios-nav {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 0;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--nav-bg) 92%, rgba(0,0,0,0.18));
  backdrop-filter: blur(30px) saturate(125%);
  -webkit-backdrop-filter: blur(30px) saturate(125%);
  border: 0.5px solid color-mix(in srgb, var(--nav-border) 82%, rgba(255,255,255,0.04));
  border-radius: 22px;
  box-shadow:
    0 10px 22px rgba(0,0,0,0.14),
    0 22px 48px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 -10px 18px rgba(0,0,0,0.05);
  z-index: 90;
  white-space: nowrap;
  overflow: visible;
}
[data-theme="light"] #ios-nav {
  background: color-mix(in srgb, var(--nav-bg) 90%, rgba(244,245,247,0.75));
  border-color: color-mix(in srgb, var(--nav-border) 80%, rgba(255,255,255,0.55));
  box-shadow:
    0 12px 24px rgba(15,23,42,0.08),
    0 24px 48px rgba(15,23,42,0.06),
    inset 0 1px 0 rgba(255,255,255,0.82),
    inset 0 -8px 16px rgba(148,163,184,0.06);
}
[data-theme="dark"] #ios-nav {
  background: color-mix(in srgb, var(--nav-bg) 94%, rgba(0,0,0,0.32));
  border-color: color-mix(in srgb, var(--nav-border) 85%, rgba(255,255,255,0.06));
  box-shadow:
    0 12px 24px rgba(0,0,0,0.18),
    0 24px 50px rgba(0,0,0,0.16),
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -10px 18px rgba(0,0,0,0.10);
}
#app.logged-in #ios-nav { display: flex; }
#app.logged-in #top-hud { display: flex; }

/* Sliding selection pill */
#ios-pill {
  position: absolute;
  top: 6px;
  left: 0;
  width: 68px;
  height: calc(100% - 12px);
  background: var(--nav-pill);
  border-radius: 16px;
  transform: translateX(6px);
  transition: transform 0.36s cubic-bezier(0.34, 1.38, 0.64, 1),
              width    0.36s cubic-bezier(0.34, 1.38, 0.64, 1);
  pointer-events: none;
  will-change: transform, width;
}

/* Nav items */
.ios-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  min-width: 60px;
  border: none;
  background: none;
  color: var(--nav-item-color);
  font-family: var(--font);
  cursor: pointer;
  border-radius: 16px;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: none;
}
.ios-item:active { transform: scale(0.88); transition: transform 0.08s ease; }
.ios-item.active  { color: var(--nav-item-active); }
.ios-item.ios-danger       { color: rgba(239,68,68,0.55); }
.ios-item.ios-danger.active { color: var(--danger); }
[data-theme="dark"] .ios-item.ios-danger { color: rgba(255,69,58,0.50); }
[data-theme="dark"] .ios-item.ios-danger.active { color: #ff453a; }
.ios-icon  { font-size: 0; line-height: 0; display: flex; align-items: center; }
.ios-icon svg { width: 18px; height: 18px; display: block; }
.ios-label { font-size: 10px; font-weight: 500; letter-spacing: 0.1px; line-height: 1; }

/* ── Heatmap + Hardware side-by-side row ───────────────── */
.hm-hw-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.hm-hw-row .hm-card { flex: 0 0 auto; }
.hm-hw-row .dash-card:not(.hm-card) { flex: 1; min-width: 140px; }

/* ── Pages ─────────────────────────────────────────────── */
.page {
  display: none;
  flex-direction: column;
  height: 100%;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.page.active {
  display: flex;
  opacity: 1;
}
/* Non-dashboard pages: clear the Dynamic Island floating pill */
.page.active:not(#page-dashboard) {
  padding-top: 56px;
}

/* ── Dashboard ──────────────────────────────────────────── */
#page-dashboard {
  display: none;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}
#page-dashboard.active { display: flex; }

.dash-top {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
  overflow: hidden;
}

/* Camera pane */
.camera-pane {
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border-right: 0.5px solid var(--border);
  position: relative;
}
.camera-pane img {
  width: 100%; height: 100%;
  object-fit: contain;
}
.camera-pane .cam-offline {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--t4); font-size: 13px;
}
.cam-offline .cam-icon { font-size: 32px; opacity: 0.3; }
.camera-label {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  border: 0.5px solid rgba(255,255,255,0.08);
  border-radius: 980px;
  padding: 4px 12px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.3px;
  color: var(--t2); text-transform: uppercase;
  display: flex; align-items: center; gap: 5px;
}
.cam-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); flex-shrink: 0;
  transition: background 0.3s;
}
.cam-live-dot.cam-dot-live {
  background: #22c55e;
  animation: pulse 1.4s ease-in-out infinite;
}
.cam-live-dot.cam-dot-off {
  background: #ef4444;
  animation: none;
}
/* Snapshot / Record action buttons in camera tab bar */
.cam-action-btn {
  background: rgba(255,255,255,0.06); border: 0.5px solid var(--border);
  border-radius: var(--r); color: var(--t2); font-size: 14px;
  padding: 4px 8px; cursor: pointer; line-height: 1;
  transition: background var(--trans), color var(--trans);
}
.cam-action-btn:hover { background: rgba(255,255,255,0.14); color: var(--t1); }
.cam-action-btn.recording { color: #ef4444; animation: pulse 1s ease-in-out infinite; }

/* Right info panel */
.info-pane {
  display: flex; flex-direction: column;
  overflow-y: auto;
  background: rgba(0,0,0,0.40);
}
.info-section {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.info-section:last-child { border-bottom: none; }
.info-section .overline { margin-bottom: 10px; }

/* Detection feed */
.det-feed {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t2);
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Stats */
.stat-item {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 0.5px solid var(--border);
  font-size: 13px;
}
.stat-item:last-child { border-bottom: none; }
.stat-item span:first-child { color: var(--t3); }
.stat-item span:last-child  { font-weight: 500; color: var(--t1);
                               font-family: var(--mono); font-size: 12px; }

/* Modes section */
.modes-list {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 2px;
}

/* Console */
.dash-console {
  flex-shrink: 0;
  background: var(--surface-2);
  border-top: 0.5px solid var(--border);
}
.console-header {
  padding: 6px 18px 0;
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--t4);
}
.console {
  background: transparent;
  color: var(--console-color);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 18px 10px;
  height: 80px;
  overflow-y: auto;
  line-height: 1.65;
}

/* ── Narada page ────────────────────────────────────────── */
.page-inner { padding: 24px 28px; flex: 1; overflow-y: auto; }
.page-title { margin-bottom: 4px; }
.page-sub { color: var(--t3); font-size: 13px; margin-bottom: 28px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.section-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.section-title { margin-bottom: 12px; }

/* ── Narada (Messages-style) ──────────────────────────── */
.narada-shell { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.narada-header { display: none !important; } /* Replaced by Dynamic Island label */
.narada-header-hidden {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
[data-theme="dark"] .narada-header {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.narada-header-info { display: flex; align-items: center; gap: 14px; }
.narada-avatar-wrap { position: relative; flex-shrink: 0; }
.narada-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5e5ce6, #bf5af2);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.narada-avatar svg { width: 20px; height: 20px; }
.narada-pulse {
  position: absolute; bottom: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #30D158;
  border: 2px solid var(--bg);
}
.narada-pulse.inactive { background: var(--t4); }
.narada-name { font-size: 16px; font-weight: 600; color: var(--t1); }
.narada-status { font-size: 12px; color: var(--t3); margin-top: 1px; }

.narada-feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.narada-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.5;
  animation: fadeSlideUp 0.2s ease;
}
.narada-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.narada-msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--t1);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.narada-msg-time {
  font-size: 10px;
  color: var(--t4);
  margin-top: 2px;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.narada-cmds-section {
  flex-shrink: 0;
  padding: 12px 20px 16px;
  border-top: 0.5px solid var(--border);
}
.narada-cmds-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--t4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.narada-cmd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.narada-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 980px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.narada-chip:hover {
  background: var(--surface-2);
  color: var(--t1);
  transform: translateY(-1px);
}
.narada-chip-icon { font-size: 13px; opacity: 0.7; }

/* Narada log for admin logs page */
.narada-log {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--t2);
  height: 260px;
  overflow-y: auto;
}
.narada-log .log-line { padding: 1px 0; }
.narada-log .log-line.response { color: var(--accent); }

/* ── Admin pages — macOS System Preferences style ──────── */
.admin-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 32px;
  flex: 1;
  overflow-y: auto;
}
.admin-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 0;
}
.admin-page-header h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }

/* Divider */
.sep { height: 0.5px; background: var(--border); margin: 24px 0; }

/* Table — clean macOS list style */
.t-wrap { overflow-x: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 8px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--t3);
  border-bottom: 0.5px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 0.5px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--table-hover); }

.color-dot {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.10);
  vertical-align: middle;
}

/* Form rows */
.form-stack { display: flex; flex-direction: column; gap: 16px; max-width: 460px; }
.form-row   { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* Slider — macOS style */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--surface-3);
  border-radius: 2px; outline: none; margin-top: 10px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 1px rgba(0,0,0,0.2);
}

/* ── Modal — macOS sheet style ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 400px; max-width: 95vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 18px;
}
.modal h2 { font-size: 19px; letter-spacing: -0.3px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions > * { flex: 1; }

/* Color swatches */
.swatch-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: transform var(--trans), border-color var(--trans);
}
.swatch:hover { transform: scale(1.15); border-color: rgba(255,255,255,0.3); }

/* ── Owner presence badge ───────────────────────────────── */
.owner-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--success);
  letter-spacing: 0.3px;
  opacity: 0.85;
}
.owner-badge.hidden { display: none; }
.owner-refresh-btn {
  background: none;
  border: none;
  color: var(--success);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.2s;
}
.owner-refresh-btn:hover { opacity: 1; transform: rotate(30deg); }
.owner-refresh-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Settings tip box ────────────────────────────────────── */
.tip-box {
  background: var(--room-bg);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--t2);
  line-height: 1.5;
  margin-bottom: 10px;
}

/* ── Settings: section title ────────────────────────────── */
.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

/* ── Settings card — open layout, no box clipping ──────── */
.settings-card {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 28px;
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 24px;
}
.settings-card:last-child { border-bottom: none; }
.settings-card .input-group { margin-bottom: 14px; }
.settings-card .input { max-width: 100%; }
.settings-card .form-row { margin-top: 16px; }
.settings-card .info-banner { margin-bottom: 18px; }
.settings-card .tip-box { margin-bottom: 14px; }
.settings-card .toggle-row { padding: 4px 0; }
.settings-card .device-add-row { margin-top: 12px; }
.settings-card .mk-create-block { margin-top: 12px; }
.settings-card .mk-list { margin-bottom: 8px; }
.settings-card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 4px;
}
.settings-card-desc {
  font-size: 13px;
  color: var(--t3);
  margin-bottom: 12px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
  gap: 16px;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; color: var(--t1); }
.setting-sublabel { font-size: 12px; color: var(--t3); margin-top: 2px; }
.setting-control { flex-shrink: 0; }

/* ── Device list ─────────────────────────────────────────── */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 10px;
  min-height: 24px;
  background: var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  padding: 10px 14px;
  font-size: 13px;
}
.device-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--t4);
  flex-shrink: 0;
}
.device-dot.online { background: var(--success); }
.device-name { flex: 1; color: var(--t1); }
.device-mac  { color: var(--t3); font-family: var(--mono); font-size: 11px; }
.device-empty { font-size: 12px; color: var(--t3); padding: 6px 0; }
.device-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.device-add-row .input { flex: 1; min-width: 120px; }

/* ── Stream quality pills ────────────────────────────────── */
.stream-quality-group {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 2px;
}
.sq-pill {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  transition: all 0.15s;
}
.sq-pill.sq-active {
  background: var(--accent);
  color: #fff;
}
.sq-pill:hover:not(.sq-active) { color: var(--t1); background: rgba(255,255,255,0.05); }

/* ── Logs gate overlay ──────────────────────────────────── */
.logs-gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.logs-gate-overlay.hidden { display: none; }
.logs-gate-card {
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,0.08);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  max-width: 380px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.logs-gate-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.logs-gate-sub { font-size: 13px; color: var(--t3); }
.logs-gate-back {
  display: block;
  background: none; border: none;
  cursor: pointer;
  font-family: var(--font); font-size: 12px;
  color: var(--t3); text-align: left;
  padding: 0; margin-bottom: 4px;
  transition: color var(--trans);
}
.logs-gate-back:hover { color: var(--t1); }

/* ── Master Keys management ────────────────────────────── */
.mk-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border-radius: var(--r); overflow: hidden; }
.mk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--t2);
}
.mk-item-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t4);
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.mk-item-del:hover { color: var(--danger); }
.mk-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mk-add-form .input { flex: 1; }
.mk-step-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mk-orange);
  margin-bottom: 6px;
}
.mk-create-block { margin-top: 4px; }
/* Strength meter */
.mk-strength-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mk-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.mk-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.25s ease, background 0.25s ease;
}
.mk-strength-label {
  font-size: 11px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
  transition: color 0.25s;
}
/* Rules checklist */
.mk-rules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255,255,255,0.02);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
}
.mk-rule {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--t3);
  line-height: 1.4;
}
.mk-rule.pass { color: var(--success); }
.mk-rule.fail { color: var(--t3); }
.mk-rule.opt  { color: var(--t4); }
.mk-rule-icon {
  font-size: 11px;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}
.mk-rule.pass .mk-rule-icon { color: var(--success); }
.mk-rule em { font-style: normal; color: var(--t4); font-size: 10px; }

/* ════════════════════════════════════════════════════════════
   WELCOME VIEW — macOS-style brand + login card
   ════════════════════════════════════════════════════════════ */

/* Top-left brand (WelcomeView) */
.wv-top {
  position: absolute;
  top: 24px; left: 28px;
  z-index: 2;
}
.wv-brand { display: flex; flex-direction: column; gap: 3px; }
.wv-name {
  font-family: var(--mono); font-size: 16px; font-weight: 700;
  letter-spacing: 4px; text-transform: uppercase; color: var(--t1);
}
.wv-tagline {
  font-family: var(--mono); font-size: 10px;
  color: var(--t3); letter-spacing: 0.4px;
}

/* Glassmorphic login card */
.login-card {
  width: 380px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
[data-theme="dark"] .login-card {
  background: rgba(17,17,17,0.82);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.lc-title {
  font-family: var(--mono); font-size: 26px; font-weight: 600;
  color: var(--t1); text-align: center;
  margin-bottom: 6px; letter-spacing: -0.4px;
}
.lc-sub {
  font-size: 13px; color: var(--t3);
  text-align: center; margin-bottom: 22px;
}

/* Backend row */
.backend-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px; margin-bottom: 18px;
}
.bk-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--t4); flex-shrink: 0;
  transition: background var(--trans);
}
.bk-dot.ok { background: var(--success); }
.bk-host {
  flex: 1; font-family: var(--mono); font-size: 12px; color: var(--t3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-text-mono {
  background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px;
  color: var(--accent); padding: 0;
  transition: opacity var(--trans);
}
.btn-text-mono:hover { opacity: 0.7; }

/* Form inputs */
.lc-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.modern-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--t1); font-family: var(--font); font-size: 15px;
  padding: 12px 14px; width: 100%;
  outline: none;
  transition: border-color var(--trans), background var(--trans);
  -webkit-appearance: none;
  box-sizing: border-box;
}
.modern-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-d); }
[data-theme="dark"] .modern-input { background: rgba(255,255,255,0.06); }
.modern-input::placeholder { color: var(--t3); }
.lc-otp {
  text-align: center; letter-spacing: 12px;
  font-size: 30px; font-family: var(--mono); font-weight: 300;
  padding: 16px;
}

/* Inline error */
.lc-err {
  font-size: 12px; color: var(--danger);
  background: var(--danger-d); border-radius: var(--r-sm);
  padding: 8px 12px; margin-bottom: 10px;
  text-align: center;
}

/* Remember me */
.remember-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; cursor: pointer;
}
.remember-chk {
  width: 15px; height: 15px; accent-color: var(--accent);
  cursor: pointer; flex-shrink: 0;
}
.remember-lbl { font-size: 12px; color: var(--t3); user-select: none; }

/* Sign In / action button */
.lc-signin {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r);
  padding: 13px; margin-bottom: 14px;
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background var(--trans);
}
.lc-signin:hover { background: #1a86f0; }
.lc-signin:disabled { opacity: 0.4; cursor: not-allowed; }
.lc-arrow { font-size: 18px; font-weight: 300; }
.lc-signin-danger { background: var(--danger); }
.lc-signin-danger:hover { background: #d93530; }
.lc-signin-mk { background: var(--mk-orange); }
.lc-signin-mk:hover { background: #d4703a; }
.mk-key-input { border-color: rgba(232,133,74,0.3); }
.mk-key-input:focus { border-color: var(--mk-orange); box-shadow: 0 0 0 3px rgba(232,133,74,0.15); }

/* Bottom link row */
.lc-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; }
.lc-link {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--t3);
  font-family: var(--font); padding: 0;
  transition: color var(--trans);
}
.lc-link:hover { color: var(--t1); }

/* Back button */
.lc-back {
  display: block; background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 12px; color: var(--t3);
  padding: 0; margin-bottom: 16px;
  transition: color var(--trans);
}
.lc-back:hover { color: var(--t1); }

/* Footer attribution */
.wv-footer {
  position: absolute; bottom: 24px; left: 0; right: 0;
  text-align: center; z-index: 1; pointer-events: none;
}
.wv-footer-line { font-size: 12px; color: var(--t4); }
.wv-footer-sub  { font-size: 11px; color: var(--t4); margin-top: 3px; }

/* Header eye dot */
.hdr-eye { color: var(--danger); margin-right: 4px; font-size: 10px; }

/* ════════════════════════════════════════════════════════════
   NEW DASHBOARD LAYOUT
   ════════════════════════════════════════════════════════════ */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
  align-items: start;
  height: 100%;
  box-sizing: border-box;
}
.dash-main, .dash-side { display: flex; flex-direction: column; gap: 12px; }

.card,
.dash-card {
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(15,23,42,0.05), 0 1px 3px rgba(15,23,42,0.03);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.dash-card:hover {
  box-shadow: 0 12px 28px rgba(15,23,42,0.08), 0 2px 8px rgba(15,23,42,0.04);
  transform: translateY(-1px);
}
[data-theme="dark"] .card,
[data-theme="dark"] .dash-card {
  box-shadow: 0 10px 24px rgba(0,0,0,0.22), 0 2px 6px rgba(0,0,0,0.12);
}
.dash-card-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.dash-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.2px;
}
.dash-card-meta  { font-size: 10px; color: var(--t4); margin-top: 3px; font-family: var(--mono); }

/* Camera toggle button */
.cam-toggle-btn {
  background: rgba(255,255,255,0.06); border: 0.5px solid var(--border);
  border-radius: var(--r); color: var(--t2); font-size: 12px;
  padding: 5px 10px; cursor: pointer; font-family: var(--font);
  transition: background var(--trans), color var(--trans);
  white-space: nowrap; flex-shrink: 0;
}
.cam-toggle-btn:hover { background: rgba(255,255,255,0.1); color: var(--t1); }

/* Console card */
.dash-console-card {
  background: transparent;
  border: none;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: none;
}
[data-theme="dark"] .dash-console-card {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.dash-console-card .console-header {
  padding: 10px 2px 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--t3);
}
.dash-console-card .console { height: 120px; padding: 2px 2px 0; }
.console {
  background: transparent;
  color: var(--console-color);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 18px 10px;
  height: 80px;
  overflow-y: auto;
  line-height: 1.65;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── Heatmap (GitHub-style) ─────────────────────────────── */
.hm-outer { display: flex; gap: 4px; overflow-x: hidden; }
.hm-left {
  display: flex; flex-direction: column;
  gap: 3px; padding-top: 18px; flex-shrink: 0;
}
.hm-day-label {
  height: 10px; font-family: var(--mono); font-size: 9px;
  color: var(--t4); line-height: 10px; text-align: right;
  padding-right: 4px; width: 24px;
}
.hm-right { display: flex; flex-direction: column; gap: 4px; }
.hm-month-row { position: relative; height: 14px; }
.hm-month-lbl {
  position: absolute; font-family: var(--mono); font-size: 9px;
  color: var(--t4); line-height: 14px; white-space: nowrap;
}
.hm-grid {
  display: grid;
  grid-template-rows: repeat(7, 10px);
  grid-auto-columns: 10px;
  grid-auto-flow: column;
  gap: 3px;
}
.hm-cell  { width: 10px; height: 10px; border-radius: 2px; }
.hm-empty { background: rgba(255,255,255,0.03); }
.hm-0 { background: rgba(255,255,255,0.06); }
.hm-1 { background: rgba(255,69,58,0.25); }
.hm-2 { background: rgba(255,69,58,0.45); }
.hm-3 { background: rgba(255,69,58,0.70); }
.hm-4 { background: var(--danger); }
.hm-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.hm-swatch { width: 10px; height: 10px; border-radius: 2px; }
.hm-legend-lbl { font-family: var(--mono); font-size: 10px; color: var(--t4); }

/* ── Minimal hardware stats ───────────────────────────────── */
.hm-det-card     { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.hm-det-card .det-timeline { flex: 1; max-height: 168px; overflow-y: auto; }

.hw-stats-card   { padding: 20px 24px; }
.hw-stats-row    { display: flex; align-items: center; }
.hw-stat         { flex: 1; text-align: center; padding: 2px 8px; }
.hw-stat-lbl     { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--t4); margin-bottom: 8px; }
.hw-stat-val     { display: block; font-size: 26px; font-weight: 200; color: var(--t1); letter-spacing: -0.02em; }
.hw-stat-div     { width: 0.5px; height: 38px; background: var(--border); flex-shrink: 0; }

/* ── Hardware metric tiles (ring gauges) ─────────────────── */
.hw-metrics { display: flex; gap: 8px; }
.hw-tile {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hw-ring-wrap { position: relative; width: 44px; height: 44px; }
.hw-ring-wrap svg { width: 44px; height: 44px; transform: rotate(-90deg); }
.hw-ring-wrap circle { fill: none; stroke-width: 4; stroke-linecap: round; }
.hw-ring-bg { stroke: var(--surface-3); }
.hw-ring-fg { transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease; }
.hw-ring-val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.hw-tile-label { font-size: 10px; color: var(--t3); font-weight: 500; letter-spacing: 0.3px; text-transform: uppercase; }

/* ── Detection class breakdown ────────────────────────────── */
.class-breakdown { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.class-row  { display: flex; align-items: center; gap: 8px; }
.class-name { font-size: 11px; color: var(--t2); font-family: var(--mono); width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-bar-wrap { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.class-bar  { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.class-count { font-size: 11px; color: var(--t4); font-family: var(--mono); width: 32px; text-align: right; }

/* ── Recent detections timeline ─────────────────────────── */
.det-timeline {
  display: flex; flex-direction: column; gap: 7px;
  max-height: 200px; overflow-y: auto;
}
.det-item { display: flex; align-items: flex-start; gap: 10px; }
.det-time {
  font-family: var(--mono); font-size: 10px; color: var(--t4);
  white-space: nowrap; padding-top: 2px; min-width: 72px;
}
.det-dot {
  width: 7px; height: 7px; border-radius: 50%;
  margin-top: 4px; flex-shrink: 0;
  background: var(--danger);
}
.det-label { font-size: 12px; color: var(--t2); flex: 1; line-height: 1.4; }
.det-empty { font-size: 12px; color: var(--t4); font-style: italic; }
.det-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

/* ── Stat rows (Apple specs-style) ─────────────────────── */
.stat-rows { display: flex; flex-direction: column; }
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-lbl {
  font-size: 12px; color: var(--t3);
  letter-spacing: 0;
}
.stat-val {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--t1);
}

/* ── Security Status Card ───────────────────────────────── */
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.35s ease, background 0.35s ease, border-color 0.35s ease;
  text-align: center;
  position: relative;
}
[data-theme="dark"] .status-card {
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.status-card.alert {
  background: rgba(255,69,58,0.04);
  border-color: rgba(255,69,58,0.18);
}
.status-card.alert-active {
  box-shadow: 0 0 60px rgba(255,69,58,0.10), inset 0 0 60px rgba(255,69,58,0.02);
}
.status-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.status-pulse-ring {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--success);
  background: rgba(48,209,88,0.06);
  transition: border-color 0.35s, background 0.35s;
}
.status-card.alert .status-pulse-ring {
  border-color: var(--danger);
  background: rgba(255,69,58,0.08);
  animation: pulse 1.2s ease-in-out infinite;
}
.status-label {
  font-family: var(--font); font-size: 22px; font-weight: 700;
  letter-spacing: 1px; color: var(--success);
  transition: color 0.35s;
}
.status-card.alert .status-label { color: var(--danger); }
.status-card.alert .status-desc  { color: var(--danger); }
.status-desc { font-size: 14px; color: var(--t2); margin-top: 3px; line-height: 1.4; }
.status-foot {
  display: flex; justify-content: center; align-items: center;
  margin-top: 20px; padding-top: 10px;
  border-top: 0.5px solid var(--border);
  gap: 16px;
}
.status-foot-lbl { font-size: 10px; color: var(--t4); }
.status-foot-val { font-family: var(--mono); font-size: 11px; color: var(--t3); }

/* ── Camera overlay ─────────────────────────────────────── */
.camera-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 300;
  display: flex; flex-direction: column;
}
.cam-ov-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.cam-ov-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  letter-spacing: 0.5px; color: var(--t2); text-transform: uppercase;
}
.cam-ov-meta { font-size: 12px; color: var(--t3); flex: 1; font-family: var(--mono); }
.cam-ov-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; background: #000;
}
.cam-ov-body img, .cam-ov-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.cam-ov-body .cam-offline {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--t4); font-size: 13px;
}
.cam-ov-body .cam-icon { font-size: 36px; opacity: 0.3; }

/* ── Activity Feed ──────────────────────────────────────── */
.activity-feed { display: flex; flex-direction: column; gap: 0; max-height: 300px; overflow-y: auto; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot.danger { background: var(--danger); }
.activity-dot.watch { background: var(--warn); }
.activity-dot.info { background: var(--accent); }
.activity-dot.presence { background: var(--success); }
.activity-text { font-size: 13px; color: var(--t2); line-height: 1.5; flex: 1; }
.activity-time { font-size: 11px; color: var(--t4); white-space: nowrap; flex-shrink: 0; }

/* ── Tabbed Logs ────────────────────────────────────────── */
.log-tabs {
  display: flex;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 16px;
}
.log-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--trans), border-color var(--trans);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.log-tab:hover { color: var(--t2); }
.log-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.logs-page .section-card,
#a-vlog.section-card {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
#a-syslog,
#a-detlog,
#a-preslog,
#a-vlog {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.log-tab-badge {
  display: inline-block;
  background: var(--surface-2);
  color: var(--t3);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}
.log-pane { display: none; }
.log-pane.active { display: block; }

/* ── Security Health Card ────────────────────────────────── */
/* Override: sec-health-card and logs card keep their card appearance */
.sec-health-card {
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 20px;
  border-bottom: none;
  padding-bottom: 20px;
}
/* Logs card — keeps enclosed card look */
.settings-card.logs-card {
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  border-bottom: none;
  padding: 0;
  overflow: hidden;
}
.sec-health-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 980px;
  background: rgba(48,209,88,0.15);
  color: #30D158;
  letter-spacing: 0.1px;
}
.sec-health-badge.warn {
  background: rgba(255,159,10,0.15);
  color: #FF9F0A;
}
.sec-health-badge.critical {
  background: rgba(255,69,58,0.15);
  color: #FF453A;
}
.sec-health-rows { display: flex; flex-direction: column; gap: 0; }
.sec-health-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}
.sec-health-row:last-child { border-bottom: none; }
.sec-health-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.sec-health-icon.ok { background: rgba(48,209,88,0.15); color: #30D158; }
.sec-health-icon.warn { background: rgba(255,159,10,0.15); color: #FF9F0A; }
.sec-health-icon.critical { background: rgba(255,69,58,0.15); color: #FF453A; }
.sec-health-info { flex: 1; min-width: 0; }
.sec-health-name { font-size: 13px; font-weight: 600; color: var(--t1); }
.sec-health-desc { font-size: 11px; color: var(--t3); margin-top: 1px; }

/* ── Toast System — macOS notification style ───────────── */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease forwards;
  max-width: 400px;
}
.toast.success { background: rgba(48,209,88,0.15); border: 0.5px solid rgba(48,209,88,0.25); color: #30D158; }
.toast.error   { background: rgba(255,69,58,0.15); border: 0.5px solid rgba(255,69,58,0.25); color: #FF453A; }
.toast.info    { background: rgba(10,132,255,0.15); border: 0.5px solid rgba(10,132,255,0.25); color: #0A84FF; }
.toast.warning { background: rgba(255,159,10,0.15); border: 0.5px solid rgba(255,159,10,0.25); color: #FF9F0A; }
.toast-dismiss {
  cursor: pointer; opacity: 0.6; margin-left: auto; font-size: 16px;
  background: none; border: none; color: inherit;
}
.toast-dismiss:hover { opacity: 1; }
.toast.removing { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(16px); } }

/* ── System health warning ──────────────────────────────── */
.health-warn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--warn-d);
  border: 0.5px solid rgba(255,159,10,0.18);
  border-radius: 12px;
  font-size: 13px;
  color: var(--warn);
  margin-bottom: 16px;
}
.health-warn-icon { font-size: 18px; flex-shrink: 0; }
.health-warn-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--warn);
  opacity: 0.6;
  cursor: pointer;
  font-size: 16px;
}

/* ── Info banner ────────────────────────────────────────── */
.info-banner {
  background: var(--accent-d);
  border: 0.5px solid rgba(10,132,255,0.15);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--t2);
  line-height: 1.6;
  margin-bottom: 16px;
}
.info-banner strong { color: var(--t1); }

/* ── Skeleton loading ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Empty states ───────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  color: var(--t3);
  font-size: 13px;
  gap: 8px;
}
.empty-state-icon { font-size: 28px; opacity: 0.4; }

/* ── Chat page — macOS Messages style ───────────────────── */
#page-chat { padding: 0; overflow: hidden; }
.chat-shell {
  display: flex; flex-direction: column;
  height: 100%; max-height: 100%;
  position: relative; /* anchor for absolute-positioned input pill */
}

/* Header — hidden, replaced by Dynamic Island */
.chat-header { display: none !important; }
.chat-header-hidden {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
[data-theme="dark"] .chat-header {
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(20px);
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar-wrap { position: relative; width: 38px; height: 38px; flex-shrink: 0; }
.chat-avatar-gradient {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #0A84FF, #5e5ce6);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.chat-name {
  font-size: 14px; font-weight: 600; color: var(--t1);
  display: flex; align-items: center; gap: 8px;
}
.chat-model-tag {
  font-size: 10px; font-weight: 500; font-family: var(--mono);
  background: rgba(255,255,255,0.06); border: 0.5px solid var(--border);
  border-radius: 4px; padding: 1px 6px; color: var(--t3);
  letter-spacing: 0.02em;
}
.chat-sub { font-size: 11px; color: var(--t4); margin-top: 2px; }

/* Header controls */
.chat-header-controls { display: flex; align-items: center; gap: 8px; }

/* Model tier selector — macOS segmented control */
.model-tier-selector {
  display: flex; gap: 1px;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 8px; padding: 2px;
}
.tier-btn {
  font-size: 10px; font-weight: 600; font-family: var(--mono);
  letter-spacing: 0.04em; text-transform: uppercase;
  background: transparent; border: none;
  color: var(--t4); cursor: pointer;
  padding: 4px 10px; border-radius: 6px;
  transition: color var(--trans), background var(--trans);
}
.tier-btn:hover { color: var(--t2); background: rgba(255,255,255,0.04); }
.tier-btn.tier-btn-active {
  background: rgba(255,255,255,0.10);
  color: var(--t1);
}

/* Info / clear buttons */
.chat-info-btn,
.chat-clear-btn {
  width: 30px; height: 30px; border-radius: 8px; background: transparent;
  border: 0.5px solid var(--border); color: var(--t4); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--trans), border-color var(--trans), background var(--trans);
}
.chat-info-btn:hover, .chat-info-btn.active,
.chat-clear-btn:hover { color: var(--t1); border-color: var(--t3); background: rgba(255,255,255,0.04); }
.chat-info-btn svg, .chat-clear-btn svg { width: 14px; height: 14px; }

/* Rate limit info bubble */
.chat-ratelimit-bubble {
  background: rgba(0,0,0,0.85);
  border-bottom: 0.5px solid var(--border);
  padding: 0 20px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.32s ease, opacity 0.25s ease, padding 0.32s ease;
}
.chat-ratelimit-bubble.open {
  max-height: 220px;
  opacity: 1;
  padding: 14px 20px;
}
.rl-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--t4);
  margin-bottom: 10px;
}
.rl-table { display: flex; flex-direction: column; gap: 5px; }
.rl-row {
  display: grid;
  grid-template-columns: 46px 1fr 56px 58px 50px 52px;
  gap: 8px; align-items: center;
  font-size: 11px;
}
.rl-head {
  color: var(--t4); font-size: 10px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding-bottom: 4px; border-bottom: 0.5px solid var(--border);
}
.rl-row:not(.rl-head) { color: var(--t3); }
.rl-row.rl-active { color: var(--t1) !important; }
.rl-row.rl-active .rl-model { color: var(--t2) !important; }
.rl-tier-badge {
  display: inline-block;
  font-size: 9px; font-weight: 700; font-family: var(--mono);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.rl-low  { color: #6ed89a; }
.rl-med  { color: #d4913a; }
.rl-high { color: #d46a6a; }
.rl-model {
  font-family: var(--mono); font-size: 10px; color: var(--t4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rl-note {
  margin-top: 10px; font-size: 10px; color: var(--t4);
  border-top: 0.5px solid var(--border); padding-top: 8px;
  line-height: 1.5;
}

/* Messages area */
.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px 0 16px;
  display: flex; flex-direction: column; gap: 0;
  scroll-behavior: smooth;
}

/* Message rows */
.chat-msg {
  display: flex; gap: 14px;
  padding: 8px 20px;
}

/* User pill — right-aligned, iMessage blue */
.chat-msg.user {
  flex-direction: row-reverse;
  padding: 6px 20px;
}
.chat-msg-pill {
  max-width: 70%;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  font-size: 14px; line-height: 1.55;
  overflow-wrap: break-word;
}

/* Assistant — left, with avatar */
.chat-msg.assistant { align-items: flex-start; }
.chat-msg-avatar-gradient {
  display: none;
}
.chat-msg-content { flex: 1; min-width: 0; }
.chat-msg-body {
  font-size: 14px; line-height: 1.65;
  color: var(--t1);
  overflow-wrap: break-word;
}

/* Markdown elements */
.chat-msg-body strong { font-weight: 600; color: var(--t1); }
.chat-msg-body em     { font-style: italic; color: var(--t2); }
.chat-heading {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--t1); margin: 10px 0 4px; letter-spacing: -0.01em;
  text-wrap: balance;
}
.chat-li {
  display: block; padding-left: 14px; position: relative;
  margin: 2px 0;
}
.chat-li::before {
  content: '\00B7'; position: absolute; left: 4px; color: var(--t4);
}
.chat-inline-code {
  font-family: var(--mono); font-size: 12px;
  background: rgba(255,255,255,0.08); border: 0.5px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: #e2c08d;
}
.chat-code-block {
  font-family: var(--mono); font-size: 12px;
  background: rgba(0,0,0,0.5); border: 0.5px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin: 8px 0;
  overflow-x: auto; color: #a8d8a8; line-height: 1.5;
  white-space: pre;
}

/* Streaming cursor */
.chat-cursor {
  display: inline-block; width: 2px; height: 14px;
  background: var(--accent); border-radius: 1px; margin-left: 1px;
  vertical-align: text-bottom;
  animation: blink 0.9s step-end infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Thinking block */
.chat-thinking {
  margin: 8px 20px;
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  transition: opacity 0.3s;
}
.chat-thinking.think-fade-out { opacity: 0; }
.think-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--t4);
  margin-bottom: 8px;
}
.think-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: 0.9;
  animation: think-pulse 1.2s ease-in-out infinite;
}
@keyframes think-pulse {
  0%,100% { transform: scale(1);   opacity: 0.9; }
  50%      { transform: scale(1.4); opacity: 0.4; }
}
.think-lines { display: flex; flex-direction: column; gap: 4px; min-height: 18px; }
.think-line {
  font-size: 12px; color: var(--t3); font-family: var(--mono);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.think-line-in  { opacity: 1; transform: translateY(0); }
.think-line-out { opacity: 0; transform: translateY(-6px); }

/* Input pill — floats above feedback bubble on desktop */
/* Base desktop: raise input above iOS nav (bottom:16px, ~68px tall) */
#page-chat .chat-input-wrap { bottom: 84px; z-index: 950; }
/* messages padding = input bottom (84px) + input height (~52px) + 12px gap */
#page-chat .chat-messages { padding-bottom: 148px; }

/* Desktop: when chat page is active, raise input above feedback bubble
   (feedback: fixed bottom:24px, 48px tall → top at 72px from viewport)
   Input raised by feedback height (48px) + gap (12px) = bottom:132px in shell */
@media (min-width: 769px) {
  body:has(#page-chat.active) #page-chat .chat-input-wrap {
    bottom: 132px;
  }
  body:has(#page-chat.active) #page-chat .chat-messages {
    padding-bottom: 200px; /* 132px + ~52px input + 16px gap */
  }
}

.chat-input-wrap {
  position: absolute;
  bottom: 16px; left: 16px; right: 16px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 8px 8px 18px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 10;
}
[data-theme="dark"] .chat-input-wrap {
  background: rgba(28,28,30,0.82);
}
/* padding-bottom no longer needed — input is in flex flow */
.chat-input-box {
  flex: 1;
  display: flex; align-items: flex-end; gap: 10px;
  background: transparent;
  border: none;
  padding: 0;
}
.chat-textarea {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 14px; font-family: var(--font);
  color: var(--t1); resize: none; line-height: 1.55;
  max-height: 100px; overflow-y: auto; padding: 2px 0;
}
.chat-textarea::placeholder { color: var(--t4); }
.chat-send-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: opacity var(--trans), transform 0.1s ease;
}
.chat-send-btn:hover  { opacity: 0.85; }
.chat-send-btn:active { transform: scale(0.9); }
.chat-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.chat-send-btn svg { width: 15px; height: 15px; }
.chat-hint { display: none; }
.chat-disclaimer {
  font-size: 10px; color: var(--t4); text-align: center;
  margin-top: 4px; letter-spacing: 0.01em; opacity: 0.7;
}

/* ── Login screen theme toggle ──────────────────────────── */
.login-theme-toggle {
  position: fixed;
  top: 18px; right: 20px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--t2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans), color var(--trans);
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.login-theme-toggle:hover { background: var(--surface-2); color: var(--t1); }
.login-theme-toggle svg { width: 16px; height: 16px; display: block; }
.login-theme-toggle .t-sun { display: none; }
.login-theme-toggle .t-moon { display: block; }
[data-theme="dark"] .login-theme-toggle .t-sun { display: block; }
[data-theme="dark"] .login-theme-toggle .t-moon { display: none; }
#app.logged-in .login-theme-toggle { display: none; }

/* ── Docs bubble button ─────────────────────────────────── */
.wv-docs-btn {
  position: fixed;
  bottom: 26px; left: 28px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface);
  border: 0.5px solid var(--border);
  color: var(--t4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  z-index: 50;
}
.wv-docs-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--t2);
  border-color: rgba(255,255,255,0.12);
}
.wv-docs-btn svg { display: block; }

/* ── Docs modal ─────────────────────────────────────────── */
.docs-modal {
  width: min(700px, 96vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, #fff 8%) 0%, var(--surface) 22%, var(--surface-2) 100%);
  border: 1px solid color-mix(in srgb, var(--border) 82%, rgba(255,255,255,0.18));
  border-radius: 24px;
  box-shadow:
    0 28px 90px rgba(0,0,0,0.24),
    0 10px 28px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(255,255,255,0.28);
}
.docs-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 88%, rgba(255,255,255,0.08));
  background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.02) 100%);
  flex-shrink: 0;
}
.docs-topbar h2 {
  margin: 0;
}
.docs-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--t3);
  line-height: 1.45;
}
.docs-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 86%, rgba(255,255,255,0.12));
  color: var(--t2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.docs-close-btn span {
  font-size: 17px;
  line-height: 1;
  transform: translateY(-1px);
}
.docs-close-btn:hover {
  background: color-mix(in srgb, var(--surface-3) 88%, rgba(255,255,255,0.20));
  color: var(--t1);
  border-color: color-mix(in srgb, var(--border) 70%, var(--accent) 30%);
  transform: scale(1.04);
}
.docs-close-btn:active {
  transform: scale(0.96);
}
.docs-body {
  overflow-y: auto; flex: 1;
  padding: 0 24px 16px;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.docs-footer {
  padding: 14px 22px 20px;
  border-top: 1px solid color-mix(in srgb, var(--border) 88%, rgba(255,255,255,0.08));
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.10) 100%);
  flex-shrink: 0;
}
.docs-footer-close {
  width: 100%;
  min-height: 42px;
  border-radius: 14px;
}

/* Docs tabs */
.docs-tabs {
  display: flex;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}
.docs-tabs::-webkit-scrollbar { display: none; }
.docs-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t3);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  white-space: nowrap;
  transition: color var(--trans), border-color var(--trans);
}
.docs-tab:hover { color: var(--t2); }
.docs-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Docs sections */
.docs-section {
  display: none;
  padding: 18px 0;
  border-bottom: 0.5px solid var(--border);
}
.docs-section.active { display: block; }
.docs-section:last-child { border-bottom: none; }
.docs-section h3 { font-size: 17px; margin: 20px 0 10px; color: var(--t1); }
.docs-section h4 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--t2); }
.docs-section p, .docs-section li { font-size: 14px; color: var(--t2); line-height: 1.7; }
.docs-section code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}
.docs-section-title {
  font-family: var(--font); font-size: 11px; font-weight: 600;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--t3); margin-bottom: 12px;
}
.docs-p {
  font-size: 12px; color: var(--t3); line-height: 1.6;
  margin-top: 10px;
}
.docs-rows { display: flex; flex-direction: column; gap: 0; }
.docs-row {
  display: flex; gap: 12px;
  padding: 7px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.docs-row:last-child { border-bottom: none; }
.docs-term {
  font-family: var(--mono); font-size: 11px; color: var(--t2);
  min-width: 130px; flex-shrink: 0;
}
.docs-term.mono-term { color: var(--accent); }
.docs-def { color: var(--t3); line-height: 1.5; }

/* Docs flow */
.docs-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.docs-flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--t2);
}
.docs-flow-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-d);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.docs-flow-arrow { color: var(--t4); font-size: 14px; }

/* Docs stack grid */
.docs-stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.docs-stack-item {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.docs-stack-item strong { font-size: 13px; display: block; margin-bottom: 4px; }
.docs-stack-item span { font-size: 12px; color: var(--t3); }

/* ── Flowchart nodes ────────────────────────────────────── */
.fc-wrap { margin-bottom: 2px; }
.fc-row {
  display: flex; align-items: center; gap: 0;
  flex-wrap: wrap; row-gap: 6px;
}
.fc-node {
  background: rgba(255,255,255,0.04);
  border: 0.5px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 4px 9px;
  font-family: var(--mono); font-size: 10px; color: var(--t2);
  white-space: nowrap;
}
.fc-node.fc-accent  { border-color: rgba(10,132,255,0.25);  color: var(--accent);  background: rgba(10,132,255,0.06); }
.fc-node.fc-success { border-color: rgba(48,209,88,0.25);   color: var(--success); background: rgba(48,209,88,0.06); }
.fc-node.fc-danger  { border-color: rgba(255,69,58,0.25);   color: var(--danger);  background: rgba(255,69,58,0.06); }
.fc-node.fc-muted   { border-color: rgba(255,255,255,0.06); color: var(--t3); }
.fc-arr {
  font-family: var(--mono); font-size: 11px; color: var(--t4);
  padding: 0 5px; flex-shrink: 0; user-select: none;
}
.fc-arr-down { padding: 3px 0; display: block; }

/* Branch layout */
.fc-branch-row {
  display: flex; align-items: flex-start; gap: 24px;
  margin-top: 8px; padding-top: 4px;
}
.fc-branch-left, .fc-branch-right {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.fc-branch-sep {
  width: 0.5px; background: var(--border);
  align-self: stretch; margin-top: 4px;
}
.fc-branch-label {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.3px;
}
.success-text { color: var(--success); }
.muted-text   { color: var(--t4); }

/* ── Mobile responsive ─────────────────────────────────── */
@media (max-width: 768px) {

  html, body, #app, #app-shell, #body, #main {
    overflow-x: hidden;
  }
  body {
    touch-action: manipulation;
  }
  button, a, input, textarea, select {
    touch-action: manipulation;
  }

  /* App shell: unlock fixed layout, allow scrolling */
  #app           { height: auto; min-height: 100vh; overflow-x: hidden; overflow-y: visible; }
  #app-shell     { overflow-x: hidden; overflow-y: visible; }
  #body          { overflow-x: hidden; overflow-y: visible; flex-direction: column; }
  #main          { overflow-x: hidden; overflow-y: visible; }
  .page          { height: auto; }
  #page-dashboard { overflow: visible; height: auto; }

  /* Chat: pin to viewport */
  #page-chat {
    position: fixed;
    top: 52px;
    left: 0; right: 0; bottom: 0;
    height: auto;
    overflow-x: hidden;
    overflow-y: hidden;
    z-index: 2;
  }
  #page-chat .chat-shell { height: 100%; overflow-x: hidden; }
  /* messages padding = input bottom (92px) + input height (~48px) + feedback bubble (46px) + gap */
  #page-chat .chat-messages { overflow-x: hidden; padding-bottom: 200px; }
  #page-chat .chat-input-wrap {
    bottom: 92px; left: 12px; right: 12px;
    padding: 6px 6px 6px 14px;
  }
  #page-chat .chat-input-box { gap: 8px; }
  #page-chat .chat-textarea {
    font-size: 15px;
    line-height: 1.4;
    max-height: 72px;
    padding: 1px 0;
  }
  #page-chat .chat-send-btn {
    width: 30px;
    height: 30px;
  }

  /* Voice page should behave like a full-height mobile sheet */
  #page-narada {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    overflow: hidden;
    z-index: 2;
  }
  #page-narada .narada-shell {
    height: 100%;
  }
  #page-narada .narada-feed {
    padding: 16px 16px 12px;
  }
  #page-narada .narada-cmds-section {
    margin-top: auto;
    padding: 12px 16px calc(90px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 0%, var(--bg) 72%, transparent 100%);
    border-top: none;
  }

  /* Login */
  .login-wordmark  { font-size: 48px; letter-spacing: 4px; }
  .login-subtitle  { font-size: 15px; }
  .login-hero      { margin-bottom: 32px; }
  .login-center    { padding: 40px 20px 80px; justify-content: flex-start; padding-top: 80px; }
  #profile-cards   { gap: 20px; max-width: 100%; }
  .profile-avatar  { width: 64px; height: 64px; font-size: 22px; }
  .profile-card .profile-name { font-size: 12px; }
  .login-corner    { bottom: 16px; right: 16px; }
  #login-panel, #admin-otp-screen, #forgot-screen { max-width: 100%; }

  /* Header */
  #header      { padding: 0 14px; gap: 10px; }
  #header-pills { display: none; }
  .hdr-user    { display: none; }

  /* iOS nav mobile */
  #ios-nav {
    bottom: 10px;
    padding: 4px 10px;
    max-width: calc(100vw - 32px);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    justify-content: flex-start;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  #ios-nav::-webkit-scrollbar { display: none; }
  .ios-item  { padding: 6px 9px; min-width: 42px; flex-shrink: 0; scroll-snap-align: center; border-radius: 14px; }
  .ios-label { font-size: 8.5px; }
  .ios-icon svg { width: 16px; height: 16px; }

  /* Heatmap + hardware stay side-by-side */
  .hm-hw-row { flex-direction: row; flex-wrap: nowrap; overflow-x: hidden; }
  .hm-hw-row .hm-card { flex: 0 0 auto; min-width: 0; }
  .hm-hw-row .dash-card:not(.hm-card) { flex: 1; min-width: 120px; }

  /* Dashboard — stacked layout */
  .dash-top {
    grid-template-columns: 1fr;
    overflow: visible;
    flex: none;
    min-height: 0;
  }
  .camera-pane {
    height: 240px;
    border-right: none;
    border-bottom: 0.5px solid var(--border);
    position: relative;
  }
  .info-pane {
    overflow: visible;
    flex: none;
    max-height: none;
  }
  .info-section:last-child { overflow: visible; flex: none; }
  .det-feed { max-height: 120px; overflow-y: auto; }
  .modes-list  { gap: 5px; }
  .console     { height: 120px; }
  .dash-console { flex-shrink: 0; }
  .readout-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .readout-val  { font-size: 15px; }

  /* Hardware metric tiles */
  .hw-metrics { flex-wrap: wrap; }
  .hw-tile { flex: 1 1 calc(50% - 8px); min-width: 0; }

  /* Narada / Admin */
  .page-inner  { padding: 18px 16px; flex: none; overflow: visible; }
  .two-col     { grid-template-columns: 1fr; }
  .admin-page  { padding: 18px 16px; flex: none; overflow: visible; max-width: 100%; }
  .admin-page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .form-stack  { max-width: 100%; }
  .form-row    { flex-direction: column; }
  .narada-log  { height: 180px; }

  /* Device add row — stack on mobile */
  .device-add-row { flex-direction: column; }
  .device-add-row .input { min-width: 0; width: 100%; }
  .device-add-row .btn { width: 100%; }

  /* Master key forms — full width */
  .mk-add-form { flex-direction: column; }
  .mk-add-form .input { width: 100%; }
  .mk-add-form .btn { width: 100%; }

  /* Settings section title — stack when it has inline button */
  .settings-section-title { flex-wrap: wrap; gap: 8px; }

  /* Sec health card on mobile */
  .sec-health-card { padding: 16px; }
  .sec-health-row { flex-wrap: wrap; }
  .sec-health-desc { word-break: break-word; }

  /* Modals */
  .modal       { width: 95vw; padding: 20px; max-height: 90vh; overflow-y: auto; overscroll-behavior: contain; }
  #m-docs .modal {
    width: min(96vw, 720px);
    max-height: calc(100vh - 18px);
    padding: 0;
    gap: 0;
    border-radius: 20px;
  }
  #m-docs .docs-body {
    padding: 0 16px 12px;
    min-height: 0;
  }
  #m-docs .docs-topbar {
    padding: 16px 16px 12px;
  }
  #m-docs .docs-close-btn {
    width: 28px;
    height: 28px;
  }
  #m-docs .docs-close-btn span {
    font-size: 16px;
  }
  #m-docs .docs-footer {
    display: none;
  }
  #m-docs .docs-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  #m-docs .docs-tabs::-webkit-scrollbar { display: none; }
  #m-docs .docs-section {
    padding: 12px 0;
  }
  #m-docs .docs-stack-grid {
    grid-template-columns: 1fr;
  }

  /* Tables */
  .t-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table   { min-width: 480px; }

  /* Touch targets — min 44px */
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 36px; }
  .nav-item { padding: 11px 10px; }
  .input   { padding: 12px 14px; font-size: 16px; }
}

/* ── Mobile login & dashboard overrides ────────────────── */
@media (max-width: 768px) {

  /* Login: card centred, brand absolute */
  #login-screen { overflow-y: auto; }
  .wv-top     { top: 20px; left: 20px; }
  .wv-name    { font-size: 15px; letter-spacing: 3px; }
  .wv-tagline { font-size: 10px; }
  .login-center {
    justify-content: center;
    padding: 72px 20px 72px;
    min-height: 100vh;
    box-sizing: border-box;
  }
  .login-card { padding: 24px 18px; width: 100%; max-width: 380px; flex-shrink: 1; }
  .lc-title   { font-size: 22px; }
  .wv-docs-btn { bottom: 16px; left: 20px; }

  /* Dashboard */
  .dash-layout {
    grid-template-columns: 1fr;
    height: auto;
    padding: 14px;
    gap: 16px;
  }
  .modern-input { font-size: 16px; }

  /* Log tabs scroll on mobile */
  .log-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .log-tabs::-webkit-scrollbar { display: none; }
  .log-tab { flex-shrink: 0; }

  /* Docs modal */
  .docs-term    { min-width: 100px; }
  .fc-branch-row { gap: 14px; }

  /* Admin headings are duplicated by the Dynamic Island on mobile */
  .admin-page-header h2 { display: none; }
  .admin-page-header {
    margin-bottom: 12px;
    min-height: 0;
  }

  /* Custom commands need horizontal room on small screens */
  #page-a-cmds .settings-card { overflow: hidden; }
  #page-a-cmds .t-wrap { overflow-x: auto; }
  #page-a-cmds table { min-width: 640px; }
  /* Add Command button moves to bottom on mobile */
  #page-a-cmds .admin-page-header .btn { display: none; }
  .cmd-add-mobile { display: flex; width: 100%; margin-top: 14px; justify-content: center; }

  /* Activity date should remain readable without opening the picker */
  .activity-date-picker {
    min-width: 138px;
    color: var(--t1);
    -webkit-text-fill-color: var(--t1);
    text-align: right;
    opacity: 1;
  }
  .activity-date-picker::-webkit-date-and-time-value {
    text-align: right;
    min-height: 1.2em;
    color: var(--t1);
  }
}

@media (max-width: 600px) {
  .hw-metrics { flex-wrap: wrap; gap: 6px; }
  .hw-tile { flex: 1 1 calc(50% - 6px); }
}

/* ════════════════════════════════════════════════════════════
   SOFT UI REDESIGN — New Components (v43)
   ════════════════════════════════════════════════════════════ */

/* ── Theme toggle button ─────────────────────────────────── */
.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--t2);
  cursor: pointer;
  transition: background var(--trans), color var(--trans), transform 0.3s ease;
  flex-shrink: 0;
}
.theme-toggle-btn:hover { background: var(--surface-3); color: var(--t1); }
.theme-toggle-btn:active { transform: rotate(20deg); }
.theme-toggle-btn svg { width: 16px; height: 16px; display: block; }
/* sun rays: visible in dark, hidden in light */
.theme-toggle-btn .t-sun { display: none; }
.theme-toggle-btn .t-moon { display: block; }
[data-theme="dark"] .theme-toggle-btn .t-sun { display: block; }
[data-theme="dark"] .theme-toggle-btn .t-moon { display: none; }

/* ── 3-Column Dashboard Layout ───────────────────────────── */
#page-dashboard {
  display: none;
  overflow: hidden;
  height: 100%;
}
#page-dashboard.active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-top: 44px; /* clear Dynamic Island — tight to show depth */
}

.app-shell-dash {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  grid-template-rows: 1fr;
  gap: 14px;
  padding: 14px;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.sidebar-left, .sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
}

.center-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden; /* camera fills remaining height, no scroll */
}

/* ── Camera main card (center) ───────────────────────────── */
.cam-main-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 200px; /* guarantee camera visible */
}

.cam-tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.cam-tab-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--t3);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--trans), background var(--trans);
}
.cam-tab-btn.active {
  color: var(--accent);
  background: var(--accent-d);
}
.cam-tab-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cam-status-txt {
  font-size: 10px;
  color: var(--t3);
  font-family: var(--mono);
}

.cam-view {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.cam-view.hidden { display: none; }
.cam-view img, .cam-view video {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.cam-view object {
  width: 100%; height: 100%;
  display: block;
}

/* HUD overlay on camera */
.cam-hud-overlay {
  position: absolute;
  top: 10px; left: 10px; right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}
.cam-hud-left {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 4px 10px;
}
.cam-live-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}
.cam-hud-fps {
  font-size: 11px; font-weight: 600; color: #fff;
  font-family: var(--mono);
}
.cam-hud-time {
  font-size: 11px; color: rgba(255,255,255,0.7);
  font-family: var(--mono);
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Cam offline state */
.cam-view-offline {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--t3); font-size: 13px;
  background: var(--surface-2);
}
.cam-view-offline svg { opacity: 0.3; }

/* Alert status bar below camera */
.alert-status-bar {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.alert-status-bar.alerting {
  background: var(--danger-d);
  border-color: var(--danger);
}
.asb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
}
.alert-status-bar.alerting .asb-dot {
  background: var(--danger);
  animation: pulse 0.8s ease-in-out infinite;
}
.asb-label {
  font-size: 13px; font-weight: 600; color: var(--t1);
  flex: 1;
}
.asb-time { font-size: 11px; color: var(--t3); font-family: var(--mono); }

/* ── Hub Health bars (left sidebar) ─────────────────────── */
.hub-health-wrap { display: flex; flex-direction: column; gap: 9px; }
.hub-health-row  { display: flex; align-items: center; gap: 8px; }
.hub-health-label {
  width: 32px;
  font-size: 11px; font-weight: 600;
  color: var(--t3);
  text-transform: uppercase; letter-spacing: 0.3px;
  flex-shrink: 0;
}
.hub-health-track {
  flex: 1; height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.hub-health-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.6s ease;
  width: 0%;
}
.hub-health-fill.warn { background: var(--warn); }
.hub-health-fill.crit { background: var(--danger); }
.hub-health-val {
  width: 38px; text-align: right;
  font-size: 11px; font-family: var(--mono);
  color: var(--t3);
}

/* ── Card title / header ─────────────────────────────────── */
.sidebar-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 16px;
  flex-shrink: 0;
}
.sidebar-card-title {
  font-size: 12px; font-weight: 600;
  color: var(--t3); text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ── System status mini-stats ────────────────────────────── */
.mini-stats { display: flex; flex-direction: column; gap: 1px; }
.mini-stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.mini-stat-row:last-child { border-bottom: none; }
.mini-stat-label { color: var(--t3); }
.mini-stat-val   { color: var(--t1); font-family: var(--mono); font-weight: 500; }

/* ── Mode pill toggles (left sidebar) ───────────────────── */
.mode-pills-list { display: flex; flex-direction: column; gap: 6px; }
.mode-pill-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--trans), opacity var(--trans);
  user-select: none;
}
.mode-pill-row:hover { background: var(--surface-3); }
.mode-pill-row.pill-active {
  background: color-mix(in srgb, var(--accent-mint) 40%, var(--surface));
}
[data-theme="dark"] .mode-pill-row.pill-active {
  background: rgba(48,209,88,0.12);
}
.mode-pill-row.pill-danger.pill-active {
  background: color-mix(in srgb, var(--danger-d) 60%, var(--surface));
}
[data-theme="dark"] .mode-pill-row.pill-danger.pill-active {
  background: rgba(255,69,58,0.12);
}
.mode-pill-row.pill-warn.pill-active {
  background: color-mix(in srgb, var(--warn-d) 60%, var(--surface));
}
.mode-pill-icon {
  font-size: 15px; width: 24px; flex-shrink: 0;
  text-align: center;
}
.mode-pill-label {
  flex: 1; margin-left: 6px;
  font-size: 13px; font-weight: 500;
  color: var(--t2);
}
.mode-pill-row.pill-active .mode-pill-label { color: var(--t1); }
/* Small macOS-style toggle inside pill row */
.mode-pill-toggle {
  width: 34px; height: 20px; border-radius: 10px;
  background: var(--surface-3); flex-shrink: 0;
  position: relative;
  transition: background 0.2s ease;
}
.mode-pill-toggle.on { background: var(--success); }
.mode-pill-toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.mode-pill-toggle.on::after { transform: translateX(14px); }

/* ── Activity Timeline (right sidebar) ──────────────────── */
.activity-timeline-wrap {
  display: flex; flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-height: 320px;
}
.activity-card-scroll {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.activity-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.activity-card-header-title {
  font-size: 12px; font-weight: 600;
  color: var(--t3); text-transform: uppercase; letter-spacing: 0.5px;
}
.activity-date-picker {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--t2);
  font-family: var(--font);
  cursor: pointer;
  /* Ensure date text visible on all platforms */
  -webkit-text-fill-color: var(--t2);
  opacity: 1;
}
.activity-date-picker:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); }

.timeline-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.timeline-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 16px;
  transition: background var(--trans);
}
.timeline-item .tl-dot { margin-top: 4px; }
.timeline-item:hover { background: var(--surface-2); }
.tl-dot-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 0;
  flex-shrink: 0; padding-top: 3px;
}
.tl-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.tl-dot.danger { background: var(--danger); }
.tl-dot.warn   { background: var(--warn); }
.tl-dot.watch  { background: var(--purple); }
.tl-dot.presence { background: var(--success); }
.tl-line {
  width: 1px; flex: 1; min-height: 8px;
  background: var(--border);
  margin-top: 3px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-title {
  font-size: 12px; font-weight: 500;
  color: var(--t1); line-height: 1.4;
  word-break: break-word;
}
.tl-time { font-size: 10px; color: var(--t3); margin-top: 2px; }

/* ── Recent detections (right sidebar) ──────────────────── */
.det-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 14px;
  flex-shrink: 0;
}

/* ── Narada chat bubbles (updated for dual theme) ────────── */
.chat-msg.user .chat-msg-pill {
  background: var(--surface-2) !important;
  color: var(--t1) !important;
  border-radius: 20px 20px 4px 20px !important;
}
.chat-msg.assistant .chat-msg-content .chat-msg-body {
  color: var(--t1);
}
.chat-msg.assistant .chat-msg-content {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
}
[data-theme="dark"] .chat-msg.assistant .chat-msg-content {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.16);
}
[data-theme="dark"] .chat-msg.user .chat-msg-pill {
  background: var(--surface-2) !important;
}
/* Narada response bubble accent */
.chat-msg.assistant .chat-msg-avatar-gradient {
  background: var(--accent-purple) !important;
  color: var(--accent) !important;
}
[data-theme="dark"] .chat-msg.assistant .chat-msg-avatar-gradient {
  background: var(--accent-d) !important;
  color: var(--accent) !important;
}

/* ── Chat header glass ───────────────────────────────────── */
.chat-header {
  background: var(--glass) !important;
}

/* ── Sign out button light mode ──────────────────────────── */
#header .btn-ghost[onclick*="logout"],
.hud-signout { color: var(--danger) !important; opacity: 0.7; }

/* ── Autofill fix (light mode) ───────────────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
  -webkit-text-fill-color: var(--t1) !important;
  caret-color: var(--t1);
}

/* ── Log line colors for light mode ─────────────────────── */
.log-line { color: var(--log-color) !important; }

/* ── Heatmap cells light mode ────────────────────────────── */
.hm-0 { background: var(--surface-2); }
.hm-1 { background: rgba(79,126,255,0.25); }
.hm-2 { background: rgba(79,126,255,0.50); }
.hm-3 { background: rgba(79,126,255,0.75); }
.hm-4 { background: var(--accent); }
[data-theme="dark"] .hm-0 { background: var(--surface-3); }
[data-theme="dark"] .hm-1 { background: rgba(10,132,255,0.25); }
[data-theme="dark"] .hm-2 { background: rgba(10,132,255,0.50); }
[data-theme="dark"] .hm-3 { background: rgba(10,132,255,0.75); }
[data-theme="dark"] .hm-4 { background: var(--accent); }

/* ── Security status card light mode ────────────────────── */
.status-card { border: 1px solid var(--border) !important; }

/* ── Logs bottom action bar ──────────────────────────────── */
.logs-bottom-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  justify-content: flex-end;
}
.logs-bottom-bar .input {
  width: 160px;
  flex-shrink: 1;
}

/* ── Custom commands section ─────────────────────────────── */
.cmd-desc {
  font-size: 12px; color: var(--t3);
  margin-bottom: 16px; line-height: 1.5;
}
/* Mobile-only add button — hidden on PC */
.cmd-add-mobile { display: none; }

/* ── Mobile: 3-column collapses ──────────────────────────── */
@media (max-width: 1023px) {
  .app-shell-dash {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    flex: none;
    overflow: visible;
    padding: 8px 8px 96px 8px;
  }
  .sidebar-left, .sidebar-right, .center-stage { overflow: visible; min-height: 0; }
  .cam-main-card { min-height: 220px; }
  .activity-card-scroll { max-height: 340px; }
  .status-card {
    padding: 22px 20px;
  }
  .status-card.alert {
    background: rgba(255,69,58,0.07);
    border-color: rgba(255,69,58,0.30);
    box-shadow: 0 12px 26px rgba(255,69,58,0.10), inset 0 0 0 1px rgba(255,69,58,0.05);
  }
  /* Tighter cards on mobile */
  .card { padding: 14px; border-radius: 16px; }
  .settings-card { padding: 14px; }
  .admin-page { padding: 16px; max-width: 100%; }
  .admin-page-header { margin-bottom: 16px; }
  /* Hide admin page headings — DI already shows the page name */
  .admin-page-header h2 { display: none; }
  .admin-page-header { min-height: 0; margin-bottom: 8px; }
  .dash-card-title { font-size: 12px; }
  /* Chat input is a flex child — no absolute positioning needed */
  /* Narada feed */
  .narada-feed { padding-bottom: 12px; }
  /* Page padding-top reduction on mobile for tighter feel */
  .page.active:not(#page-dashboard) { padding-top: 52px; }
  /* Dashboard clear for island */
  #page-dashboard.active { padding-top: 48px; }
  .app-shell-dash { padding-top: 0; }
}

/* ── Mode row highlight for light theme ──────────────────── */
.mode-row:hover { background: var(--room-bg); }
.mode-row.on { background: color-mix(in srgb, rgba(48,209,88,0.10) 100%, var(--surface)); }
[data-theme="dark"] .mode-row.on { background: rgba(48,209,88,0.06); }

/* ── Feedback Widget ─────────────────────────────────────── */
.fb-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 960;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

#app.fb-hidden .fb-wrap { display: none !important; }

/* Bubble trigger button */
.fb-bubble {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 18px rgba(79,126,255,0.38), 0 1px 4px rgba(0,0,0,0.12);
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.18s ease,
              background 0.15s ease;
  flex-shrink: 0;
  pointer-events: auto;
}
.fb-bubble:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 8px 28px rgba(79,126,255,0.50), 0 2px 8px rgba(0,0,0,0.14);
  background: color-mix(in srgb, var(--accent) 85%, #fff);
}
.fb-bubble:active { transform: scale(0.95); }
.fb-bubble svg { pointer-events: none; }

/* Icon morph — X when open */
.fb-bubble .fb-icon-open  { transition: opacity 0.15s, transform 0.15s; }
.fb-bubble .fb-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); transition: opacity 0.15s, transform 0.15s; }
.fb-bubble.is-open .fb-icon-open  { opacity: 0; transform: rotate(90deg) scale(0.6); }
.fb-bubble.is-open .fb-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Panel */
.fb-panel {
  width: 344px;
  background: var(--glass-h);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow), 0 0 0 0.5px var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform-origin: bottom right;
  transform: scale(0.88) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.18s ease;
  pointer-events: none;
}
.fb-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.fb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fb-panel-head h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
}
.fb-panel-head span {
  font-size: 11px;
  color: var(--t3);
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 20px;
}

/* Star rating */
.fb-stars {
  display: flex;
  gap: 4px;
}
.fb-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--t4);
  transition: color 0.12s, transform 0.12s cubic-bezier(0.34,1.56,0.64,1);
  font-size: 22px;
  line-height: 28px;
  text-align: center;
  user-select: none;
}
.fb-star:hover { color: var(--warn); transform: scale(1.2); }
.fb-star.lit    { color: var(--warn); transform: scale(1.1); }
.fb-star.hover-preview { color: var(--warn); transform: scale(1.2); }

/* Category pills */
.fb-cats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.fb-cat {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--t2);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}
.fb-cat:hover { background: var(--accent-d); color: var(--accent); border-color: var(--accent); }
.fb-cat.sel   { background: var(--accent-d); color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Inputs */
.fb-input, .fb-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--t1);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fb-input { padding: 8px 11px; }
.fb-textarea {
  padding: 10px 12px;
  resize: none;
  line-height: 1.5;
  height: 96px;
}
.fb-input:focus, .fb-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-d);
}
.fb-input::placeholder, .fb-textarea::placeholder { color: var(--t3); }

.fb-textarea-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fb-textarea-wrap .fb-textarea {
  padding-bottom: 12px;
}
.fb-char-count {
  position: static;
  align-self: flex-end;
  font-size: 10px;
  color: var(--t3);
  pointer-events: none;
  line-height: 1;
}
.fb-char-count.near { color: var(--warn); }
.fb-char-count.over { color: var(--danger); }

/* Submit row */
.fb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fb-footer small {
  font-size: 11px;
  color: var(--t3);
}
.fb-submit {
  padding: 7px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.fb-submit:hover  { opacity: 0.88; transform: translateY(-1px); }
.fb-submit:active { transform: scale(0.97); }
.fb-submit:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Success state */
.fb-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 0 8px;
  text-align: center;
}
.fb-success.show { display: flex; }
.fb-success-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(48,209,88,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.fb-success h4 { font-size: 14px; font-weight: 600; color: var(--t1); margin: 0; }
.fb-success p  { font-size: 12px; color: var(--t2); margin: 0; }

/* Tab bar */
.fb-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 3px;
}
.fb-tabs:empty {
  display: none;
}
.fb-tab {
  flex: 1;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: calc(var(--r) - 2px);
  cursor: pointer;
  background: transparent;
  color: var(--t2);
  transition: background 0.15s, color 0.15s;
}
.fb-tab.active {
  background: var(--surface);
  color: var(--t1);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.fb-tab:not(.active):hover { background: var(--surface-3); color: var(--t1); }

/* Inbox toolbar */
.fb-inbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.fb-inbox-summary {
  font-size: 11.5px;
  color: var(--t2);
}
.fb-inbox-refresh {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--t2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.3s;
}
.fb-inbox-refresh:hover { background: var(--surface-3); color: var(--t1); }
.fb-inbox-refresh.spinning { transform: rotate(360deg); }

/* Inbox scrollable list */
.fb-inbox-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.fb-inbox-list::-webkit-scrollbar { width: 4px; }
.fb-inbox-list::-webkit-scrollbar-track { background: transparent; }
.fb-inbox-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.fb-inbox-empty {
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  padding: 24px 0;
}

/* Individual feedback card */
.fb-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.fb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.fb-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--t1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fb-card-stars {
  font-size: 11px;
  color: var(--warn);
  letter-spacing: -1px;
  flex-shrink: 0;
}
.fb-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.fb-card-cat {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--accent-d);
  color: var(--accent);
}
.fb-card-cat.bug     { background: var(--danger-d); color: var(--danger); }
.fb-card-cat.feature { background: var(--accent-purple); color: var(--purple); }
.fb-card-cat.general { background: var(--accent-d);   color: var(--accent); }
.fb-card-cat.other   { background: var(--warn-d);     color: var(--warn); }
.fb-card-time {
  font-size: 10.5px;
  color: var(--t3);
}
.fb-card-msg {
  font-size: 12px;
  color: var(--t2);
  line-height: 1.5;
  word-break: break-word;
}

/* Mobile — panel sits above the bottom nav (68px tall) */
@media (max-width: 768px) {
  .fb-wrap { bottom: calc(92px + env(safe-area-inset-bottom)); right: 16px; }
  /* On chat page: raise feedback above input (92px + 46px + 8px gap = 146px) */
  body:has(#page-chat.active) .fb-wrap { bottom: calc(146px + env(safe-area-inset-bottom)); }
  /* Chat input restored to absolute positioning */
  #page-chat .chat-input-wrap { bottom: 92px; left: 12px; right: 12px; z-index: 950; }
  /* messages padding = input bottom (92px) + input height (~46px) + 12px gap */
  #page-chat .chat-messages { padding-bottom: 156px; }
  /* Always hide feedback bubble on mobile for login screen */
  #app:not(.logged-in) .fb-wrap,
  #app.fb-hidden .fb-wrap { display: none !important; }
  .fb-panel { width: min(344px, calc(100vw - 32px)); max-height: min(68vh, 520px); overflow-y: auto; }
  .fb-textarea { height: 80px; }
  .fb-bubble { width: 46px; height: 46px; }
  /* Prevent iOS zoom on all inputs */
  input, textarea, select { font-size: 16px !important; }
}
/* Very small screens — go full width */
@media (max-width: 400px) {
  .fb-wrap { bottom: calc(88px + env(safe-area-inset-bottom)); right: 12px; left: auto; }
  .fb-bubble { align-self: flex-end; }
  .fb-panel { width: min(320px, calc(100vw - 24px)); }
  .fb-stars { gap: 6px; }
  .fb-star  { width: 32px; height: 32px; font-size: 26px; }
}

/* ── Scheduled modes UI ─────────────────────────────────── */
.sched-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.sched-row  { display: flex; align-items: center; gap: 8px; }
.sched-label {
  width: 52px; font-size: 12px; font-weight: 600;
  color: var(--t2); flex-shrink: 0;
}
.sched-sep  { font-size: 11px; color: var(--t4); flex-shrink: 0; }
.input-sm   { flex: 1; min-width: 0; padding: 5px 8px; font-size: 12px; }
