/* ============================================================
   RV OPS PLATFORM — modern design system v2
   Glass morphism + gradient accents + motion + depth
   Dark, high-contrast, mobile-first, two modes (driving/ops)
   ============================================================ */

:root {
  /* Layered dark surfaces — each tier sits on top of the previous */
  --bg: #07091a;
  --bg-elev: radial-gradient(1200px 800px at 30% -20%, #1a2447 0%, #07091a 60%);
  --surface: rgba(22, 28, 58, 0.62);
  --surface-2: rgba(36, 46, 88, 0.72);
  --surface-solid: #161c3a;
  --border: rgba(120, 140, 200, 0.18);
  --border-strong: rgba(140, 165, 230, 0.32);

  /* Foreground */
  --text: #ecf0fc;
  --text-dim: #c0c8df;
  --muted: #7e8aac;

  /* Brand + severity palette */
  --accent: #3ee08f;
  --accent-2: #19b67a;
  --info: #6ea8ff;
  --info-2: #3076ff;
  --warn: #f6c453;
  --warn-2: #f08a3f;
  --danger: #ef4f6b;
  --danger-2: #c0254e;
  --purple: #b48cff;

  /* Gradients */
  --grad-accent: linear-gradient(135deg, #3ee08f 0%, #19b67a 100%);
  --grad-info: linear-gradient(135deg, #6ea8ff 0%, #3076ff 100%);
  --grad-warn: linear-gradient(135deg, #f6c453 0%, #f08a3f 100%);
  --grad-danger: linear-gradient(135deg, #ff5e7a 0%, #c0254e 100%);
  --grad-glass: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.0) 100%);
  --grad-card: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);

  /* Depth */
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.05) inset, 0 4px 12px rgba(0,0,0,0.35);
  --shadow-md: 0 1px 0 rgba(255,255,255,0.06) inset, 0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 1px 0 rgba(255,255,255,0.07) inset, 0 14px 48px rgba(0,0,0,0.6);
  --glow-accent: 0 0 24px rgba(62, 224, 143, 0.35);
  --glow-warn:   0 0 24px rgba(246, 196, 83, 0.40);
  --glow-danger: 0 0 28px rgba(239, 79, 107, 0.50);

  /* Geometry */
  --radius-xs: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --gap: 12px;
  --tap: 44px;

  /* Motion */
  --ease-out: cubic-bezier(.22,.61,.36,1);
  --ease-in-out: cubic-bezier(.65,.05,.36,1);
  --t-fast: 140ms;
  --t-med: 280ms;
  --t-slow: 480ms;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--bg-elev);
  background-attachment: fixed;
  /* Subtle starfield texture overlay */
  position: relative;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(2px 2px at 20% 15%, rgba(255,255,255,0.06), transparent 50%),
    radial-gradient(1px 1px at 70% 70%, rgba(255,255,255,0.04), transparent 50%),
    radial-gradient(1.5px 1.5px at 50% 40%, rgba(255,255,255,0.05), transparent 50%),
    radial-gradient(1px 1px at 90% 25%, rgba(255,255,255,0.04), transparent 50%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--info); text-decoration: none; transition: color var(--t-fast) var(--ease-out); }
a:hover { color: var(--accent); }

/* ============================================================
   Buttons — glassy, gradient on active, motion on hover
   ============================================================ */
button {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: var(--tap);
  cursor: pointer;
  touch-action: manipulation;
  letter-spacing: 0.2px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}
button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
button:active { transform: translateY(0); }
button.active {
  background: var(--grad-info);
  color: #001b3a;
  border-color: transparent;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(110,168,255,0.4);
}
button.primary {
  background: var(--grad-accent);
  color: #00321b;
  border-color: transparent;
  font-weight: 600;
}
button.danger {
  background: var(--grad-danger);
  color: #fff;
  border-color: transparent;
}
button.ghost { background: transparent; }

/* ============================================================
   Header / Topbar — glass with bottom hairline
   ============================================================ */
#topbar {
  display: flex; align-items: center; gap: var(--gap);
  padding: 10px 14px;
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand {
  font-weight: 800;
  letter-spacing: 1.6px;
  font-size: 13px;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  height: 38px;
}
#modeswitch {
  display: flex; gap: 2px;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  align-items: center;
}
#modeswitch .mode-btn {
  padding: 6px 14px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: transparent;
  border: none;
  color: var(--muted);
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
#modeswitch .mode-btn:hover {
  opacity: 1;
  color: var(--text);
}
#modeswitch .mode-btn.active {
  background: var(--grad-accent);
  color: #00321b;
  opacity: 1;
  box-shadow: var(--shadow-sm);
}
#statusline {
  display: flex; align-items: center; gap: 10px;
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#conn-indicator {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
#conn-indicator.conn-ok {
  background: var(--accent);
  box-shadow: var(--glow-accent);
  animation: ping 2.4s ease-out infinite;
}
#conn-indicator.conn-wait { background: var(--warn); box-shadow: var(--glow-warn); }
#conn-indicator.conn-bad  { background: var(--danger); box-shadow: var(--glow-danger); animation: pulse 1s infinite; }

/* User identity pill — shows which family member is logged in via Tailscale */
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  margin-left: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  cursor: default;
  transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}
.user-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}
.user-pill.user-guest {
  opacity: 0.55;
  color: var(--muted);
}
.user-pill.user-owner {
  background: linear-gradient(135deg, rgba(62,224,143,0.16), rgba(62,224,143,0.04));
  border-color: rgba(62,224,143,0.35);
  color: var(--accent);
}

@keyframes ping {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62,224,143,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(62,224,143,0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ============================================================
   Page nav — pill-tabs with active gradient
   ============================================================ */
#pagenav {
  display: flex; gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.4);
  backdrop-filter: blur(10px);
}
#pagenav::-webkit-scrollbar { display: none; }
#pagenav a {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 36px;
  display: flex; align-items: center; gap: 6px;
  color: var(--muted);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease-out);
}
#pagenav a:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}
#pagenav a.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Main content — animated page transitions
   ============================================================ */
#content {
  padding: 16px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: pageEnter var(--t-med) var(--ease-out);
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.loading, .error {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}
.error { color: var(--danger); }

/* ============================================================
   Cards — glass morphism with gradient border
   ============================================================ */
.card {
  position: relative;
  background:
    var(--grad-card),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transition: transform var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              border-color var(--t-med) var(--ease-out);
  animation: cardEnter var(--t-med) var(--ease-out) backwards;
}
.card:hover { box-shadow: var(--shadow-md); }
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.card > h2,
.card > h3 {
  margin: 0 0 12px 0;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  display: flex; align-items: center; gap: 8px;
}
.card.alert-warn  { border-color: rgba(246,196,83,0.45); box-shadow: var(--shadow-md), var(--glow-warn); }
.card.alert-danger { border-color: rgba(239,79,107,0.55); box-shadow: var(--shadow-md), var(--glow-danger); }
.card.alert-ok    { border-color: rgba(62,224,143,0.45); box-shadow: var(--shadow-md), var(--glow-accent); }

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* ============================================================
   Bignum + value layout
   ============================================================ */
.bignum {
  font-size: clamp(28px, 7vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  background: linear-gradient(180deg, var(--text) 0%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bignum .unit {
  font-size: clamp(12px, 1.9vw, 16px);
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
  -webkit-text-fill-color: var(--muted);
}

.sev-warn   { color: var(--warn) !important;   -webkit-text-fill-color: var(--warn) !important; }
.sev-danger { color: var(--danger) !important; -webkit-text-fill-color: var(--danger) !important;
              animation: pulse-color 1.2s ease-in-out infinite; }
.sev-ok     { color: var(--accent) !important; -webkit-text-fill-color: var(--accent) !important; }
@keyframes pulse-color {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.3); }
}

.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }

.label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; }
.value { color: var(--text); font-weight: 600; }

/* ============================================================
   Mode visibility helpers
   ============================================================ */
.driving-only { display: none; }
body.mode-driving .driving-only { display: block; }
body.mode-driving .ops-only { display: none; }

/* ============================================================
   HUD tiles — glass with gradient hover, ring on alert
   ============================================================ */
.hud {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.hud .tile {
  position: relative;
  background:
    var(--grad-card),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t-med) var(--ease-out),
              border-color var(--t-med) var(--ease-out);
}
.hud .tile::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--grad-info);
  opacity: 0;
  transition: opacity var(--t-med);
  z-index: 0;
}
.hud .tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.hud .tile > * { position: relative; z-index: 1; }
.hud .tile .label { font-size: clamp(10px, 1.6vw, 12px); }
.hud .tile .bignum { font-size: clamp(34px, 11vw, 64px); margin-top: 4px; }
.hud .tile .unit { font-size: clamp(13px, 2.2vw, 18px); margin-left: 2px; }

/* ============================================================
   Tables — dense data
   ============================================================ */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: rgba(255,255,255,0.02);
}
table.data tbody tr.clickable { cursor: pointer; transition: background var(--t-fast); }
table.data tbody tr.clickable:hover { background: var(--surface-2); }

/* ============================================================
   Pills — gradient when severity-colored
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  letter-spacing: 0.4px;
}
.pill.ok    { background: rgba(62,224,143,0.15);  color: var(--accent); border-color: rgba(62,224,143,0.35); box-shadow: 0 0 0 1px rgba(62,224,143,0.08); }
.pill.warn  { background: rgba(246,196,83,0.15);  color: var(--warn);   border-color: rgba(246,196,83,0.35); }
.pill.bad   { background: rgba(239,79,107,0.15);  color: var(--danger); border-color: rgba(239,79,107,0.4);  animation: pulse-color 1.5s infinite; }
.pill.info  { background: rgba(110,168,255,0.15); color: var(--info);   border-color: rgba(110,168,255,0.35); }

/* ============================================================
   Bottom bar — quick stats with grad accents
   ============================================================ */
#bottombar {
  background: rgba(11, 16, 32, 0.85);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
#quick-stats {
  display: flex; gap: 14px; justify-content: space-around;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  font-weight: 500;
}
#quick-stats b {
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  margin-right: 3px;
}

/* ============================================================
   Driving Mode — glance-readable, larger targets, fewer pages
   ============================================================ */
body.mode-driving { --tap: 56px; }
body.mode-driving #pagenav a { font-size: clamp(15px, 3vw, 19px); padding: 12px 18px; }
body.mode-driving .bignum    { font-size: clamp(38px, 11vw, 80px); }
body.mode-driving .bignum .unit { font-size: clamp(16px, 2.6vw, 22px); }
body.mode-driving .card      { padding: 18px; }
body.mode-driving .card h2,
body.mode-driving .card h3   { font-size: clamp(12px, 2.2vw, 15px); }
body.mode-driving #quick-stats { font-size: clamp(14px, 2.6vw, 18px); }
body.mode-driving #quick-stats b { font-size: clamp(18px, 3.4vw, 26px); }
body.mode-driving .label { font-size: clamp(12px, 1.9vw, 14px); }
body.mode-driving .value { font-size: clamp(16px, 2.7vw, 21px); }
body.mode-driving p,
body.mode-driving li,
body.mode-driving td { font-size: clamp(15px, 2.5vw, 18px); }

/* ============================================================
   Big driving actions (the GAS/BREAK/STOP/MAP buttons)
   ============================================================ */
.driving-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.big-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 18px 8px;
  min-height: 84px;
  font-weight: 700;
  letter-spacing: 0.8px;
  font-size: clamp(13px, 2.2vw, 17px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background:
    var(--grad-card),
    var(--surface-2);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.big-action .ic {
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1;
}
.big-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.big-action:active { transform: translateY(0); }
.action-gas  { background: linear-gradient(140deg, rgba(246,196,83,0.18), rgba(240,138,63,0.05)); border-color: rgba(246,196,83,0.35); }
.action-dog  { background: linear-gradient(140deg, rgba(110,168,255,0.18), rgba(48,118,255,0.05)); border-color: rgba(110,168,255,0.35); }
.action-stop { background: linear-gradient(140deg, rgba(180,140,255,0.18), rgba(160,100,240,0.05)); border-color: rgba(180,140,255,0.35); }
.action-map  { background: linear-gradient(140deg, rgba(62,224,143,0.18), rgba(25,182,122,0.05)); border-color: rgba(62,224,143,0.35); }

/* ============================================================
   Inputs
   ============================================================ */
input[type="text"], input[type="number"], input[type="date"], textarea, select {
  background: rgba(11, 16, 32, 0.65);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(110,168,255,0.18);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ============================================================
   Modal dialogs (native <dialog>) with glass + transition
   ============================================================ */
dialog.app-modal {
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 92vw;
  width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalEnter var(--t-med) var(--ease-out);
}
dialog.app-modal::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  animation: backdropFade var(--t-med) var(--ease-out);
}
@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }
dialog.app-modal .modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
  display: flex; align-items: center; gap: 10px;
}
dialog.app-modal .modal-head h2 {
  margin: 0; font-size: clamp(16px, 2.8vw, 19px); font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--text);
  flex: 1;
}
dialog.app-modal .modal-body {
  padding: 18px;
  overflow-y: auto;
  max-height: calc(90vh - 120px);
}
dialog.app-modal .modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: rgba(11, 16, 32, 0.5);
}
dialog.app-modal label { display: block; margin-bottom: 12px; }
dialog.app-modal label .label { display: block; margin-bottom: 4px; }

/* ============================================================
   Inline SVG icons — sized by font, color = currentColor
   ============================================================ */
.icon {
  width: 1em; height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.lg { width: 1.6em; height: 1.6em; }
.icon.xl { width: 2.2em; height: 2.2em; }

/* ============================================================
   Misc helpers
   ============================================================ */
.fade-in   { animation: pageEnter var(--t-med) var(--ease-out); }
.count-up  { font-variant-numeric: tabular-nums; transition: color var(--t-med); }

.dim       { color: var(--muted); }
.strong    { color: var(--text); font-weight: 600; }

/* For elements that should not show in driving mode */
@media (max-width: 480px) {
  .card { padding: 14px; border-radius: var(--radius); }
  .hud .tile { padding: 12px; }
}

/* Thread Folding and Show More Toggle */
.thread-collapsed {
  max-height: 240px !important;
  overflow: hidden !important;
  position: relative;
}
.thread-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: linear-gradient(to top, var(--bg, #0b1020) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}
.thread-show-more-container {
  display: flex;
  justify-content: center;
  margin-top: -15px;
  margin-bottom: 15px;
  position: relative;
  z-index: 15;
}
.thread-show-more-btn {
  background: rgba(125, 164, 255, 0.15);
  border: 1px solid rgba(125, 164, 255, 0.35);
  color: #7da4ff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease-out;
}
.thread-show-more-btn:hover {
  background: rgba(125, 164, 255, 0.25);
  border-color: #7da4ff;
  box-shadow: 0 0 10px rgba(125, 164, 255, 0.3);
}

/* ============================================================
   Premium Visual Enhancements v3
   — Animated borders, shines, scrollbars, utility classes
   ============================================================ */

/* ---- Animated gradient border for featured cards ---- */
.card-featured {
  position: relative;
  border: none !important;
  background-clip: padding-box;
}
.card-featured::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--gradient-angle, 0deg),
    var(--accent), var(--info), var(--purple), var(--accent)
  );
  z-index: -1;
  opacity: 0.6;
  animation: rotateGradient 6s linear infinite;
}
@keyframes rotateGradient {
  to { --gradient-angle: 360deg; }
}
@property --gradient-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* ---- Glassmorphic shine overlay ---- */
.glass-shine {
  position: relative;
  overflow: hidden;
}
.glass-shine::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.04),
    transparent
  );
  transform: skewX(-20deg);
  animation: shineSlide 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}
@keyframes shineSlide {
  0%, 100% { left: -100%; }
  50% { left: 150%; }
}

/* ---- Custom scrollbar styling ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 140, 200, 0.25);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 140, 200, 0.4);
}
#content::-webkit-scrollbar-thumb {
  background: rgba(62, 224, 143, 0.2);
}
#content::-webkit-scrollbar-thumb:hover {
  background: rgba(62, 224, 143, 0.35);
}

/* ---- Staggered card entrance animation ---- */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }
.card:nth-child(5) { animation-delay: 240ms; }
.card:nth-child(6) { animation-delay: 300ms; }

/* ---- Shimmer animation for data values ---- */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.shimmer-text {
  background: linear-gradient(
    90deg,
    var(--text) 0%, var(--text) 40%,
    var(--accent) 50%,
    var(--text) 60%, var(--text) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s ease-in-out infinite;
}

/* ---- Glow pulse for status indicators ---- */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(62, 224, 143, 0.3); }
  50% { box-shadow: 0 0 20px rgba(62, 224, 143, 0.6); }
}
.glow-accent { animation: glowPulse 2.5s ease-in-out infinite; }

@keyframes glowPulseInfo {
  0%, 100% { box-shadow: 0 0 8px rgba(110, 168, 255, 0.3); }
  50% { box-shadow: 0 0 20px rgba(110, 168, 255, 0.6); }
}
.glow-info { animation: glowPulseInfo 2.5s ease-in-out infinite; }

/* ---- Gradient divider line ---- */
.gradient-divider {
  height: 1px;
  border: none;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  margin: var(--gap) 0;
}

/* ---- Gradient section header accent ---- */
.section-accent-header {
  position: relative;
  padding-left: 14px;
}
.section-accent-header::before {
  content: "";
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--grad-accent);
}

/* ---- Premium page title bar ---- */
.page-title-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 var(--gap) 0;
  margin-bottom: var(--gap);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.page-title-bar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 2px;
  background: var(--grad-accent);
  border-radius: 1px;
}
.page-title-bar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Frosted chip / tag ---- */
.frosted-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all var(--t-fast) var(--ease-out);
}
.frosted-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* ---- Float-in animation ---- */
@keyframes floatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.float-in { animation: floatIn var(--t-med) var(--ease-out) backwards; }

/* ---- Enhanced select dropdowns ---- */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237e8aac' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* ---- Premium range slider ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  transition: background var(--t-fast);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--grad-accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px rgba(62, 224, 143, 0.4);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 14px rgba(62, 224, 143, 0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--grad-accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px rgba(62, 224, 143, 0.4);
}

/* ============================================================
   WEB OS SHELL REDESIGN — Glassmorphism, Saturation, Depth, Motions
   ============================================================ */

/* Redefined custom scrollbar — bright neon-blue cyberpunk so it's easy to find.
   Wide, glowing thumb on a faintly-lit track. */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
::-webkit-scrollbar-track {
  background: rgba(11, 16, 32, 0.55);
  box-shadow: inset 0 0 6px rgba(62, 224, 255, 0.18);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3ee0ff, #4aa8ff);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(62, 224, 255, 0.7), 0 0 16px rgba(62, 224, 255, 0.35);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6cf0ff, #5cb8ff);
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow: 0 0 12px rgba(62, 224, 255, 0.95), 0 0 24px rgba(62, 224, 255, 0.5);
}
/* Firefox */
* {
  scrollbar-color: #3ee0ff rgba(11, 16, 32, 0.55);
}

/* Enhanced Page Entry Transition (Fluid blur-in slide scale) */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: scale(0.975) translateY(16px);
    filter: blur(12px) saturate(80%);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0) saturate(100%);
  }
}

/* Topbar glassmorphism update - Floating OS header */
#topbar {
  background: rgba(11, 16, 32, 0.72) !important;
  backdrop-filter: blur(28px) saturate(175%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(175%) !important;
  border-bottom: 1px solid rgba(120, 140, 200, 0.16) !important;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Redesigned Primary Navigation (Floating Capsule Tabs) */
#pagenav {
  background: rgba(7, 9, 26, 0.5) !important;
  backdrop-filter: blur(20px) saturate(140%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(140%) !important;
  border-bottom: 1px solid rgba(120, 140, 200, 0.1) !important;
  padding: 8px 16px !important;
}
#pagenav a {
  border-radius: 12px !important;
  border: 1px solid transparent !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
  letter-spacing: 0.2px;
  transition: all var(--t-med) cubic-bezier(0.16, 1, 0.3, 1) !important;
}
#pagenav a:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text) !important;
  transform: translateY(-1px);
}
#pagenav a.active {
  background: linear-gradient(135deg, rgba(110, 168, 255, 0.16) 0%, rgba(48, 118, 255, 0.08) 100%) !important;
  color: var(--info) !important;
  border-color: rgba(110, 168, 255, 0.28) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
  text-shadow: 0 0 10px rgba(110, 168, 255, 0.25);
}

/* Secondary Contextual Nav - Frosted OS Ribbon */
#subnav {
  background: rgba(15, 20, 38, 0.72) !important;
  backdrop-filter: blur(30px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(30px) saturate(160%) !important;
  border-bottom: 1px solid rgba(120, 140, 200, 0.12) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03) !important;
}
#subnav a {
  border-radius: 10px !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
  background: rgba(255, 255, 255, 0.02) !important;
  font-weight: 500 !important;
  transition: all var(--t-med) cubic-bezier(0.16, 1, 0.3, 1) !important;
}
#subnav a:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(110, 168, 255, 0.25) !important;
  transform: scale(1.02) translateY(-0.5px);
}
#subnav a.active {
  background: linear-gradient(135deg, var(--info) 0%, var(--info-2) 100%) !important;
  color: #070914 !important;
  border-color: transparent !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 14px rgba(110, 168, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
}

/* Glassmorphic Panel Overrides */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%), rgba(22, 28, 58, 0.48) !important;
  border: 1px solid rgba(120, 140, 200, 0.16) !important;
  backdrop-filter: blur(20px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(150%) !important;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
  border-radius: 18px !important;
}
.card:hover {
  border-color: rgba(120, 140, 200, 0.28) !important;
  box-shadow: var(--shadow-md), 0 0 20px rgba(110, 168, 255, 0.08) !important;
  transform: translateY(-2px);
}

/* Buttons - Advanced Liquid OS Glass */
button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(120, 140, 200, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
button:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(110, 168, 255, 0.3) !important;
  transform: translateY(-1.5px) scale(1.01);
}

/* WOS Dialog System Enhancements */
dialog.app-modal {
  background: rgba(22, 28, 58, 0.8) !important;
  backdrop-filter: blur(40px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(160%) !important;
  border: 1px solid rgba(125, 164, 255, 0.28) !important;
  border-radius: 24px !important;
}
dialog.app-modal .modal-head {
  background: rgba(255, 255, 255, 0.02) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
dialog.app-modal .modal-foot {
  background: rgba(11, 16, 32, 0.4) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* User Pill visual elevation */
.user-pill {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-weight: 700 !important;
}
.user-pill:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(110, 168, 255, 0.4) !important;
  box-shadow: 0 4px 12px rgba(110, 168, 255, 0.15);
}

/* Plan & Ledger Glow Pulse */
#plan-link {
  background: rgba(255, 186, 8, 0.08) !important;
  border: 1px solid rgba(255, 186, 8, 0.28) !important;
  transition: all var(--t-fast) var(--ease-out);
}
#plan-link:hover {
  background: rgba(255, 186, 8, 0.16) !important;
  border-color: rgba(255, 186, 8, 0.6) !important;
  box-shadow: 0 0 12px rgba(255, 186, 8, 0.2);
  transform: scale(1.02);
}

/* Bottombar OS Quick Stats footer */
#bottombar {
  background: rgba(11, 16, 32, 0.72) !important;
  backdrop-filter: blur(28px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(160%) !important;
  border-top: 1px solid rgba(120, 140, 200, 0.16) !important;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
}
#quick-stats b {
  color: var(--text) !important;
}

/* Autopilot AI Orb & Panel Redesign - Holographic Glass */
#ai-autopilot-orb {
  background: linear-gradient(135deg, rgba(62, 224, 143, 0.8), rgba(0, 245, 212, 0.8)) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  box-shadow: 0 0 24px rgba(62, 224, 143, 0.4), inset 0 0 12px rgba(255, 255, 255, 0.6) !important;
  transition: all var(--t-med) cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}
#ai-autopilot-orb:hover {
  transform: scale(1.1) rotate(15deg) !important;
  box-shadow: 0 0 32px rgba(62, 224, 143, 0.6), inset 0 0 16px rgba(255, 255, 255, 0.8) !important;
}
#ai-autopilot-panel {
  background: rgba(11, 16, 32, 0.75) !important;
  backdrop-filter: blur(35px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(35px) saturate(180%) !important;
  border: 1px solid rgba(110, 168, 255, 0.28) !important;
  border-radius: 24px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5) !important;
}
#ai-autopilot-panel textarea {
  border-color: rgba(110, 168, 255, 0.2) !important;
  background: rgba(7, 9, 20, 0.6) !important;
}
#ai-autopilot-panel textarea:focus {
  border-color: var(--info) !important;
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.25) !important;
}

/* Profile slide drawer */
#profile-drawer {
  background: linear-gradient(180deg, rgba(13, 19, 41, 0.85) 0%, rgba(11, 16, 32, 0.9) 100%) !important;
  backdrop-filter: blur(40px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(40px) saturate(160%) !important;
  border-left: 1px solid rgba(125, 164, 255, 0.2) !important;
}

/* ============================================================
   PREMIUM VISUALS V3 — Scroll-fades, micro-animations & glow
   ============================================================ */

/* ---- Edge-fading horizontal scroll bars ---- */
#pagenav {
  mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent) !important;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent) !important;
}

/* ---- Micro-animations: Icon tilt on nav hover ---- */
#pagenav a .icon, #subnav a .icon {
  transition: transform var(--t-med) var(--ease-out) !important;
}
#pagenav a:hover .icon, #subnav a:hover .icon {
  transform: rotate(10deg) scale(1.1);
}
#pagenav a.active .icon, #subnav a.active .icon {
  transform: scale(1.05);
}

/* ---- Premium User-Pill glowing state ---- */
.user-pill {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.02) !important;
  transition: all var(--t-med) var(--ease-out) !important;
}
.user-pill:not(.user-guest) {
  animation: userPillBreath 4s ease-in-out infinite alternate;
}
@keyframes userPillBreath {
  0% { box-shadow: 0 0 4px rgba(110, 168, 255, 0.1); }
  100% { box-shadow: 0 0 16px rgba(110, 168, 255, 0.25), 0 0 0 1px rgba(110,168,255,0.15) inset; }
}

/* ---- Glassmorphic Cards premium lift ---- */
.card {
  transition: border-color var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out) !important;
}
.card:hover {
  transform: translateY(-2px) scale(1.005) !important;
  border-color: rgba(110, 168, 255, 0.35) !important;
  box-shadow: var(--shadow-md), 0 10px 30px rgba(110, 168, 255, 0.08) !important;
}

/* ---- Interactive button hover transitions ---- */
button:not(.primary):not(.danger):hover {
  box-shadow: 0 0 12px rgba(110, 168, 255, 0.15) !important;
}
button.primary:hover {
  box-shadow: 0 0 20px rgba(62, 224, 143, 0.4) !important;
}
button.danger:hover {
  box-shadow: 0 0 20px rgba(239, 79, 107, 0.4) !important;
}

/* ---- Navigation notification badge ---- */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-danger, linear-gradient(135deg, #f44336, #e91e63));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 6px;
  box-shadow: 0 2px 5px rgba(244, 67, 54, 0.4);
  vertical-align: middle;
  transition: all 0.3s ease;
}
.nav-badge.hidden {
  display: none !important;
}

/* ============================================================
   Mobile Tap Targets & Padding Utilities
   Enforcing WCAG 44x44px mobile touch standards
   ============================================================ */

/* Enforce 44px minimum sizing directly */
.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Expand the touch/tap area of small icons/elements without visually scaling them */
.tap-container {
  position: relative;
}
.tap-container::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
  z-index: 5;
}





