/* ════════════════════════════════════════════════════════════════
   PROTOCOL — Design System
   Dark. Disciplined. No compromises.
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg-0: #060608;
  --bg-1: #0C0C10;
  --bg-2: #111116;
  --bg-3: #18181F;
  --bg-4: #1E1E28;

  /* Borders */
  --border-0: #16161E;
  --border-1: #22222C;
  --border-2: #2C2C3A;

  /* Text */
  --text-0: #F0F0F5;
  --text-1: #9090A0;
  --text-2: #50505E;
  --text-inv: #060608;

  /* Accent — Electric Lime */
  --accent: #BAFF29;
  --accent-dim: rgba(186, 255, 41, 0.10);
  --accent-glow: rgba(186, 255, 41, 0.20);
  --accent-dark: #8ACC00;

  /* Status */
  --green: #00C896;
  --green-dim: rgba(0, 200, 150, 0.12);
  --amber: #FFB020;
  --amber-dim: rgba(255, 176, 32, 0.12);
  --red: #FF3E3E;
  --red-dim: rgba(255, 62, 62, 0.12);
  --red-bright: #FF1A1A;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Nav */
  --nav-h: 64px;
  --header-h: 52px;

  /* Font */
  --font: 'Space Grotesk', system-ui, -apple-system, sans-serif;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-med: 220ms ease;
  --t-slow: 400ms ease;
}

/* ─── Reset ──────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text-0);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: var(--font); }
img, canvas { display: block; max-width: 100%; }

/* ─── App Shell ──────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ─── Header ─────────────────────────────────────────────────── */

#app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  background: rgba(6, 6, 8, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-0);
  z-index: 100;
}

.app-logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.06em;
  margin-left: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.day-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2);
  transition: background var(--t-fast);
}
.day-status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.day-status-dot.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.day-status-dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }

.btn-emergency {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-1);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.btn-emergency:active { transform: scale(0.92); background: var(--red-dim); border-color: var(--red); }

/* ─── Main content ───────────────────────────────────────────── */

#main-content {
  flex: 1;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page {
  padding: var(--space-md);
  animation: fadeIn 180ms ease;
}

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

/* ─── Bottom Nav ─────────────────────────────────────────────── */

#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  display: flex;
  align-items: stretch;
  background: rgba(12, 12, 16, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-0);
  z-index: 100;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-2);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 4px;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  position: relative;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--t-fast);
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-full);
}

.nav-item:active { transform: scale(0.88); }

/* ─── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: var(--r-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}

.card-accent {
  border-color: var(--accent);
  background: rgba(186, 255, 41, 0.04);
}

.card-danger {
  border-color: var(--red);
  background: var(--red-dim);
}

.card-success {
  border-color: var(--green);
  background: var(--green-dim);
}

.card-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--space-sm);
}

.card-title-accent { color: var(--accent); }

/* ─── Typography ─────────────────────────────────────────────── */

.display-xl {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.display-lg {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.display-md {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.h1 { font-size: 22px; font-weight: 700; line-height: 1.2; }
.h2 { font-size: 18px; font-weight: 600; line-height: 1.3; }
.h3 { font-size: 15px; font-weight: 600; line-height: 1.4; }

.body-lg { font-size: 15px; line-height: 1.6; }
.body { font-size: 14px; line-height: 1.6; }
.body-sm { font-size: 13px; line-height: 1.5; }
.caption { font-size: 11px; line-height: 1.4; }

.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-1); }
.text-dim    { color: var(--text-2); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.text-white  { color: var(--text-0); }

/* ─── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--r-md);
  padding: 12px var(--space-lg);
  transition: all var(--t-fast);
  white-space: nowrap;
  border: none;
  cursor: pointer;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: var(--text-inv);
}
.btn-primary:hover { background: #ccff44; }

.btn-ghost {
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border-1);
}
.btn-ghost:hover { border-color: var(--border-2); color: var(--text-0); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-full { width: 100%; }
.btn-sm { font-size: 12px; padding: 8px 14px; }
.btn-lg { font-size: 16px; padding: 16px 24px; }

/* ─── Forms ──────────────────────────────────────────────────── */

.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 16px; /* Prevents iOS zoom */
  font-weight: 500;
  padding: 12px var(--space-md);
  transition: border-color var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-4);
}

.form-input::placeholder { color: var(--text-2); }

.form-input-num {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  padding: 16px;
}

/* Range slider */
.form-range {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-4);
  border-radius: var(--r-full);
  outline: none;
  margin: 8px 0;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
}

/* Toggle */
.toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle-btn {
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 2px solid var(--border-1);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: all var(--t-fast);
  cursor: pointer;
}

.toggle-btn.selected-yes {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.toggle-btn.selected-no {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* Textarea */
textarea.form-input {
  resize: none;
  min-height: 80px;
  line-height: 1.5;
  font-size: 14px;
}

/* ─── Dashboard specific ─────────────────────────────────────── */

.dashboard-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: var(--r-xl);
}

.weight-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.weight-display .num {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-0);
}

.weight-display .unit {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-1);
}

.goal-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.goal-badge .label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

.goal-badge .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.metric-tile {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: var(--r-lg);
  padding: 12px var(--space-md);
}

.metric-tile .label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 4px;
}

.metric-tile .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-0);
  line-height: 1.1;
}

.metric-tile .value-sm {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}

.metric-tile .sub {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
}

.metric-tile.hit .value { color: var(--green); }
.metric-tile.warn .value { color: var(--amber); }
.metric-tile.miss .value { color: var(--red); }

.countdown-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-md);
  background: var(--bg-2);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}

.countdown-bar .days {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.countdown-bar .days-label {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.06em;
}

.progress-track {
  height: 3px;
  background: var(--bg-4);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--t-slow);
}

.progress-fill.red { background: var(--red); }
.progress-fill.amber { background: var(--amber); }

/* Coach message card */
.coach-message {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  padding: var(--space-md);
  margin-bottom: 8px;
  position: relative;
}

.coach-message::before {
  content: 'COACH';
  position: absolute;
  top: -8px;
  left: var(--space-md);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--bg-0);
  padding: 0 6px;
  color: var(--accent);
}

.coach-message .text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-0);
}

.coach-message.danger {
  border-color: var(--red);
}
.coach-message.danger::before { color: var(--red); }
.coach-message.success { border-color: var(--green); }
.coach-message.success::before { color: var(--green); }

/* ─── Check-in ────────────────────────────────────────────────── */

.checkin-header {
  text-align: center;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
}

.checkin-step {
  display: none;
}
.checkin-step.active {
  display: block;
  animation: fadeIn 160ms ease;
}

.step-indicator {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-2);
  transition: background var(--t-fast);
}
.step-dot.done { background: var(--accent); }
.step-dot.active { background: var(--accent); width: 18px; border-radius: var(--r-full); }

.big-input-wrap {
  text-align: center;
  padding: var(--space-xl) 0;
}

.big-input-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--space-md);
}

.big-number {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-0);
  line-height: 1;
  min-width: 200px;
  display: inline-block;
}

.big-number-unit {
  font-size: 20px;
  color: var(--text-1);
  font-weight: 500;
  margin-left: 4px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-0);
  font-size: 24px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.stepper-btn:active { transform: scale(0.88); background: var(--bg-4); }

.range-with-value {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.range-val {
  font-size: 24px;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
  color: var(--accent);
}

/* ─── Progress page ──────────────────────────────────────────── */

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-0);
}

.stat-row:last-child { border-bottom: none; }

.stat-row .label {
  font-size: 13px;
  color: var(--text-1);
}

.stat-row .value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
}

.pattern-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}

.pattern-alert .icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.pattern-alert .content {}
.pattern-alert .ptitle { font-size: 13px; font-weight: 600; color: var(--text-0); margin-bottom: 2px; }
.pattern-alert .pdesc { font-size: 12px; color: var(--text-1); line-height: 1.5; }

.pattern-alert.critical { border-left: 2px solid var(--red); }
.pattern-alert.high { border-left: 2px solid var(--amber); }
.pattern-alert.medium { border-left: 2px solid var(--accent); }
.pattern-alert.low { border-left: 2px solid var(--text-2); }

/* ─── Plan page ──────────────────────────────────────────────── */

.plan-section {
  margin-bottom: var(--space-md);
}

.plan-section-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-0);
}

.meal-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-0);
}
.meal-row:last-child { border-bottom: none; }
.meal-row .name { font-size: 12px; font-weight: 600; color: var(--text-0); margin-bottom: 4px; }
.meal-row .kcal { font-size: 10px; color: var(--accent); font-weight: 600; }
.meal-row .detail { font-size: 13px; color: var(--text-1); line-height: 1.5; margin-top: 4px; }

.schedule-row {
  display: flex;
  gap: var(--space-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-0);
  align-items: flex-start;
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row .time { font-size: 12px; font-weight: 700; color: var(--accent); min-width: 48px; padding-top: 1px; }
.schedule-row .task { font-size: 13px; color: var(--text-1); line-height: 1.4; }

.avoid-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-0);
}
.avoid-item:last-child { border-bottom: none; }
.avoid-item::before { content: '✕'; color: var(--red); font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.avoid-item span { font-size: 13px; color: var(--text-1); line-height: 1.4; }

.adjust-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-0);
}
.adjust-item:last-child { border-bottom: none; }
.adjust-item::before { content: '→'; color: var(--amber); font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.adjust-item span { font-size: 13px; color: var(--text-1); line-height: 1.4; }

.exercise-list {
  list-style: none;
  padding: 0;
}
.exercise-list li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-1);
  border-bottom: 1px solid var(--border-0);
  display: flex;
  align-items: center;
  gap: 8px;
}
.exercise-list li::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.exercise-list li:last-child { border-bottom: none; }

/* ─── Coach page ─────────────────────────────────────────────── */

.action-card {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: var(--space-md);
  background: var(--bg-2);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  border-left: 2px solid transparent;
}
.action-card.p0 { border-color: var(--red); }
.action-card.p1 { border-color: var(--accent); }
.action-card.p2 { border-color: var(--amber); }
.action-card.p3 { border-color: var(--text-2); }

.action-tag {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  white-space: nowrap;
  align-self: flex-start;
}

.action-text {
  font-size: 13px;
  color: var(--text-0);
  line-height: 1.5;
}

.coach-input-area {
  position: sticky;
  bottom: 0;
  background: var(--bg-0);
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--border-0);
}

.coach-chat-log {
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
}

.coach-note-bubble {
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.coach-note-bubble.user {
  background: var(--bg-3);
  color: var(--text-1);
  margin-left: 32px;
}

.coach-note-bubble.coach {
  background: rgba(186,255,41,0.06);
  color: var(--text-0);
  border: 1px solid var(--border-1);
  margin-right: 32px;
}

/* ─── Emergency mode ─────────────────────────────────────────── */

.emergency-banner {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--r-lg);
  padding: var(--space-lg);
  text-align: center;
  margin-bottom: var(--space-md);
}

.emergency-banner .emoji { font-size: 32px; margin-bottom: 8px; }
.emergency-banner .title { font-size: 16px; font-weight: 700; color: var(--red); letter-spacing: 0.06em; }
.emergency-banner .desc { font-size: 13px; color: var(--text-1); margin-top: 8px; line-height: 1.5; }

.emergency-priority {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-2);
  border-radius: var(--r-lg);
  margin-bottom: 8px;
  align-items: flex-start;
}

.emergency-priority .num {
  font-size: 28px;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  min-width: 32px;
}

.emergency-priority .content {}
.emergency-priority .label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 4px;
}
.emergency-priority .action { font-size: 13px; color: var(--text-0); line-height: 1.5; }

/* ─── History ─────────────────────────────────────────────────── */

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-0);
}
.history-item:last-child { border-bottom: none; }

.history-date {
  min-width: 48px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.history-weight {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-0);
  min-width: 56px;
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red   { background: var(--red-dim);   color: var(--red);   }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-dim   { background: var(--bg-3);      color: var(--text-2);}

/* ─── Settings ────────────────────────────────────────────────── */

.settings-section {
  margin-bottom: var(--space-xl);
}

.settings-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--space-md);
}

/* ─── Toast ───────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 440px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text-0);
  animation: toastIn 200ms ease, toastOut 200ms ease 2.8s forwards;
  pointer-events: auto;
}

.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red);   }
.toast.info    { border-color: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ─── Utility classes ─────────────────────────────────────────── */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ─── Empty state ────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-2);
}
.empty-state .icon { font-size: 36px; margin-bottom: var(--space-md); opacity: 0.5; }
.empty-state .msg { font-size: 14px; line-height: 1.6; }

/* ─── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 0; height: 0; }

/* ─── Loading ─────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--text-2);
  font-size: 13px;
}

/* ─── Section header ─────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ─── Desktop fallback ───────────────────────────────────────── */

@media (min-width: 480px) {
  #app {
    border-left: 1px solid var(--border-0);
    border-right: 1px solid var(--border-0);
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
  }

  #app-header {
    border-radius: 0;
  }
}
