:root {
  --bg: #1e0f36;
  --bg-alt: #150a29;
  --accent: #7c3aed;
  --accent-bright: #a78bfa;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --text: #f2eefc;
  --text-dim: #b9aed6;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #2a1550, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  border-radius: 18px;
}

.screen { display: none; flex: 1; padding: 20px 16px 90px; }
.screen.active { display: block; }

h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; color: var(--accent-bright); }
p { color: var(--text-dim); line-height: 1.5; }

/* Big, low-precision-required tap targets — important for hand tremor */
button, .btn {
  font-size: 17px;
  padding: 16px 20px;
  min-height: 52px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
  margin: 6px 0;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
button:active, .btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--glass); color: var(--text); border: 1px solid var(--glass-border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--accent); color: var(--accent-bright); }

input, select, textarea {
  width: 100%;
  font-size: 16px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  margin: 6px 0;
}
label { font-size: 14px; color: var(--text-dim); display: block; margin-top: 10px; }

.card { padding: 18px; margin-bottom: 14px; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; position: sticky; top: 0; z-index: 5;
  background: rgba(21, 10, 41, 0.85); backdrop-filter: blur(10px);
}

.nav-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  background: rgba(21, 10, 41, 0.95); border-top: 1px solid var(--glass-border);
  z-index: 10;
}
.nav-item {
  background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; width: auto; min-height: unset; padding: 6px 10px; margin: 0;
}
.nav-item.active { color: var(--accent-bright); }
.nav-item .icon { font-size: 20px; }

/* SOS */
.sos-button {
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f87171, var(--danger));
  box-shadow: 0 0 0 8px rgba(239,68,68,0.15), 0 10px 40px rgba(239,68,68,0.4);
  color: #fff; font-size: 30px; font-weight: 800;
  margin: 30px auto; display: flex; align-items: center; justify-content: center;
  min-height: unset;
}
.sos-button:active { transform: scale(0.95); }
.quick-dial-row { display: flex; gap: 10px; }
.quick-dial-row a.btn { text-decoration: none; text-align: center; display: block; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.taken { background: rgba(34,197,94,0.2); color: var(--success); }
.pill.pending { background: rgba(245,158,11,0.2); color: var(--warn); }
.pill.missed { background: rgba(239,68,68,0.2); color: var(--danger); }

.dose-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--glass-border); }
.dose-row:last-child { border-bottom: none; }
.dose-actions { display: flex; gap: 8px; }
.dose-actions button { width: auto; padding: 10px 14px; margin: 0; font-size: 14px; }

.slider-row { margin: 14px 0; }
.slider-row output { color: var(--accent-bright); font-weight: 700; }

.error-msg { color: var(--danger); font-size: 14px; min-height: 18px; }
.hint { font-size: 13px; color: var(--text-dim); }

canvas#tremorChart, canvas#symptomChart { max-width: 100%; }

/* Owner bypass dot — matches fleet-standard pattern */
#ownerDot {
  position: fixed; bottom: 6px; left: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: rgba(124,58,237,0.35); z-index: 50;
}

/* Blink-to-control scanning highlight */
.scan-highlight {
  outline: 4px solid var(--accent-bright) !important;
  box-shadow: 0 0 24px var(--accent-bright) !important;
}
#blinkVideo { width: 100%; border-radius: 12px; opacity: 0.85; }
#blinkStatus { text-align: center; font-weight: 600; }

.alert-item { padding: 12px; border-left: 3px solid var(--danger); margin-bottom: 8px; }
.alert-item.resolved { border-left-color: var(--success); opacity: 0.7; }

.premium-pill { background: rgba(124,58,237,0.25); color: var(--accent-bright); vertical-align: middle; margin-left: 6px; }
.legal-footer { text-align: center; font-size: 12px; margin-top: 24px; line-height: 1.8; }
.legal-footer a { color: var(--text-dim); }

.chat-bubble { padding: 10px 14px; border-radius: 14px; margin: 6px 0; max-width: 85%; line-height: 1.4; }
.chat-bubble.user { background: var(--accent); color: #fff; margin-left: auto; }
.chat-bubble.assistant { background: rgba(255,255,255,0.08); color: var(--text); margin-right: auto; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box { width: 100%; max-width: 400px; border: 2px solid var(--danger); }
