  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  input, select, textarea, button { font-family: var(--font); color: var(--text); }
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not(.form-input),
  select:not(.form-select),
  textarea:not(.form-input) {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.875rem;
    outline: none;
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
  }
  select:not(.form-select) {
    cursor: pointer;
    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='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }
  input:not(.form-input):focus, select:not(.form-select):focus, textarea:not(.form-input):focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139,92,246,0.15);
  }
  input:not(.form-input)::placeholder, textarea:not(.form-input)::placeholder { color: var(--text-muted); opacity: 0.5; }
  input[type="time"], input[type="date"], input[type="datetime-local"] { color-scheme: dark; }

  :root {
    --bg: #0B0D12;
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --primary-dim: rgba(139, 92, 246, 0.12);
    --primary-glow: #A78BFA;
    --accent: #06B6D4;
    --accent-dim: rgba(6, 182, 212, 0.12);
    --hgh: #F97316;
    --hgh-dim: rgba(249, 115, 22, 0.12);
    --glp1: #84CC16;
    --glp1-dim: rgba(132, 204, 22, 0.12);
    --pth: #22C55E;
    --pth-dim: rgba(34, 197, 94, 0.10);
    --amber: #F59E0B;
    --amber-dim: rgba(245, 158, 11, 0.12);
    --danger: #EF4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --warning: #F59E0B;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --compound-color-0: hsl(160, 55%, 62%);
    --compound-color-1: hsl(205, 55%, 62%);
    --compound-color-2: hsl(250, 55%, 62%);
    --compound-color-3: hsl(295, 55%, 62%);
    --compound-color-4: hsl(340, 55%, 62%);
    --compound-color-5: hsl(25, 55%, 62%);
    --compound-color-6: hsl(70, 55%, 62%);
    --compound-color-7: hsl(115, 55%, 62%);
    --surface: #161922;
    --surface-hover: #1C202B;
    --border: #1E293B;
    --border-strong: rgba(255, 255, 255, 0.22);
    --text: #F8FAFC;
    --text-muted: #94A3B8;
    --success: #22C55E;
    --success-dim: rgba(34, 197, 94, 0.10);
    --primary-rgb: 139, 92, 246;
    --font: 'Inter', -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
    --modal-backdrop: rgba(4, 6, 10, 0.78);
    --modal-surface-top: rgba(26, 30, 42, 0.96);
    --modal-surface-bottom: rgba(17, 20, 30, 0.98);
    --modal-border-strong: rgba(255, 255, 255, 0.08);
    --modal-border-soft: rgba(255, 255, 255, 0.04);
    --modal-shadow-premium: 0 24px 80px rgba(0, 0, 0, 0.55), 0 8px 28px rgba(0, 0, 0, 0.32);
    --field-surface: rgba(255, 255, 255, 0.05);
    --field-surface-hover: rgba(255, 255, 255, 0.065);
    --field-border: rgba(255, 255, 255, 0.08);
    --field-border-strong: rgba(255, 255, 255, 0.12);
    --field-ring: rgba(139, 92, 246, 0.22);
    --control-tray-surface: rgba(255, 255, 255, 0.045);
    --control-tray-border: rgba(255, 255, 255, 0.05);
    --control-active-surface: rgba(255, 255, 255, 0.08);
    --control-active-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
    --subpanel-surface: rgba(255, 255, 255, 0.03);
    --subpanel-border: rgba(255, 255, 255, 0.06);
    --engine-picker-surface: rgba(255, 255, 255, 0.05);
    --engine-picker-border: rgba(255, 255, 255, 0.09);
    --engine-picker-hover: rgba(255, 255, 255, 0.08);
    /* Subscription & Ad tokens */
    --ad-surface: rgba(255, 255, 255, 0.018);
    --pro-tier-surface: rgba(139, 92, 246, 0.06);
    --upgrade-btn-border: rgba(245, 158, 11, 0.2);
    --sidebar-width: 72px;
  }

  html {
    font-size: 15px;
    height: -webkit-fill-available;
    overflow-x: hidden;
  }
  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    min-height: -webkit-fill-available; /* iOS ≤ 15.3 fallback */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-feature-settings: 'tnum' 1;
    -webkit-font-smoothing: antialiased;
  }

  .ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .ic svg { display: block; }

  /* ===== TOP BAR ===== */
  .topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px 0 calc(var(--sidebar-width) + 24px);
    flex-shrink: 0;
    z-index: 20;
  }
  .topbar-brand { display: flex; align-items: center; gap: 10px; }
  .topbar-brand img { height: 34px; width: auto; }
  .topbar-brand span { font-size: 1.15rem; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
  .topbar-brand .brand-beta {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.09em;
  }
  .topbar-brand .brand-version {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
  }
  .topbar-right { display: flex; align-items: center; gap: 16px; }
  .topbar-user { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 0.875rem; font-weight: 500; }
  .topbar-user .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary-dim); border: 2px solid var(--primary-glow);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: var(--primary-glow);
  }
  .topbar-icon {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: transparent; border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; color: var(--text-muted);
  }
  .topbar-icon:hover { background: var(--surface-hover); border-color: var(--primary); color: var(--text); }
  .btn-upgrade-topbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--upgrade-btn-border);
    background: var(--amber-dim);
    color: var(--amber);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease, transform 200ms ease;
  }
  .btn-upgrade-topbar:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.3);
  }
  .btn-upgrade-topbar:active {
    opacity: 0.85;
    transform: scale(0.97);
  }
  .btn-upgrade-topbar.hidden { display: none; }
  .btn-tool-topbar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }
  .btn-tool-topbar:hover {
    border-color: var(--field-border-strong);
    color: var(--text);
  }
  .btn-tool-topbar:active {
    opacity: 0.75;
  }
  .ai-fab {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 200ms ease, box-shadow 200ms ease;
    z-index: 1000;
  }
  .ai-fab:hover { transform: scale(1.04); }
  .ai-fab:active { opacity: 0.85; }
  .ai-fab[hidden] { display: none; }
  .badge-pro {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 100px;
    background: var(--primary-dim);
    color: var(--primary-glow);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
  }
  .badge-pro.hidden { display: none; }
  .badge-pro.pulse { animation: pro-badge-pulse 600ms 1; }
  @keyframes pro-badge-pulse {
    0% { box-shadow: 0 0 0 0 var(--primary-dim); }
    100% { box-shadow: 0 0 0 4px transparent; }
  }

  /* ===== LAYOUT ===== */
  .layout { display: flex; flex: 1; overflow: hidden; }

  /* ===== SIDEBAR ===== */
  .sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex; flex-direction: column; align-items: center;
    padding: 16px 0; gap: 4px; flex-shrink: 0; z-index: 10;
  }
  .sidebar-item {
    width: 56px; height: 56px; border-radius: var(--radius-sm);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; cursor: pointer; transition: all 0.2s;
    border: none; background: transparent; color: var(--text-muted);
    font-family: var(--font); position: relative;
    user-select: none; -webkit-user-select: none;
  }
  .sidebar-item .label { font-size: 0.625rem; font-weight: 600; letter-spacing: 0.3px; }
  .sidebar-item:hover { background: var(--surface-hover); color: var(--text); }
  .sidebar-item.active { background: rgba(139, 92, 246, 0.14); color: var(--primary); }

  /* ===== MAIN CONTENT ===== */
  .main {
    flex: 1; overflow-y: auto; padding: 32px 48px 48px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  .main::-webkit-scrollbar { width: 6px; }
  .main::-webkit-scrollbar-track { background: transparent; }
  .main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .view-wrap { max-width: 1500px; margin: 0 auto; }
  .view { display: none; }
  .view.active { display: block; }

  /* ===== CARDS ===== */
  .card {
    background: var(--surface);
    border-radius: var(--radius-lg); padding: 24px;
  }

  /* ===== TYPOGRAPHY ===== */
  .page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.3px; }
  .page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 24px; font-weight: 400; }
  .section-title {
    font-size: 0.8125rem; font-weight: 600; margin-bottom: 16px;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 8px;
  }

  /* ===== BUTTONS ===== */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 0.8125rem; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.2s; letter-spacing: 0.2px;
    user-select: none; -webkit-user-select: none;
  }
  .btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
  }
  .btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
    transform: translateY(-1px);
  }
  .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
  .btn-outline:hover { border-color: var(--primary); color: var(--primary); }
  .btn-sm { padding: 6px 14px; font-size: 0.75rem; }
  .btn-ghost { background: transparent; color: var(--text-muted); border: none; padding: 6px 8px; cursor: pointer; transition: color 0.2s; }
  .btn-ghost:hover { color: var(--primary); }
  .btn-full { width: 100%; }
  .mt-8 { margin-top: 8px; }
  .mt-12 { margin-top: 12px; }
  .mt-16 { margin-top: 16px; }
  .is-hidden { display: none; }
  .progress-zero { width: 0%; }
  .today-sparkline { width: 100%; display: block; min-height: 72px; max-height: 160px; }
  .card-compact-pad { padding: 20px; }
  .card-flush { padding: 0; overflow: hidden; }
  .card-scroll-x { overflow-x: auto; }
  .chart-area { width: 100%; min-height: 350px; transition: opacity 150ms ease; }
  .chart-area.chart-transitioning { opacity: 0; }
  .symptom-chart-area { width: 100%; height: 200px; margin: 16px 0; }

  .badge {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 100px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.2px;
  }
  .badge-violet {
    background: var(--primary-dim);
    color: var(--primary-glow);
  }
  .badge-cyan { background: var(--accent-dim); color: var(--accent); }
  .badge-amber {
    background: rgba(245,158,11,0.15);
    color: #FCD34D;
  }
  .badge-success { background: var(--success-dim); color: var(--success); }
  .ad-banner {
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
    background: var(--ad-surface);
    padding: 16px 24px;
    margin: 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-height: 160px;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
  }
  .ad-banner.visible {
    opacity: 1;
    transform: translateY(0);
  }
  .ad-banner-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .ad-banner-label {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.5;
  }
  .ad-banner-body {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
  }
  .ad-banner-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }
  .ad-banner-dismiss {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    transition: color 200ms ease;
  }
  .ad-banner-dismiss:hover { color: var(--text); }
  .ad-banner-upgrade-link {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    text-decoration: none;
    transition: color 200ms ease;
  }
  .ad-banner-upgrade-link:hover { color: var(--text); }
  .ad-banner.dismissing {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: opacity 200ms ease, max-height 200ms ease, margin 200ms ease, padding 200ms ease;
  }

  /* =================== TODAY VIEW =================== */
  .today-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
  .greeting { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.3px; }
  .greeting span { color: var(--text); }
  .date-text { font-size: 0.875rem; color: var(--text-muted); margin-top: 4px; font-weight: 400; }
  .streak-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; background: var(--primary-dim);
    border-radius: 100px; font-size: 0.8125rem; font-weight: 600; color: var(--primary-glow);
    user-select: none; -webkit-user-select: none;
  }
  .dose-status { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
  .dose-progress-bar { width: 160px; height: 4px; background: var(--border); border-radius: 8px; overflow: hidden; }
  .dose-progress-fill { height: 100%; background: var(--primary); border-radius: 8px; }
  .dose-status-text { font-size: 0.8125rem; color: var(--text-muted); }

  #today-nudge-area {
    display: grid;
    grid-template-columns: 5fr 4fr 4fr;
    gap: 20px;
    margin-bottom: 20px;
  }
  #today-nudge-area:empty { display: none; }

  .today-bento { display: grid; grid-template-columns: 5fr 4fr 4fr; gap: 20px; margin-bottom: 20px; }

  .doses-wrap {
    background: var(--surface);
    border-radius: var(--radius-lg); padding: 24px;
  }
  .dose-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; background: var(--bg); border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md); transition: border-color 0.2s;
  }
  .dose-card:hover { border-color: rgba(139,92,246,0.3); }
  .dose-card + .dose-card { margin-top: 8px; }
  .dose-card.taken { border-color: rgba(34,197,94,0.2); opacity: 0.75; }
  .dose-info { display: flex; align-items: center; gap: 12px; }
  .dose-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  }
  .dose-dot--trt { background: var(--primary); }
  .dose-dot--peptide { background: var(--accent); }
  .dose-dot--hcg { background: var(--amber); }
  .dose-name { font-weight: 600; font-size: 0.875rem; }
  .dose-detail { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; font-weight: 400; }
  .dose-taken-info {
    font-size: 0.75rem; color: var(--success); font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(34, 197, 94, 0.15); padding: 6px 14px;
    border-radius: var(--radius-sm);
  }

  .sparkline-card { padding: 24px; display: flex; flex-direction: column; overflow: hidden; }
  .engine-switcher {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
  }
  .engine-switcher .pill.active {
    background: var(--primary-dim);
    color: var(--primary-glow);
    border-color: rgba(139, 92, 246, 0.3);
  }
  .engine-switcher .pill.active[data-engine="hgh"] {
    background: var(--hgh-dim);
    color: var(--hgh);
    border-color: rgba(249, 115, 22, 0.3);
  }
  .engine-switcher .pill.active[data-engine="glp1"] {
    background: var(--glp1-dim);
    color: var(--glp1);
    border-color: rgba(132, 204, 22, 0.3);
  }
  .engine-switcher .pill.active[data-engine="pth"] {
    background: var(--pth-dim);
    color: var(--pth);
    border-color: rgba(34, 197, 94, 0.3);
  }
  .pill--locked {
    opacity: 0.38;
    cursor: default;
    pointer-events: none;
  }
  .pill-lock-wrapper {
    position: relative;
    cursor: pointer;
  }
  .pill-lock-wrapper .pill--locked {
    pointer-events: none;
  }
  .pill-lock-wrapper:active .pill--locked {
    transform: scale(0.96);
  }
  .pill-lock-wrapper svg.lock-icon {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 10px;
    height: 10px;
    color: var(--text-muted);
  }
  .engine-lock-tip {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease;
  }
  .engine-lock-tip.visible {
    opacity: 1;
    transform: translateY(0);
  }
  .sparkline-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
  .sparkline-value { font-size: 2rem; font-weight: 800; letter-spacing: -1px; transition: opacity 100ms ease; }
  .sparkline-value.value-updating { opacity: 0.4; }
  .sparkline-value small { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-left: 2px; letter-spacing: 0; }
  .sparkline-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
  .sparkline-sublabel { font-size: 0.75rem; color: var(--text-muted); margin-top: 12px; margin-bottom: 16px; display: flex; gap: 16px; font-weight: 400; flex-wrap: wrap; }
  .sparkline-sublabel .accent { color: var(--accent); font-weight: 500; }
  .sparkline-chart-block--secondary {
    border-top: 1px solid var(--subpanel-border);
    padding-top: 16px;
    margin-top: 16px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 200ms ease-out, transform 200ms ease-out;
  }
  .sparkline-chart-block--secondary.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
  .today-sparkline--secondary {
    width: 100%;
    height: 72px;
    display: block;
  }
  .engine-discovery-nudge {
    margin-top: 12px;
    grid-column: auto;
    background: var(--subpanel-surface);
    border-color: var(--subpanel-border);
  }

  .symptom-card { padding: 24px; }
  .slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .slider-row:last-of-type { margin-bottom: 0; }
  .slider-label { width: 56px; font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; font-weight: 500; }
  .slider-track { flex: 1; height: 6px; background: var(--border); border-radius: 8px; position: relative; }
  .slider-fill { height: 100%; border-radius: 3px; position: absolute; top: 0; left: 0; }
  .slider-fill.violet { background: var(--primary); }
  .slider-fill.cyan { background: var(--accent); }
  .slider-fill.green { background: var(--success); }
  .slider-fill.amber { background: var(--amber); box-shadow: 0 0 6px var(--amber-dim); }
  .slider-fill::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: inherit;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
  }
  .slider-val { width: 22px; text-align: right; font-size: 0.8125rem; color: var(--text); font-weight: 700; }
  .symptom-remove-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; flex-shrink: 0; transition: color 150ms; }
  .symptom-remove-btn:hover { color: var(--danger); }
  .symptom-add-section { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
  .symptom-add-row { display: flex; gap: 8px; align-items: center; }
  .symptom-add-input { flex: 1; font-size: 0.75rem; padding: 6px 10px; height: auto; min-width: 0; transition: border-color 300ms; }
  .symptom-add-btn { flex-shrink: 0; }
  .symptom-add-error { height: 16px; margin-top: 4px; font-size: 0.6875rem; color: var(--text-muted); opacity: 0; transition: opacity 150ms; }
  .symptom-undo-strip { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); transition: opacity 150ms ease; }
  .symptom-undo-label { font-size: 0.8125rem; color: var(--text-muted); }
  .symptom-undo-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.8125rem; padding: 0; }

  .tomorrow-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); font-size: 0.8125rem; color: var(--text-muted);
  }
  .tomorrow-bar strong { color: var(--text); font-weight: 600; }

  /* =================== PROTOCOL VIEW =================== */
  .protocol-sections { display: flex; flex-direction: column; gap: 28px; }
  .proto-top { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .proto-top > section { min-width: 0; }
  .compound-card {
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
    min-width: 0;
  }
  .compound-card:hover { border-color: rgba(139,92,246,0.2); }
  .compound-card + .compound-card { margin-top: 8px; }
  .compound-card-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
  .compound-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }
  .compound-left > div { flex: 1; min-width: 0; }
  .compound-type-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
  .compound-name { font-weight: 600; font-size: 0.875rem; }
  .compound-left .compound-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .compound-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; font-weight: 400; overflow-wrap: anywhere; }
  .compound-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
  .compound-action-row { display: flex; align-items: center; gap: 4px; }

  #protocol-cycle-timeline:empty { display: none; }

  .cycle-toggle-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
  }
  .cycle-toggle-btn.cycle-toggle-transition {
    transition: color 150ms ease, background 150ms ease, transform 100ms ease;
  }
  .cycle-toggle-btn.cycle-open {
    color: var(--primary);
    background: var(--primary-dim);
    border-radius: var(--radius-sm);
  }
  .cycle-toggle-btn:hover { color: var(--text); }
  .cycle-toggle-btn:active { transform: scale(0.93); }

  .cycle-enabled-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
  }
  .cycle-enabled-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .cycle-enabled-switch {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background-color 150ms ease, border-color 150ms ease;
  }
  .cycle-enabled-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 150ms ease;
  }
  .cycle-enabled-control input:checked + .cycle-enabled-switch {
    background: var(--primary);
    border-color: var(--primary);
  }
  .cycle-enabled-control input:checked + .cycle-enabled-switch::after {
    transform: translateX(16px);
  }
  .cycle-enabled-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
  }

  .cycle-first-use-label {
    min-height: 16px;
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted);
    text-align: center;
    opacity: 0;
    pointer-events: none;
  }
  .cycle-first-use-label.fade-in { animation: cycleLabelFadeIn 200ms ease forwards; }
  .cycle-first-use-label.fade-out { animation: cycleLabelFadeOut 200ms ease forwards; }
  @keyframes cycleLabelFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes cycleLabelFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
  }

  .compound-card.cycle-off-phase,
  .compound-card.cycle-off-phase:hover { border-color: var(--border-strong); }

  .compound-status-text {
    display: none;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
  }
  .compound-status-text.visible { display: block; }

  .cycle-config-block {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 160ms cubic-bezier(0.4, 0, 1, 1);
  }
  .cycle-config-block.expanded {
    grid-template-rows: 1fr;
    transition: grid-template-rows 200ms cubic-bezier(0.0, 0.0, 0.2, 1);
  }
  .cycle-config-inner {
    overflow: hidden;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .cycle-duration-control {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-md);
    padding: 12px;
  }
  .cycle-duration-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .cycle-duration-col .stepper-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .cycle-duration-col input[type="number"] {
    width: 48px;
    padding: 0;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: none;
    -moz-appearance: textfield;
  }
  .cycle-duration-col input[type="number"]::-webkit-inner-spin-button,
  .cycle-duration-col input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .cycle-duration-sublabel {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .cycle-duration-divider {
    width: 1px;
    align-self: stretch;
    margin: 0 8px;
    background: var(--border);
  }
  .cycle-contextual-copy {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.5;
  }
  .cycle-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.5;
  }
  .cycle-summary-repeating {
    display: flex;
    justify-content: flex-end;
  }
  .cycle-save-slot:empty { display: none; }
  .cycle-save-btn {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    margin-top: 4px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
  }
  .cycle-save-btn:hover { background: var(--primary-hover); }
  .cycle-start-date-label {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
  }
  .cycle-start-date-input {
    width: 100%;
    margin-top: 4px;
  }

  .cycle-timeline-panel {
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .cycle-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
  }
  .cycle-timeline-header-left {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
  }
  .cycle-timeline-subcopy {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.4;
  }
  .cycle-timeline-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
  }
  .cycle-active-pill {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--primary-dim);
    color: var(--primary);
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .cycle-legend-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .cycle-legend-dot,
  .cycle-legend-row-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .cycle-legend-overflow {
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .cycle-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 150ms ease;
  }
  .cycle-chevron.collapsed { transform: rotate(-90deg); }
  .cycle-timeline-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 200ms cubic-bezier(0.0, 0.0, 0.2, 1);
  }
  .cycle-timeline-body.collapsed {
    grid-template-rows: 0fr;
    transition: grid-template-rows 160ms cubic-bezier(0.4, 0, 1, 1);
  }
  .cycle-timeline-body-inner {
    overflow: hidden;
    max-height: 104px;
  }
  .cycle-timeline-scroll-area {
    display: flex;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0 12px;
    position: relative;
  }
  .cycle-sticky-column {
    width: 104px;
    flex-shrink: 0;
    padding-left: 16px;
    background: var(--surface);
  }
  .cycle-legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    margin-bottom: 6px;
  }
  .cycle-legend-row-copy {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    gap: 1px;
    overflow: hidden;
  }
  .cycle-legend-row:last-child,
  .cycle-bar-row:last-child { margin-bottom: 0; }
  .cycle-legend-row-name {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
  }
  .cycle-legend-row-meta {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.625rem;
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1.1;
    opacity: 0.9;
  }
  .cycle-scroll-zone {
    flex: 1;
    overflow-x: auto;
    overflow-y: visible;
    padding-right: 16px;
    -webkit-overflow-scrolling: touch;
  }
  .cycle-bars-rows {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .cycle-bar-row {
    position: relative;
    height: 34px;
  }
  .cycle-bar-segment {
    position: absolute;
    top: 7px;
    height: 20px;
    border-radius: var(--radius-sm);
  }
  .cycle-bar-segment.cycle-bar-segment--join-left {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }
  .cycle-bar-segment.cycle-bar-segment--join-right {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }
  .cycle-overflow-gradient {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 16px;
    background: linear-gradient(to top, var(--surface) 0%, transparent 100%);
    pointer-events: none;
    z-index: 2;
  }
  .cycle-today-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary);
    box-shadow: 0 0 4px rgba(var(--primary-rgb), 0.4);
    z-index: 3;
    pointer-events: none;
  }
  .cycle-today-dot {
    position: absolute;
    top: -3px;
    left: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
  }
  .cycle-today-label {
    position: absolute;
    top: -18px;
    left: -24px;
    font-size: 0.625rem;
    color: var(--primary-glow);
    white-space: nowrap;
  }

  .weekly-grid { display: flex; gap: 6px; min-width: 0; max-width: 100%; }
  .day-col { flex: 1; min-width: 0; text-align: center; }
  .day-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
  .day-dots { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 60px; }
  .day-dot {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.625rem; font-weight: 600;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  }
  .day-dot.tc { background: rgba(124, 58, 237, 0.15); border-color: rgba(124, 58, 237, 0.30); color: #A78BFA; }
  .day-dot.bpc { background: rgba(6, 182, 212, 0.15); border-color: rgba(6, 182, 212, 0.30); color: #67E8F9; }
  .day-dot.hcg { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.30); color: #FCD34D; }
  .schedule-legend { display: flex; gap: 16px; margin-top: 12px; min-width: 0; max-width: 100%; }
  .schedule-legend > * { min-width: 0; max-width: 100%; flex: 0 1 auto; }
  .schedule-legend > * > span:last-child { min-width: 0; overflow-wrap: anywhere; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
  .legend-dot { width: 8px; height: 8px; border-radius: 50%; }

  .vial-card { padding: 20px; background: var(--surface); border: 1px solid rgba(255, 255, 255, 0.05); border-radius: var(--radius-md); }
  .vial-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .vial-name { font-weight: 600; font-size: 0.875rem; }
  .vial-remaining { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
  .vial-bar { height: 6px; background: var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
  .vial-bar-fill { height: 100%; background: var(--accent); border-radius: 8px; }
  .vial-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; justify-content: space-between; font-weight: 400; }
  .proto-vial-type-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .proto-vial-type-btn {
    min-height: 44px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--field-border);
    background: var(--field-surface);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  }
  .proto-vial-type-btn:hover {
    border-color: var(--field-border-strong);
    background: var(--field-surface-hover);
    color: var(--text);
  }
  .proto-vial-type-btn:focus-visible {
    outline: 2px solid var(--field-ring);
    outline-offset: 1px;
  }
  .proto-vial-type-btn.selected {
    border-color: var(--primary);
    background: var(--primary-dim);
    color: var(--text);
  }
  .vial-update-affordance {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 0;
    cursor: pointer;
    touch-action: manipulation;
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 150ms ease, color 150ms ease;
    user-select: none;
  }
  .vial-update-affordance:hover,
  .vial-update-affordance:focus {
    opacity: 1;
    color: var(--text);
    outline: none;
  }
  .vial-update-affordance:focus-visible {
    outline: 2px solid var(--field-ring);
    outline-offset: 2px;
    border-radius: 4px;
  }
  .vial-pct-picker {
    display: flex;
    gap: 4px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 16px 0;
  }
  .vial-pct-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    cursor: pointer;
    touch-action: manipulation;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  .vial-pct-segment.selected {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--text);
  }
  .vial-pct-segment:hover:not(.selected) {
    background: var(--surface-active, var(--surface-hover));
    border-color: var(--border-hover, var(--border));
  }
  .vial-pct-segment:focus-visible {
    outline: 2px solid var(--field-ring);
    outline-offset: -2px;
  }
  .vial-update-modal {
    max-width: 320px;
  }
  @media (max-width: 768px) {
    .vial-update-modal {
      position: fixed !important;
      bottom: 0 !important;
      left: 0 !important;
      right: 0 !important;
      top: auto !important;
      max-width: 100% !important;
      width: 100% !important;
      border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0 !important;
      max-height: 60dvh;
      overflow-y: auto;
      margin: 0 !important;
      transform: none !important;
    }
  }

  .body-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .body-stat { text-align: center; padding: 16px 8px; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
  .body-stat-value { font-size: 1.25rem; font-weight: 700; }
  .body-stat-label { font-size: 0.6875rem; color: var(--text-muted); margin-top: 4px; font-weight: 400; }

  /* =================== INSIGHTS VIEW =================== */
  .insights-subtabs {
    display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border);
    padding: 4px; border-radius: var(--radius-md); margin-bottom: 24px; width: fit-content;
  }
  .subtab {
    padding: 8px 20px; border-radius: var(--radius-sm);
    font-size: 0.8125rem; font-weight: 600; cursor: pointer;
    border: none; background: transparent;
    color: var(--text-muted); font-family: var(--font); transition: all 0.2s;
    display: flex; align-items: center; gap: 6px;
    user-select: none; -webkit-user-select: none;
  }
  .subtab:hover { color: var(--text); }
  .subtab.active { background: var(--primary); color: #fff; }
  .insights-layout { display: grid; grid-template-columns: 5fr 3fr; gap: 24px; }
  .insight-panel { display: none; }
  .insight-panel.active { display: block; }

  .time-pills { display: flex; gap: 4px; margin-bottom: 16px; }
  .pill {
    padding: 6px 14px; border-radius: 100px;
    font-size: 0.75rem; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); font-family: var(--font); transition: all 0.2s;
    user-select: none; -webkit-user-select: none;
  }
  .pill:hover { border-color: var(--primary); color: var(--primary); }
  .pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
  .pill--future { border-color: rgba(249, 115, 22, 0.45); color: #F97316; }
  .pill--future:hover { border-color: #F97316; color: #F97316; background: rgba(249, 115, 22, 0.08); }
  .pill--future.active-future { background: #F97316; border-color: #F97316; color: #fff; }

  .chart-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
  .chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
  .engine-picker { position: relative; }
  .engine-picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px 0 12px;
    background: var(--engine-picker-surface);
    border: 1px solid var(--engine-picker-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
    user-select: none;
    -webkit-user-select: none;
  }
  .engine-picker-btn:hover {
    background: var(--engine-picker-hover);
    border-color: rgba(255, 255, 255, 0.14);
  }
  .engine-picker-btn svg.chevron {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
    transition: transform 150ms ease;
  }
  .engine-picker-btn[aria-expanded="true"] svg.chevron {
    transform: rotate(180deg);
  }
  .engine-picker-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
    padding: 4px 0;
  }
  .engine-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background 100ms ease;
  }
  .engine-picker-item:hover {
    background: var(--surface-hover);
  }
  .engine-picker-item.active {
    color: var(--primary-glow);
  }
  .engine-picker-item.active svg.check {
    color: var(--primary-glow);
  }
  .engine-picker-item.locked {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: default;
    flex-direction: column;
    align-items: flex-start;
  }
  .engine-picker-item.locked:hover {
    background: transparent;
  }
  .engine-picker-item-note {
    font-size: 0.6875rem;
    line-height: 1.35;
    color: var(--text-muted);
    padding-left: 22px;
  }
  .engine-picker-divider {
    margin: 4px 0;
    border: none;
    border-top: 1px solid var(--border);
    padding: 4px 14px 0;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.5;
  }
  .chart-series-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
  }
  .chart-toggle {
    padding: 5px 12px; border-radius: 100px; font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); cursor: pointer; font-family: var(--font); transition: all 0.2s;
  }
  .chart-toggle.active-v { background: var(--primary-dim); border-color: rgba(139,92,246,0.3); color: var(--primary-glow); }
  .chart-toggle.active-c { background: var(--accent-dim); border-color: rgba(6,182,212,0.3); color: var(--accent); }
  .chart-toggle.active-hgh { background: var(--hgh-dim); border-color: rgba(249,115,22,0.3); color: var(--hgh); }
  .chart-toggle.active-pulse { background: var(--amber-dim); border-color: rgba(245,158,11,0.3); color: var(--amber); }
  .chart-toggle.active-glp1 { background: var(--glp1-dim); border-color: rgba(132,204,22,0.3); color: var(--glp1); }
  .chart-toggle.active-pth { background: var(--pth-dim); border-color: rgba(34,197,94,0.3); color: var(--pth); }
  .chart-svg-wrap { width: 100%; aspect-ratio: 2.2 / 1; margin-bottom: 16px; }
  .chart-svg-wrap svg { width: 100%; height: 100%; }

  .est-levels { display: flex; gap: 24px; padding: 16px 0 0; border-top: 1px solid var(--border); }
  .est-level { display: flex; align-items: center; gap: 8px; }
  .est-dot { width: 10px; height: 10px; border-radius: 50%; }
  .est-label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 400; }
  .est-value { font-size: 0.875rem; font-weight: 700; }

  .log-list { display: flex; flex-direction: column; gap: 0; }
  .log-list .log-entry + .log-entry { border-top: 1px solid #1E293B; }
  .log-entry {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: var(--surface);
    font-size: 0.8125rem;
  }
  .log-list .log-entry:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .log-list .log-entry:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
  .log-entry-left { display: flex; flex-direction: column; gap: 2px; }
  .log-compound { font-weight: 600; color: var(--text); }
  .log-date { color: var(--text-muted); font-size: 0.75rem; font-weight: 400; }
  .log-dose { color: var(--text-muted); font-weight: 600; }

  .history-table { width: 100%; border-collapse: collapse; }
  .history-table th { text-align: left; padding: 10px 12px; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600; }
  .history-table td { padding: 12px 12px; font-size: 0.8125rem; border-bottom: 1px solid var(--border); color: var(--text); }
  .history-table tr:hover td { background: var(--surface-hover); }
  .history-date { display: block; }
  .history-time { display: none; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
  .history-route-site { display: none; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

  .symptom-chart-placeholder { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
  .labs-placeholder-card { text-align: center; padding: 48px 24px; }
  .labs-placeholder-icon { margin-bottom: 16px; color: var(--text-muted); }
  .labs-placeholder-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
  .labs-placeholder-copy { color: var(--text-muted); font-size: 0.875rem; max-width: 400px; margin: 0 auto 24px; }

  /* Recent Doses compound color borders */
  .log-entry--testosterone { border-left: 3px solid var(--primary); padding-left: 13px; }
  .log-entry--bpc157 { border-left: 3px solid var(--accent); padding-left: 13px; }
  .log-entry--hcg { border-left: 3px solid var(--amber); padding-left: 13px; }

/* Mobile Bottom Tab Bar */
.bottom-tabs { position:fixed; bottom:0; left:0; right:0; height:64px;
  background:var(--surface); border-top:1px solid var(--border);
  display:none; align-items:center; justify-content:space-around;
  z-index:100; padding-bottom:env(safe-area-inset-bottom); }
.bottom-tab { display:flex; flex-direction:column; align-items:center; gap:4px;
  background:none; border:none; color:var(--text-muted); font-family:var(--font);
  font-size:0.625rem; font-weight:600; cursor:pointer; padding:8px 16px;
  transition:color 0.2s; user-select:none; -webkit-user-select:none; }
.bottom-tab.active { color:var(--primary); }

/* Overlays */
.overlay { position:fixed; inset:0; z-index:500;
  background:rgba(0,0,0,0.6); backdrop-filter:blur(4px); }
.overlay-hidden { display: none; }
.overlay-panel { position:absolute; top:0; right:0;
  width:min(400px,100%); height:100%; background:var(--surface);
  border-left:1px solid var(--border); display:flex; flex-direction:column;
  animation:slideInRight 250ms cubic-bezier(0.32, 0.72, 0, 1); }
@keyframes slideInRight {
  from { transform:translateX(100%); opacity:0; }
  to { transform:translateX(0); opacity:1; }
}
@keyframes slideOutRight {
  from { transform:translateX(0); opacity:1; }
  to { transform:translateX(100%); opacity:0; }
}
@keyframes slideUpSheet {
  from { transform:translateY(100%); opacity:0; }
  to { transform:translateY(0); opacity:1; }
}
@keyframes slideDownSheet {
  from { transform:translateY(0); opacity:1; }
  to { transform:translateY(100%); opacity:0; }
}
.overlay-closing .overlay-panel {
  animation:slideOutRight 150ms ease-in forwards;
}
@media (max-width:480px) {
  .overlay-panel {
    top:auto;
    right:0;
    bottom:0;
    left:0;
    width:100%;
    max-height:92dvh;
    height:auto;
    border-left:none;
    border-radius:var(--radius-lg) var(--radius-lg) 0 0;
    animation:slideUpSheet 300ms cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .overlay-closing .overlay-panel {
    animation:slideDownSheet 150ms ease-in forwards;
  }
}
.overlay-header { display:flex; justify-content:space-between;
  align-items:center; padding:16px 24px; border-bottom:1px solid var(--border);
  position:sticky; top:0; background:var(--surface); z-index:1; }
.overlay-header h2 { font-size:1rem; font-weight:600; }
.simulator-overlay-heading {
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.topbar-brand--simulator {
  gap:8px;
  flex-shrink:0;
}
.topbar-brand--simulator img {
  height:24px;
  width:auto;
}
.topbar-brand--simulator > span {
  font-size:1.32rem;
  letter-spacing:-0.3px;
  white-space:nowrap;
}
.topbar-brand--simulator .brand-beta,
.topbar-brand--simulator .brand-version {
  font-size:1.05rem;
}
.simulator-overlay-heading-text {
  font-size:1rem;
  font-weight:600;
  color:var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.overlay-body { flex:1; overflow-y:auto; padding:24px; -webkit-overflow-scrolling:touch; overscroll-behavior-y:contain;
  min-height:0;
  mask-image:linear-gradient(
    to bottom,
    transparent 0px,
    black 16px,
    black calc(100% - 16px),
    transparent 100%
  );
  -webkit-mask-image:linear-gradient(
    to bottom,
    transparent 0px,
    black 16px,
    black calc(100% - 16px),
    transparent 100%
  );
}
.overlay-drag-handle {
  display:none;
  width:32px;
  height:4px;
  background:rgba(255, 255, 255, 0.2);
  border-radius:2px;
  margin:8px auto 0;
}
@media (max-width:480px) {
  .overlay-drag-handle { display:block; }
}
.overlay-close-btn {
  width:44px;
  height:44px;
  padding:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  border:none;
  cursor:pointer;
  color:var(--text-muted);
  border-radius:var(--radius-sm);
  flex-shrink:0;
  transition:background 150ms ease;
}
.overlay-close-btn:hover { background:var(--surface-hover); }
.overlay-close-btn:active { background:var(--primary-dim); }

@media (min-width:481px) {
  #simulator-content {
    padding:24px 48px;
  }
}

/* Simulator — Compound Slots */
.sim-layout {
  display:flex;
  flex-direction:column;
  gap:24px;
}
.sim-intake {
  width:min(100%, 520px);
  margin:0 auto;
  display:flex;
  flex-direction:column;
  gap:16px;
}
.sim-results-region {
  width:100%;
  min-width:0;
}
.sim-intake-header {
  display:flex;
  flex-direction:column;
  gap:12px;
}
.sim-header-strip {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:12px;
}
.sim-meta {
  margin:0;
  font-size:0.8125rem;
  color:var(--text-muted);
}
.sim-slot {
  padding:12px 16px;
  background:var(--field-surface);
  border:1px solid var(--field-border);
  border-radius:var(--radius-sm);
}
.sim-slot:hover {
  border-color:var(--field-border-strong);
}
.sim-slot-compound {
  width:100%;
  min-width:0;
  font-size:0.9375rem;
  font-weight:500;
}
.sim-slot-dose {
  width:100%;
  min-width:0;
}
.sim-slot-freq {
  width:100%;
  min-width:0;
  font-size:0.8125rem;
  color:var(--text-muted);
}
.sim-slot-freq:focus {
  color:var(--text);
}
.sim-slot-remove {
  width:44px;
  height:44px;
  min-width:44px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:none;
  border:none;
  cursor:pointer;
  color:var(--text-muted);
  opacity:0.4;
  padding:0;
  border-radius:var(--radius-sm);
  flex-shrink:0;
}
.sim-slot-remove:hover,
.sim-slot-remove:focus {
  color:var(--danger);
  opacity:1;
}
.sim-add-btn {
  background:none;
  border:none;
  cursor:pointer;
  font-size:0.8125rem;
  font-weight:500;
  color:var(--text-muted);
  padding:0;
  text-align:left;
}
.sim-cap-msg {
  font-size:0.8125rem;
  font-weight:400;
  color:var(--text-muted);
}
.badge-source {
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:var(--primary-dim);
  color:var(--primary-glow);
  border-radius:100px;
  padding:3px 10px;
  font-size:0.75rem;
  font-weight:600;
  letter-spacing:0.3px;
}
.badge-source-clear {
  background:none;
  border:none;
  cursor:pointer;
  color:var(--primary-glow);
  opacity:0.65;
  padding:0;
  display:flex;
  align-items:center;
  font-size:0.875rem;
  line-height:1;
}
.badge-source-clear:hover {
  opacity:1;
}
.sim-chart-wrap {
  height:380px;
}
.sim-chart-card {
  padding:20px;
}
@media (max-width:640px) {
  .sim-chart-wrap {
    height:clamp(280px, 48vh, 420px);
  }
}
.sim-slot-inner {
  display:flex;
  flex-direction:column;
  gap:8px;
  flex:1;
  min-width:0;
}
.sim-slot-name-row {
  display:grid;
  grid-template-columns:minmax(0, 1fr) 44px;
  align-items:end;
  gap:12px;
}
.sim-slot-fields-row {
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
}
.sim-slot-label {
  font-size:0.75rem;
  color:var(--text-muted);
  font-weight:400;
}
.sim-slot-field-group {
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
}
.sim-slot-field-group--compound {
  width:100%;
}
.sim-window-tray {
  background:var(--control-tray-surface);
  border:1px solid var(--control-tray-border);
  border-radius:var(--radius-sm);
  padding:3px;
  display:flex;
  gap:3px;
}
.sim-window-btn {
  padding:6px 12px;
  border-radius:6px;
  border:none;
  font-size:0.8125rem;
  font-weight:500;
  cursor:pointer;
  background:transparent;
  color:var(--text-muted);
  font-family:var(--font);
}
.sim-window-btn.active {
  background:var(--control-active-surface);
  color:var(--text);
  box-shadow:var(--control-active-shadow);
}
.sim-from-row {
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.sim-from-label {
  font-size:0.8125rem;
  color:var(--text-muted);
}
.sim-from-date {
  font-size:0.8125rem;
  color:var(--text);
}
.sim-stack-zone {
  display:flex;
  flex-direction:column;
  gap:12px;
}
.sim-slot-list {
  display:flex;
  flex-direction:column;
  gap:8px;
}
.sim-add-area {
  margin-top:8px;
}
.sim-option-row {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.sim-option-btn {
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text-muted);
  font-size:0.75rem;
  font-weight:600;
  letter-spacing:0.02em;
  cursor:pointer;
  font-family:var(--font);
}
.sim-option-btn:hover {
  color:var(--text);
  border-color:var(--field-border-strong);
}
.sim-option-btn.active.sim-option-btn--protocol {
  background:var(--primary-dim);
  border-color:rgba(139, 92, 246, 0.38);
  color:var(--primary-glow);
}
.sim-option-btn.active.sim-option-btn--ramp {
  background:var(--amber-dim);
  border-color:rgba(245, 158, 11, 0.34);
  color:var(--amber);
}
.sim-option-btn.active.sim-option-btn--mode-gbarl {
  background:rgba(34, 197, 94, 0.12);
  border-color:rgba(34, 197, 94, 0.34);
  color:#86efac;
}
.sim-option-btn.active.sim-option-btn--mode-hormones {
  background:var(--primary-dim);
  border-color:rgba(139, 92, 246, 0.38);
  color:var(--primary-glow);
}
.sim-option-btn.active.sim-option-btn--labels {
  background:rgba(148, 163, 184, 0.14);
  border-color:rgba(148, 163, 184, 0.34);
  color:#cbd5e1;
}
.sim-empty-state {
  min-height:120px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:0.8125rem;
  color:var(--text-muted);
  text-align:center;
  max-width:520px;
  margin:0 auto;
}
.sim-status {
  margin-top:8px;
  font-size:0.8125rem;
  color:var(--text-muted);
}
.sim-status.sim-status-error {
  color:var(--amber);
}
@keyframes sim-results-in {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.sim-results-enter {
  animation:sim-results-in 250ms ease-out forwards;
}
@media (min-width:960px) {
  .sim-empty-state {
    display:none;
  }
  .sim-layout.sim-layout--results {
    display:grid;
    grid-template-columns:minmax(320px, 520px) minmax(0, 1fr);
    align-items:start;
    gap:24px;
  }
  .sim-layout.sim-layout--results .sim-intake {
    width:100%;
    margin:0;
  }
}
@media (max-width:640px) {
  .simulator-overlay-heading {
    gap:8px;
  }
  .topbar-brand--simulator img {
    height:20px;
  }
  .topbar-brand--simulator > span {
    font-size:0.8125rem;
  }
  .simulator-overlay-heading-text {
    font-size:0.875rem;
  }
  .sim-chart-card {
    padding:12px;
  }
  .sim-option-row {
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:6px;
  }
  .sim-option-btn {
    width:100%;
    text-align:center;
    padding:6px 8px;
    font-size:0.6875rem;
  }
  .sim-layout.sim-layout--results .sim-empty-state {
    display:none;
  }
  .sim-header-strip {
    align-items:flex-start;
  }
  .sim-slot-name-row {
    grid-template-columns:minmax(0, 1fr);
    align-items:start;
  }
  .sim-slot-remove {
    justify-self:end;
  }
  .sim-slot-fields-row {
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

/* Modal dialogs (onboarding + protocol/settings forms) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: min(680px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}
.upgrade-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--modal-backdrop);
  opacity: 0;
  transition: opacity 180ms ease;
}
.upgrade-modal-backdrop.visible { opacity: 1; }
.upgrade-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  z-index: 201;
  width: min(480px, calc(100vw - 32px));
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--modal-surface-top) 0%, var(--modal-surface-bottom) 100%);
  border: 1px solid var(--modal-border-strong);
  box-shadow: var(--modal-shadow-premium);
  padding: 32px;
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 220ms ease;
}
.upgrade-modal.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.upgrade-modal.closing {
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0;
  transition: transform 180ms ease-in, opacity 180ms ease-in;
}
.upgrade-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  transition: color 200ms ease;
}
.upgrade-modal-close:hover { color: var(--text); }
.upgrade-modal-header {
  margin-bottom: 24px;
  text-align: center;
}
.upgrade-modal-headline {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  margin: 0 0 8px 0;
}
.upgrade-modal-subhead {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
  margin: 0;
}
.plan-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}
.plan-card {
  flex: 1;
  border-radius: var(--radius-md);
  padding: 24px;
  position: relative;
}
.plan-basic {
  background: var(--subpanel-surface);
  border: 1px solid var(--subpanel-border);
}
.plan-pro {
  background: var(--pro-tier-surface);
  border: 1px solid var(--primary);
  box-shadow: 0 0 0 1px var(--primary-dim);
}
.plan-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px 0;
}
.plan-card-price {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin: 0 0 16px 0;
}
.plan-card-price span {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
}
.plan-pro .badge-violet {
  position: absolute;
  top: -1px;
  right: 16px;
  padding: 3px 8px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.plan-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}
.plan-feature-check {
  width: 16px;
  height: 16px;
  color: var(--primary-glow);
  flex-shrink: 0;
}
.btn-subscribe-disabled {
  width: 100%;
  padding: 12px 20px;
  margin-top: 8px;
  background: var(--surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: not-allowed;
  opacity: 0.7;
}
.btn-subscribe-disabled + .coming-soon-text {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}
@media (max-width: 480px) {
  .upgrade-modal { padding: 24px; }
  .plan-cards { flex-direction: column; }
}

/* ── Previous Doses Modal ── */
.previous-doses-modal {
  width: min(960px, 100%);
  max-height: 92vh;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.pd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 0;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

.pd-header-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.pd-origin-tip {
  margin-top: 4px;
  max-width: 260px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--primary-glow);
  font-weight: 500;
  text-align: right;
}

.pd-kicker-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.pd-kicker {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pd-nav-btn {
  background: none;
  border: none;
  padding: 0 1px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font);
  line-height: 1;
  opacity: 0.45;
  transition: opacity 150ms ease;
}
.pd-nav-btn:hover:not(:disabled) { opacity: 0.9; }
.pd-nav-btn:disabled { opacity: 0.15; cursor: default; }

.pd-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.pd-close-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--subpanel-surface);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pd-body {
  padding: 16px 20px 20px;
  flex: 1;
}

.pd-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.pd-day {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--subpanel-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pd-day.rest {
  min-height: 88px;
  border-style: dashed;
  border-color: rgba(30, 41, 59, 0.5);
}

.pd-day-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.pd-date strong {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
}

.pd-date span {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.pd-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: none;
  transition: background-color 300ms ease, box-shadow 300ms ease;
}
.pd-mark.taken {
  background: var(--success);
  border: none;
  box-shadow: 0 0 0 3px var(--success-dim);
}
.pd-mark.missed {
  background: var(--amber);
  border: none;
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.pd-dose-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pd-chip.taken {
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--subpanel-surface);
  border: 1px solid var(--border);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.pd-chip.taken .pd-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.pd-chip.taken .pd-chip-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-chip.missed {
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
}
.pd-chip.missed .pd-chip-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}
.pd-chip.missed .pd-chip-name {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.pd-chip--oil.missed {
  background: var(--accent-dim);
  border-color: rgba(6, 182, 212, 0.35);
}
.pd-chip--peptide.missed {
  background: var(--amber-dim);
  border-color: rgba(245, 158, 11, 0.35);
}

.pd-missed-btn {
  flex-shrink: 0;
  width: 22px;
  height: 14px;
  padding: 0;
  border-radius: 3px;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 60ms ease;
  pointer-events: none;
}
.pd-missed-btn:active { transform: scale(0.88); }
.pd-missed-btn .pd-mdot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
}

.pd-chip.missed.expanded .pd-chip-dot,
.pd-chip.missed.expanded .pd-chip-name,
.pd-chip.missed.expanded .pd-missed-btn { display: none; }

.pd-chip-actions {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.pd-action-skip,
.pd-action-taken {
  flex: 1;
  min-width: 0;
  height: 18px;
  border-radius: 3px;
  border: none;
  font-family: var(--font);
  font-size: 0.5625rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: transform 60ms ease;
}
.pd-action-skip { background: var(--danger); color: #fff; }
.pd-action-taken { background: var(--success); color: #052e16; }
.pd-action-skip:active,
.pd-action-taken:active { transform: scale(0.94); }
@keyframes pdPopoverFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.pd-chip.skipped {
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--subpanel-surface);
  border: 1px solid var(--border);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}
.pd-chip.skipped .pd-chip-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}
.pd-chip.skipped .pd-chip-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-rest-note {
  margin-top: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.pd-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 20px 20px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.pd-btn-close {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--subpanel-surface);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.pd-footer--action { justify-content: space-between; }

.pd-btn-mark-all {
  padding: 10px 20px;
  min-height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--success);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 150ms ease;
}
.pd-btn-mark-all:hover { opacity: 0.88; }
.pd-btn-mark-all:active { opacity: 0.78; transform: scale(0.97); }
.pd-btn-mark-all:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pd-toast-container {
  position: sticky;
  bottom: 56px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
.pd-toast {
  background: var(--surface);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
}
.pd-toast.visible { opacity: 1; transform: translateY(0); }
.pd-toast.hiding {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 300ms ease, transform 300ms ease;
}
.pd-toast .pd-toast-name { color: var(--success); }
.pd-toast-undo-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 0 12px;
  flex-shrink: 0;
  pointer-events: auto;
}

@media (max-width: 960px) {
  .pd-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .pd-body { padding-left: 16px; padding-right: 16px; }
  .pd-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .pd-day {
    padding: 12px;
    border-radius: 10px;
    gap: 12px;
  }
  .pd-day.rest { min-height: 110px; }
  .pd-date strong { font-size: 1rem; }
  .pd-date span { font-size: 0.8125rem; }
  .pd-mark {
    width: 12px;
    height: 12px;
  }
  .pd-chip.taken,
  .pd-chip.missed,
  .pd-chip.skipped {
    height: 30px;
    padding: 0 10px;
    border-radius: 6px;
  }
  .pd-chip.taken .pd-chip-dot,
  .pd-chip.skipped .pd-chip-dot {
    width: 7px;
    height: 7px;
  }
  .pd-chip.missed .pd-chip-dot {
    width: 6px;
    height: 6px;
  }
  .pd-chip.taken .pd-chip-name,
  .pd-chip.missed .pd-chip-name,
  .pd-chip.skipped .pd-chip-name { font-size: 0.875rem; }
  .pd-missed-btn {
    width: 26px;
    height: 18px;
  }

  /* Chip action popover — replaces inline 18px buttons on mobile */
  .pd-chip.missed.expanded {
    position: relative;
    overflow: visible;
  }
  .pd-chip-actions {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 140px;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--modal-border-strong);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    z-index: 20;
    animation: pdPopoverFadeIn 120ms ease-out forwards;
  }
  .pd-action-skip,
  .pd-action-taken {
    height: auto;
    min-height: 36px;
    font-size: 0.75rem;
    font-weight: 600;
  }
}

.protocol-compound-backdrop {
  background: var(--modal-backdrop);
  backdrop-filter: blur(10px);
  padding: 24px;
}
.protocol-compound-modal {
  width: min(720px, 100%);
  background: linear-gradient(180deg, var(--modal-surface-top) 0%, var(--modal-surface-bottom) 100%);
  border: 1px solid var(--modal-border-strong);
  box-shadow: var(--modal-shadow-premium);
  padding: 32px;
  animation: modalSlideUp 0.2s ease-out;
}
.protocol-compound-modal .modal-actions {
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--modal-border-soft);
}
.protocol-compound-modal .modal-actions .btn {
  min-height: 44px;
}
.protocol-compound-modal .modal-actions .btn-ghost {
  padding: 10px 16px;
  border: 1px solid var(--subpanel-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.protocol-compound-modal .modal-actions .btn-ghost:hover {
  border-color: var(--field-border-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.protocol-compound-modal .modal-actions .btn-ghost:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--field-ring);
}
.protocol-compound-modal .modal-actions .btn-ghost:active {
  transform: translateY(1px);
}
.protocol-compound-modal .modal-actions .btn-primary {
  padding: 10px 18px;
  font-weight: 700;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.24);
}
.protocol-compound-modal .modal-actions .btn-primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
  box-shadow: 0 14px 28px rgba(139, 92, 246, 0.28);
}
.protocol-compound-modal .modal-actions .btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.24), 0 0 0 3px var(--field-ring);
}
.protocol-compound-modal .modal-actions .btn-primary:active {
  transform: translateY(1px);
}
.protocol-compound-modal .modal-actions .btn-primary:disabled,
.protocol-compound-modal .modal-actions .btn-ghost:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}
.onboarding-wizard {
  width: min(760px, 100%);
  max-height: min(92vh, 940px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

/* Settings Sections */
.form-group { margin-bottom:20px; }
.form-group--narrow  { max-width: 120px; }
.form-group--medium  { max-width: 240px; }
.form-group-flush { margin-bottom:0; }
.form-label { display:block; font-size:0.75rem; font-weight:600;
  color:var(--text-muted); margin-bottom:8px; }
.form-input, .form-select { width:100%; padding:10px 14px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius:var(--radius-sm); color:var(--text);
  font-family:var(--font); font-size:0.875rem; font-weight:400;
  outline:none; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2); transition:border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance:none; appearance:none; }
.form-input:focus, .form-select:focus { border-color:rgba(139, 92, 246, 0.5);
  box-shadow:0 0 0 2px rgba(139, 92, 246, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.2); }
.form-input::placeholder { color:var(--text-muted); opacity:0.6; }
.form-select { 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='%2394A3B8' 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 12px center;
  padding-right:36px; cursor:pointer; }
.form-select option { background:var(--surface); color:var(--text); padding:8px; }
input[type="time"] { color-scheme:dark; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { opacity:0.3; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }
.protocol-compound-modal .compound-type-name-row { grid-template-columns:1fr 2fr; }
@media (max-width:480px) {
  .protocol-compound-modal .proto-compound-primary-row {
    grid-template-columns: 2fr 1fr;
  }
  .protocol-compound-modal .proto-compound-primary-row > .form-group:first-child {
    grid-column: 1 / -1;
  }
}

/* Fused input + addon (dose + unit) */
.input-group { display:flex; }
.input-group .input-group-field {
  border-radius:var(--radius-sm) 0 0 var(--radius-sm);
  border-right:none; flex:1; min-width:0; }
.input-group .input-group-addon {
  border-radius:0 var(--radius-sm) var(--radius-sm) 0;
  width:auto; min-width:80px; flex-shrink:0; }
.input-group:focus-within .input-group-field,
.input-group:focus-within .input-group-addon { border-color:var(--primary); }

.form-hint { font-size:0.75rem; color:var(--text-muted); margin-top:4px; }
.form-hint-spaced { margin-top:8px; }
.seg-control { display:flex; border:1px solid var(--border); border-radius:var(--radius-sm); overflow:hidden; }
.seg-btn { flex:1; padding:10px 14px; background:transparent; border:none; color:var(--text-muted); font-family:var(--font); font-size:0.875rem; font-weight:400; cursor:pointer; transition:background 0.15s,color 0.15s; line-height:1; }
.seg-btn + .seg-btn { border-left:1px solid var(--border); }
.seg-btn.active { background:var(--primary); color:#fff; font-weight:500; }
.seg-btn:hover:not(.active) { background:var(--border); color:var(--text); }
.dose-units-hint { font-size:0.7rem; color:var(--text-muted); display:block; margin-top:2px; }
.compound-vial-meta { font-size:0.7rem; color:var(--text-muted); overflow-wrap:anywhere; }
.compound-vial-warning { font-size:0.7rem; color:var(--amber); overflow-wrap:anywhere; }
.protocol-compound-modal .vial-section-wrap { margin-top:4px; padding-top:16px; border-top:1px solid var(--border); }
.protocol-compound-modal .vial-section-header { cursor:pointer; display:flex; align-items:center; gap:8px; }
.protocol-compound-modal .vial-section-label { margin:0; }
.protocol-compound-modal .vial-section-hint { font-size:0.72rem; color:var(--text-muted); }

.protocol-compound-modal .dialog-header { margin-bottom:24px; }
.protocol-compound-modal .dialog-title { margin:0; font-size:1.25rem; font-weight:700; line-height:1.15; letter-spacing:-0.02em; }
.protocol-compound-modal .dialog-subtitle { margin:8px 0 0; font-size:0.875rem; line-height:1.5; color:var(--text-muted); }
.protocol-compound-modal .form-group { margin-bottom:24px; }
.protocol-compound-modal .form-label { letter-spacing:0.01em; color:var(--text-muted); margin-bottom:8px; }
.protocol-compound-modal .form-input,
.protocol-compound-modal .form-select { min-height:44px; background:var(--field-surface); border:1px solid var(--field-border);
  font-weight:500; box-shadow:none; transition:border-color 0.2s, background 0.2s, box-shadow 0.2s; }
.protocol-compound-modal .form-input:hover,
.protocol-compound-modal .form-select:hover { background:var(--field-surface-hover); border-color:var(--field-border-strong); }
.protocol-compound-modal .form-input:focus,
.protocol-compound-modal .form-select:focus { border-color:var(--primary); box-shadow:0 0 0 3px var(--field-ring); }
.protocol-compound-modal .proto-compound-primary-row { margin-top:16px; }
.protocol-compound-modal .proto-compound-day-grid { display:grid; grid-template-columns:repeat(7, minmax(0, 1fr)); gap:8px; margin-top:8px; }
.protocol-compound-modal .compound-name-custom { margin-top:8px; }
.protocol-compound-modal .input-group { min-height:44px; }
.protocol-compound-modal .input-group .input-group-addon {
  min-width:80px;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--field-border);
  color: var(--text-muted);
  font-size:0.8125rem;
  font-weight:600;
}
.protocol-compound-modal .input-group-addon--unit { display:flex; align-items:center; justify-content:center; min-width:64px; }
.protocol-compound-modal .form-hint { line-height:1.45; margin-top:8px; }
.protocol-compound-modal .seg-control { align-items:center; gap:4px; padding:4px; min-height:44px;
  background:var(--control-tray-surface); border:1px solid var(--control-tray-border); border-radius:var(--radius-md); overflow:visible; }
.protocol-compound-modal .seg-btn { min-height:36px; padding:8px 14px; border-radius:var(--radius-sm);
  font-weight:600; transition:background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s; }
.protocol-compound-modal .seg-btn + .seg-btn { border-left:none; }
.protocol-compound-modal .seg-btn.active { background:var(--control-active-surface); color:var(--text); box-shadow:var(--control-active-shadow); }
.protocol-compound-modal .seg-btn:hover:not(.active) { background:rgba(255, 255, 255, 0.04); color:var(--text); }
.protocol-compound-modal .seg-btn:focus-visible { outline:none; box-shadow:0 0 0 3px var(--field-ring); }
.protocol-compound-modal .seg-btn:active { transform:translateY(1px); }
.protocol-compound-modal .seg-btn:disabled { opacity:0.56; cursor:not-allowed; }
.protocol-compound-modal .vial-section-wrap { margin-top:24px; padding:16px; border:1px solid var(--subpanel-border);
  border-radius:var(--radius-md); background:var(--subpanel-surface); }
.protocol-compound-modal .vial-section-header { width:100%; gap:16px; padding:0; border:none; background:transparent;
  color:inherit; text-align:left; border-radius:var(--radius-sm); transition:background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.18s; }
.protocol-compound-modal .vial-section-header:hover { background:rgba(255, 255, 255, 0.02); }
.protocol-compound-modal .vial-section-header:focus-visible { outline:none; box-shadow:0 0 0 3px var(--field-ring); }
.protocol-compound-modal .vial-section-header:active { transform:translateY(1px); }
.protocol-compound-modal .vial-section-copy { display:flex; flex-direction:column; gap:4px; min-width:0; }
.protocol-compound-modal .vial-section-label { color:var(--text); }
.protocol-compound-modal .vial-section-hint { font-size:0.75rem; line-height:1.45; }
.protocol-compound-modal .vial-section-chevron { margin-left:auto; flex-shrink:0; color:var(--text-muted); transition:transform 0.2s ease, color 0.2s ease; }
.protocol-compound-modal .vial-section-wrap.is-open .vial-section-chevron { transform:rotate(180deg); color:var(--text); }
.protocol-compound-modal .vial-section-body { margin-top:16px; padding-top:16px; border-top:1px solid var(--modal-border-soft); }

/* Day-of-week toggle pills */
.protocol-compound-modal .day-toggle { position:relative; cursor:pointer; display:block; }
.protocol-compound-modal .day-toggle-input { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.protocol-compound-modal .day-toggle-btn {
  display:flex; align-items:center; justify-content:center;
  padding:9px 4px; border-radius:100px;
  border:none; font-size:0.7rem; font-weight:600;
  color:var(--text-muted); background: rgba(255, 255, 255, 0.06);
  transition:background 0.15s, color 0.15s;
  user-select:none; -webkit-user-select:none; }
.protocol-compound-modal .day-toggle-input:checked + .day-toggle-btn {
  background:var(--primary); color:#fff; }
.protocol-compound-modal .day-toggle:hover .day-toggle-btn { color:var(--text); background:rgba(255, 255, 255, 0.1); }
.protocol-compound-modal .day-toggle:hover .day-toggle-input:checked + .day-toggle-btn {
  background:var(--primary); color:#fff; }

.protocol-compound-modal .day-toggle-btn {
  min-height:44px;
  padding:8px 4px;
  border-radius:var(--radius-md);
  border:1px solid var(--control-tray-border);
  font-size:0.75rem;
  letter-spacing:0.01em;
  background: rgba(255, 255, 255, 0.04);
  transition:background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.protocol-compound-modal .day-toggle-input:checked + .day-toggle-btn {
  background:linear-gradient(180deg, rgba(139, 92, 246, 0.22) 0%, rgba(139, 92, 246, 0.16) 100%);
  border-color:rgba(139, 92, 246, 0.42);
  color:var(--text);
  box-shadow:0 8px 20px rgba(139, 92, 246, 0.14);
}
.protocol-compound-modal .day-toggle:hover .day-toggle-btn {
  color:var(--text);
  background:rgba(255, 255, 255, 0.07);
  border-color:var(--field-border-strong);
}
.protocol-compound-modal .day-toggle:hover .day-toggle-input:checked + .day-toggle-btn {
  background:linear-gradient(180deg, rgba(139, 92, 246, 0.26) 0%, rgba(139, 92, 246, 0.2) 100%);
  color:var(--text);
}
.protocol-compound-modal .day-toggle-input:focus-visible + .day-toggle-btn { box-shadow:0 0 0 3px var(--field-ring); }
.protocol-compound-modal .day-toggle:active .day-toggle-btn { transform:translateY(1px); }
@media (max-width:768px) { .protocol-compound-modal .day-toggle-btn { font-size:0.6875rem; padding:8px 2px; } }

.settings-section { padding-bottom:24px; margin-bottom:24px;
  border-bottom:1px solid var(--border); }
.settings-section:last-child { border-bottom:none; margin-bottom:0; }
.settings-plan-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-section-title { font-size:0.6875rem; font-weight:500;
  text-transform:uppercase; letter-spacing:0.8px;
  color:var(--text-muted); margin-bottom:16px; }
.settings-plan-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
}
.settings-plan-tier {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.settings-plan-note {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.settings-plan-check {
  color: var(--primary-glow);
}
.settings-plan-card .btn-primary {
  align-self: flex-start;
}
.settings-profile-row { display:flex; flex-direction:column; align-items:flex-start;
  padding:12px 16px; background:var(--bg);
  border:1px solid var(--field-border); border-radius:var(--radius-sm);
  margin-bottom:0; }
.settings-profile-name { font-size:1rem; font-weight:600; color:var(--text); margin-bottom:4px; }
.settings-profile-switch-link {
  font-size:0.75rem;
  font-weight:400;
  color:var(--primary-glow);
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap:4px;
  cursor:pointer;
  background:none;
  border:none;
  padding:0;
}
.settings-profile-switch-select {
  display:none;
  margin-top:8px;
  width:100%;
}
.settings-profile-switch-select.open {
  display:block;
}
/* Profile management action buttons */
.settings-profile-actions {
  display:flex;
  gap:8px;
  margin-top:8px;
}
.settings-profile-action-btn {
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
  font-size:0.8125rem;
  font-weight:500;
  color:var(--text-muted);
  min-height:44px;
  display:flex;
  align-items:center;
}
.settings-profile-action-btn:hover,
.settings-profile-action-btn:focus {
  color:var(--text);
  outline:none;
}
.settings-profile-edit-area {
  width:100%;
  margin-top:8px;
}
.settings-profile-edit-row {
  display:flex;
  align-items:center;
  gap:12px;
  margin-top:8px;
  min-height:36px;
}
.settings-profile-edit-cancel {
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
  font-size:0.8125rem;
  color:var(--text-muted);
}
.settings-profile-edit-cancel:hover,
.settings-profile-edit-cancel:focus {
  color:var(--text);
  outline:none;
}
.settings-profile-confirm {
  font-size:0.8125rem;
  color:var(--text-muted);
  margin-top:8px;
  opacity:1;
  transition:opacity 0.6s ease;
}
.settings-profile-confirm.fade-out {
  opacity:0;
}
.settings-profile-inline-error {
  font-size:0.8125rem;
  color:var(--danger);
  margin-top:6px;
}

/* Password show/hide toggle */
.pwd-toggle {
  position:absolute;
  right:2px;
  bottom:2px;
  width:40px;
  height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:transparent;
  border:none;
  cursor:pointer;
  padding:0;
  color:var(--text-muted);
  opacity:0.8;
}
.pwd-toggle:hover,
.pwd-toggle:focus {
  opacity:1;
  outline:none;
}
.pwd-toggle.revealed {
  color:var(--text);
  opacity:1;
}
.settings-body-params-card {
  background:var(--bg);
  border:1px solid var(--field-border);
  border-radius:var(--radius-md);
  padding:16px;
}
.settings-body-params-card .btn-save-body {
  margin-top:16px;
  width:100%;
}
.btn--loading {
  opacity:0.7;
  pointer-events:none;
  position:relative;
}
.btn--success {
  background:var(--accent) !important;
}
.btn--error {
  background:var(--warning-dim) !important;
  border:1px solid var(--warning) !important;
  color:var(--warning) !important;
}
@keyframes spin { to { transform:rotate(360deg); } }
.btn-spinner {
  width:16px;
  height:16px;
  border:2px solid rgba(255, 255, 255, 0.3);
  border-top-color:rgba(255, 255, 255, 0.9);
  border-radius:50%;
  display:inline-block;
  animation:spin 600ms linear infinite;
  vertical-align:middle;
}
.settings-accordion-toggle {
  display:flex;
  align-items:center;
  min-height:44px;
  cursor:pointer;
  padding:12px 0;
  border-bottom:1px solid var(--border);
  user-select:none;
}
.settings-accordion-toggle .settings-section-title {
  margin-bottom:0;
  flex:1;
}
.settings-accordion-chevron {
  width:16px;
  height:16px;
  color:var(--text-muted);
  margin-left:auto;
  flex-shrink:0;
  transition:transform 200ms ease;
}
.settings-accordion-chevron.expanded {
  transform:rotate(90deg);
}
.settings-accordion-content {
  overflow:hidden;
  max-height:0;
  transition:max-height 300ms ease, padding-top 300ms ease;
  padding-top:0;
}
.settings-accordion-content.expanded {
  max-height:400px;
  padding-top:16px;
}
.settings-btn-row { display:flex; flex-direction:row; gap:8px; flex-wrap:wrap; }
.settings-data-caution {
  font-size:0.75rem;
  color:var(--text-muted);
  margin-top:4px;
}
.settings-account-info { padding:12px 16px; background:var(--bg);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  display:flex; align-items:center; justify-content:space-between; }
.settings-email { font-size:0.875rem; font-weight:500; }
.settings-signed-in-label { font-size:0.75rem; color:var(--text-muted); margin-bottom:2px; }
.settings-status { color: var(--text-muted); font-size: 0.9rem; }
.settings-auth-row { display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap; }
.settings-auth-copy { min-width:0; }
.settings-auth-email { font-size:0.875rem;font-weight:500;word-break:break-word; }
.settings-modal-body { padding:16px;max-width:480px;width:min(92vw,480px); }
.settings-modal-title { margin:0 0 12px; }
.settings-modal-actions { display:flex;gap:8px;justify-content:flex-end;margin-top:16px; }
.settings-empty { color:var(--text-muted);font-size:0.9rem; }
.settings-compound-row { display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid rgba(255,255,255,0.08); }
.settings-compound-name-wrap { min-width:0; }
.settings-compound-name { font-weight:600; }

.onboarding-title { margin: 0 0 12px; }
.onboarding-copy { margin: 0 0 8px; color: var(--text-muted); line-height: 1.6; }
.onboarding-copy--spaced { margin-bottom: 16px; }
.onboarding-day-option { display:flex;align-items:center;gap:6px;font-size:0.8rem;color:var(--text-muted); }
.onboard-day { accent-color: var(--primary); }
.proto-compound-day { accent-color: var(--primary); }
.form-row-onboarding-days { grid-template-columns:repeat(4,minmax(0,1fr));row-gap:10px; }

.ai-content { display:flex;flex-direction:column;height:100%;padding:0; }
.ai-messages { flex:1;overflow-y:auto;padding:16px; }
.ai-message {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  max-width: min(88%, 620px);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
  border: 1px solid var(--border);
}
.ai-message--user {
  margin-left: auto;
  background: var(--primary-dim);
  border-color: rgba(167, 139, 250, 0.45);
}
.ai-message--assistant {
  margin-right: auto;
  background: var(--surface-hover);
}
.ai-welcome-title { font-size:1.1rem;font-weight:600;margin-bottom:8px; }
.ai-welcome-copy { color:var(--text-muted);font-size:0.875rem; }
.ai-input-area {
  display: flex;
  padding: 12px 16px;
  gap: 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-input-field { flex:1;border-radius:var(--radius-sm) 0 0 var(--radius-sm); }
.ai-send-btn { border-radius:0 var(--radius-sm) var(--radius-sm) 0;padding:10px 16px; }
.slider-input { width: 100%; height: 100%; }

/* ===== TIME TRAVEL HEADER ===== */
.date-text--interactive {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition: color 0.2s;
}
.date-text--interactive:hover { color: var(--text); }
.date-chevron {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.date-chevron--open { transform: rotate(180deg); }

/* Calendar dropdown */
.cal-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  min-width: 272px;
  animation: calFadeIn 0.15s ease-out;
}
@keyframes calFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-month-label { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.cal-nav-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: var(--font);
}
.cal-nav-btn:hover { border-color: var(--primary); color: var(--primary); }
.cal-day-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
  gap: 2px;
}
.cal-day-label {
  text-align: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 4px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
}
.cal-cell:not(.cal-cell--empty):not(.cal-cell--disabled):hover {
  background: var(--primary-dim);
  color: var(--text);
}
.cal-cell--today { color: var(--text); font-weight: 700; border: 1px solid rgba(139,92,246,0.35); }
.cal-cell--selected { background: var(--primary) !important; color: #fff !important; font-weight: 700; }
.cal-cell--disabled { color: var(--border); cursor: not-allowed; pointer-events: none; }
.cal-cell--empty { cursor: default; pointer-events: none; }
.cal-today-btn {
  width: 100%;
  margin-top: 10px;
  padding: 7px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}
.cal-today-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Travel mode banner */
.travel-mode-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  font-size: 0.8125rem;
  color: var(--primary-glow);
}
.travel-mode-banner > span { flex: 1; }
.travel-mode-back {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 2px 4px;
  transition: color 0.15s;
  white-space: nowrap;
}
.travel-mode-back:hover { color: var(--text); }

/* Dose list fade on date switch */
@keyframes dosesFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes dosesFadeIn  { from { opacity: 0; } to { opacity: 1; } }
.doses-switching-out { animation: dosesFadeOut 0.1s ease-in forwards; }
.doses-switching-in  { animation: dosesFadeIn 0.2s ease-out forwards; }

/* LOG button — past date ghost style */
.btn-log-past {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary-glow);
  font-weight: 400;
}
.btn-log-past:hover { background: var(--primary-dim); transform: none; }

/* ===== MISSED DOSE NUDGE ===== */
.missed-nudge {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1;
  padding: 10px 14px;
  background: rgba(255, 165, 0, 0.10);
  border: 1px solid rgba(255, 165, 0, 0.2);
  border-radius: var(--radius-md);
  min-height: 48px;
  animation: calFadeIn 0.25s ease-out;
  overflow: hidden;
}
.missed-nudge-icon { color: #FFA500; flex-shrink: 0; display: flex; align-items: center; }
.missed-nudge-text {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text);
  font-weight: 500;
}
.missed-nudge-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-nudge-log {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-glow);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
  border-radius: var(--radius-sm);
  transition: color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn-nudge-log:hover { opacity: 0.85; }
.btn-nudge-dismiss {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px;
  transition: color 0.15s;
}
.btn-nudge-dismiss:hover { color: var(--text); }
@keyframes nudgeCollapse {
  from { opacity: 1; max-height: 80px; padding-top: 12px; padding-bottom: 12px; margin-bottom: 10px; }
  to   { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; border-width: 0; }
}
.missed-nudge--dismissing { animation: nudgeCollapse 0.3s ease-in forwards; }

/* ===== ADD ENTRY MODAL (Insights) ===== */
.add-entry-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: calFadeIn 0.2s ease-out;
}
.add-entry-modal {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalSlideUp 0.2s ease-out;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.add-entry-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.add-entry-modal-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.add-entry-modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  font-family: var(--font);
}
.add-entry-modal-close:hover { border-color: var(--primary); color: var(--text); }

/* + icon button next to Recent Doses header */
.btn-add-entry-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.2s, transform 0.15s;
}
.btn-add-entry-icon:hover { background: var(--primary-hover); transform: scale(1.1); }

/* ===== HISTORY TABLE — DELETE ACTION ===== */
.btn-delete-entry-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--danger-dim);
  border: none;
  color: var(--danger);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, opacity 0.15s;
  opacity: 0;
}
.btn-delete-entry-icon:hover { background: rgba(239, 68, 68, 0.2); transform: scale(1.1); }

.history-delete-cell {
  width: 36px;
  min-width: 36px;
  text-align: right;
  padding-right: 12px !important;
  vertical-align: middle;
}
tr:hover .btn-delete-entry-icon { opacity: 1; }

.history-delete-confirm {
  padding: 10px 16px !important;
  background: rgba(245, 158, 11, 0.07) !important;
}
.history-delete-confirm-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text);
}
.history-delete-confirm-inner span { flex: 1; }

.btn-danger-sm {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--amber);
  background: transparent;
  color: var(--amber);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-danger-sm:hover { background: rgba(245,158,11,0.12); }

.btn-cancel-sm {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-cancel-sm:hover { border-color: var(--text-muted); color: var(--text); }

/* Mobile Responsive */
@media (max-width:768px) {
  .sidebar { display:none; }
  .topbar { padding:0 16px; height:50px; }
  .topbar-brand img { height: 30px; }
  .topbar-brand span { font-size: 1rem; }
  .brand-version { display: none; }
  .topbar-right { gap: 8px; }
  .topbar-user span { display: none; }
  .btn-tool-topbar { padding: 6px 8px; }
  .btn-upgrade-topbar { padding: 0 10px; }
  .main { padding:20px 16px 100px; margin-left:0 !important; overflow-x: hidden; }
  .bottom-tabs { display:flex; }

  #today-nudge-area,
  .today-bento { grid-template-columns:1fr; }
  .proto-top { grid-template-columns:1fr; }
  .insights-layout { grid-template-columns:1fr; }
  #view-protocol {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
    overscroll-behavior-x: none;
    touch-action: pan-y pinch-zoom;
  }
  #view-protocol .protocol-sections,
  #view-protocol .proto-top,
  #view-protocol .proto-top > section,
  #view-protocol .compound-card,
  #view-protocol .card-compact-pad,
  #view-protocol .weekly-grid,
  #view-protocol .schedule-legend {
    min-width: 0;
    max-width: 100%;
  }
  #view-protocol .card-compact-pad {
    overflow-x: hidden;
    overflow-x: clip;
  }
  .greeting { font-size:1.25rem; }
  .today-header { flex-direction:column; gap:8px; }
  .body-grid { grid-template-columns:repeat(3,1fr); }
  .ad-banner {
    align-items: flex-start;
    gap: 16px;
  }
  .ad-banner-right {
    align-items: flex-start;
    padding-right: 48px;
  }
  .ad-banner-dismiss {
    position: absolute;
    top: 12px;
    right: 12px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  /* Chart height — reduce from desktop 350px to a phone-friendly size */
  .chart-area { min-height: 220px; }

  /* H-1: Chart header pills — stack vertically so they don't overflow */
  .chart-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .time-pills { flex-wrap: wrap; margin-bottom: 0; }
  .engine-picker { width: 100%; }
  .engine-picker-btn { width: 100%; justify-content: space-between; }
  .engine-picker-dropdown { left: 0; right: auto; width: 100%; }
  .chart-series-toggles { gap: 6px; }
  .engine-switcher { flex-wrap: wrap; }

  /* H-2: Insights subtabs fill full width */
  .insights-subtabs { width: 100%; }
  .subtab { flex: 1; justify-content: center; padding: 8px 10px; font-size: 0.75rem; }

  /* M-1: Touch targets — icon buttons */
  .btn-add-entry-icon,
  .btn-delete-entry-icon { width: 36px; height: 36px; }
  .pill, .btn-sm { min-height: 44px; }
  /* symptom add row: intentionally below 44px — input is the primary tap target */
  .symptom-add-btn { min-height: 32px; }
  .subtab { min-height: 44px; }

  /* M-2: Weekly schedule dots — slightly smaller on mobile to breathe */
  .day-dot { width: 28px; height: 28px; font-size: 0.5625rem; }
  .weekly-grid { gap: 3px; }
  .schedule-legend { flex-wrap: wrap; align-items: flex-start; gap: 6px 12px; width: 100%; }
  .compound-card-main { gap: 12px; }
  .compound-right { align-items: flex-end; }
  .cycle-duration-control { padding: 12px 8px; }
  .cycle-duration-col .stepper-row { gap: 6px; }
  .cycle-timeline-header { padding: 12px; }
  .cycle-timeline-subcopy { display: none; }
  .cycle-sticky-column { width: 92px; padding-left: 12px; }
  .cycle-scroll-zone { padding-right: 12px; }

  /* M-5: History table scroll hint */
  .card-scroll-x {
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }

  /* M-6: Active press states (touch devices) */
  .btn:active { opacity: 0.75; transform: scale(0.97); }
  .pill:active, .subtab:active, .bottom-tab:active { opacity: 0.7; }
  .dose-card:active, .compound-card:active { border-color: rgba(139,92,246,0.4); }

  /* M-7: Slider hit area — tall track, thin visible bar */
  .slider-track { height: 20px; display: flex; align-items: center; }
  .slider-fill { height: 6px; top: 50%; transform: translateY(-50%); }

  /* L-1: Prevent 300ms tap delay */
  button, .pill, .subtab, .bottom-tab, .dose-card, .cal-cell { touch-action: manipulation; }

  /* L-2: Tomorrow bar truncation */
  #tomorrow-doses { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .pd-origin-tip {
    max-width: 220px;
    text-align: left;
  }
}

@media (max-width: 480px) {
  .btn-tool-topbar .btn-tool-label { display: none; }
  .btn-tool-topbar { padding: 6px 8px; }
}

/* M-3: Missed nudge — wrap on very narrow screens */
@media (max-width: 480px) {
  .missed-nudge { flex-wrap: wrap; }
  .missed-nudge-actions { margin-left: auto; }
  .engine-discovery-nudge .missed-nudge-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
  .pd-header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: flex-start;
  }
  .pd-origin-tip {
    max-width: none;
    flex: 1 1 180px;
  }

  /* M-4: Form rows collapse to single column */
  .form-row { grid-template-columns: 1fr; }
  /* Settings body params: keep weight+age side-by-side - they are a paired unit */
  .settings-body-params-card .form-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-row-3 { grid-template-columns: 1fr; }
  .form-row-onboarding-days { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .settings-btn-row {
    flex-direction:column;
  }
  .settings-btn-row .btn {
    width:100%;
  }
  .settings-plan-card .btn-primary {
    width: 100%;
    align-self: stretch;
  }

  /* H-3: History table mobile column collapse */
  .history-table th:nth-child(2),
  .history-table td:nth-child(2) { display: none; }
  .history-table th:nth-child(5),
  .history-table td:nth-child(5) { display: none; }
  .history-table th:nth-child(6),
  .history-table td:nth-child(6) { display: none; }
  .history-time { display: block; }
  .history-route-site { display: block; }

  /* M-8: History delete button always visible on touch */
  .btn-delete-entry-icon { opacity: 0.5; }
  .btn-delete-entry-icon:active { opacity: 1; }

  /* M-9: Remove right-edge shadow on collapsed mobile history table */
  .card-scroll-x {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

@media (min-width:769px) { .bottom-tabs { display:none; } }
