/* ============================================================================
   Sebas Day Tracker — Modern iOS redesign (2026)
   Loaded LAST. A single cohesive "Clean & calm + iOS blue" system that
   supersedes the old styles.css base and the partial ios-skin.css.
   Light + dark (driven by body.dark-mode, which the app toggles to follow
   the system setting). SF Pro everywhere, flat surfaces, hairline separators.
   ============================================================================ */

:root {
    /* Surfaces */
    --r-bg: #F2F2F7;            /* systemGroupedBackground */
    --r-card: #FFFFFF;          /* elevated card */
    --r-card-2: #FFFFFF;        /* nested card */
    --r-fill: rgba(118,118,128,0.12);   /* control fill (tertiary) */
    --r-fill-2: rgba(118,118,128,0.08);
    /* Labels */
    --r-label: #1C1C1E;
    --r-label-2: rgba(60,60,67,0.60);
    --r-label-3: rgba(60,60,67,0.30);
    --r-sep: rgba(60,60,67,0.16);
    /* Accent + semantics */
    --r-accent: #007AFF;
    --r-accent-press: #0063CC;
    --r-accent-soft: rgba(0,122,255,0.12);
    --r-green: #34C759;
    --r-amber: #FF9500;
    --r-red: #FF3B30;
    --r-purple: #AF52DE;
    --r-green-soft: rgba(52,199,89,0.14);
    --r-amber-soft: rgba(255,149,0,0.16);
    --r-red-soft: rgba(255,59,48,0.14);
    /* Shape */
    --r-card-radius: 18px;
    --r-ctl-radius: 12px;
    --r-tap: 44px;
    --r-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.05);
    --r-shadow-pop: 0 12px 40px rgba(0,0,0,0.16);
    --r-blur: saturate(180%) blur(20px);
    --r-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", sans-serif;
    /* Remap legacy tokens so old rules pick up the new accent automatically */
    --primary: #007AFF;
    --primary-dark: #0063CC;
}

body.dark-mode {
    --r-bg: #000000;
    --r-card: #1C1C1E;
    --r-card-2: #2C2C2E;
    --r-fill: rgba(118,118,128,0.24);
    --r-fill-2: rgba(118,118,128,0.16);
    --r-label: #FFFFFF;
    --r-label-2: rgba(235,235,245,0.60);
    --r-label-3: rgba(235,235,245,0.30);
    --r-sep: rgba(84,84,88,0.55);
    --r-accent: #0A84FF;
    --r-accent-press: #409CFF;
    --r-accent-soft: rgba(10,132,255,0.24);
    --r-green: #30D158;
    --r-amber: #FF9F0A;
    --r-red: #FF453A;
    --r-purple: #BF5AF2;
    --r-green-soft: rgba(48,209,88,0.20);
    --r-amber-soft: rgba(255,159,10,0.20);
    --r-red-soft: rgba(255,69,58,0.22);
    --r-shadow: 0 1px 2px rgba(0,0,0,0.4);
    --r-shadow-pop: 0 16px 50px rgba(0,0,0,0.6);
    --primary: #0A84FF;
}

/* ---------- Base ---------- */
html, body {
    font-family: var(--r-font) !important;
    background: var(--r-bg) !important;
    color: var(--r-label);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body { letter-spacing: -0.01em; }
button, input, textarea, select { font-family: var(--r-font) !important; }
* { -webkit-tap-highlight-color: transparent; }

#app { background: var(--r-bg); }
.main-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 16px calc(120px + var(--safe-bottom, 0px));
    max-width: 640px;
    margin: 0 auto;
}

/* ============================================================
   Large-title header (replaces the cramped top bar visually)
   ============================================================ */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px calc(10px + env(safe-area-inset-top, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--r-bg) 82%, transparent);
    -webkit-backdrop-filter: var(--r-blur);
    backdrop-filter: var(--r-blur);
    border-bottom: 0.5px solid var(--r-sep);
    min-height: 52px;
}
.top-bar .sync-status { font-size: 0.9rem; opacity: 0.7; order: 5; margin-left: 2px; }
.date-selector {
    display: flex; align-items: center; justify-content: center;
    flex: 1; cursor: pointer; gap: 6px; min-width: 0;
}
.current-date {
    font-size: 1.34rem; font-weight: 700; letter-spacing: -0.02em;
    color: var(--r-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.date-arrow {
    width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 999px; background: var(--r-fill); color: var(--r-accent); cursor: pointer;
}
.date-arrow svg { width: 17px; height: 17px; }
.date-arrow:active { background: var(--r-fill-2); transform: scale(0.94); }
.today-btn {
    border: none; background: var(--r-accent); color: #fff; font-weight: 600; font-size: 0.82rem;
    padding: 0 12px; height: 32px; border-radius: 999px; cursor: pointer;
}
.topbar-more {
    width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 999px; background: var(--r-fill); color: var(--r-accent); cursor: pointer;
}
.topbar-more svg { width: 18px; height: 18px; }

/* overflow + food dropdown menus → iOS context menu */
.topbar-menu, .food-menu {
    position: absolute; right: 14px; top: 56px; z-index: 60;
    min-width: 220px; padding: 6px;
    background: var(--r-card); border: 0.5px solid var(--r-sep);
    border-radius: 14px; box-shadow: var(--r-shadow-pop);
    -webkit-backdrop-filter: var(--r-blur); backdrop-filter: var(--r-blur);
}
.topbar-menu-item, .food-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 11px 12px; border: none; background: none; cursor: pointer;
    font-size: 1rem; color: var(--r-label); border-radius: 9px; text-align: left;
}
.topbar-menu-item:active, .food-menu-item:active { background: var(--r-fill); }
.food-menu-item-danger, .food-menu-item.food-menu-item-danger { color: var(--r-red); }
.topbar-menu-version { display: block; padding: 8px 12px 4px; font-size: 0.72rem; color: var(--r-label-3); }

/* ============================================================
   Week at a glance
   ============================================================ */
.week-glance {
    display: flex; gap: 6px; padding: 4px 16px 2px; margin: 0 -16px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.week-glance::-webkit-scrollbar { display: none; }
.week-day {
    flex: 1 0 auto; min-width: 44px; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 6px; border-radius: 14px; cursor: pointer; position: relative;
    background: transparent; transition: background 0.15s;
}
.week-day .week-day-name { font-size: 0.66rem; font-weight: 600; color: var(--r-label-2); text-transform: uppercase; letter-spacing: 0.02em; }
.week-day .week-day-date { font-size: 1.02rem; font-weight: 600; color: var(--r-label); }
.week-day .week-day-emoji { font-size: 0.92rem; line-height: 1; }
.week-day.today-marker .week-day-date { color: var(--r-accent); }
.week-day.selected { background: var(--r-accent); }
.week-day.selected .week-day-name, .week-day.selected .week-day-date { color: #fff; }
.week-day-color { width: 100%; height: 5px; border-radius: 3px; background: var(--r-fill-2); flex-shrink: 0; }
.week-day.selected .week-day-color { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7); }
.week-day-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.week-day-dot.good { background: var(--r-green); }
.week-day-dot.soft { background: var(--r-amber); }
.week-day-dot.wet { background: var(--r-red); }
.week-day.selected .week-day-dot.good, .week-day.selected .week-day-dot.soft, .week-day.selected .week-day-dot.wet { background: #fff; }
.week-day-report-badge { position: absolute; top: 2px; right: 4px; font-size: 0.6rem; }

/* ============================================================
   Cards / sections (shared scaffold — hits 7 sections)
   ============================================================ */
.section, .food-hero, .ai-insights-section, .visual-timeline {
    background: var(--r-card);
    border: none;
    border-radius: var(--r-card-radius);
    box-shadow: var(--r-shadow);
    padding: 16px;
    margin: 0;
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-header.compact { margin-bottom: 12px; }
.section-header h3, .section h3 {
    font-size: 1.06rem; font-weight: 700; letter-spacing: -0.01em; color: var(--r-label); margin: 0;
}
.text-btn {
    border: none; background: none; color: var(--r-accent); font-weight: 600; font-size: 0.95rem;
    cursor: pointer; padding: 4px 2px; display: inline-flex; align-items: center; gap: 4px;
}
.text-btn:active { opacity: 0.6; }

/* ---------- Buttons (shared) ---------- */
.btn-primary {
    background: var(--r-accent); color: #fff; border: none; border-radius: var(--r-ctl-radius);
    font-weight: 600; font-size: 1rem; min-height: var(--r-tap); padding: 0 20px; cursor: pointer;
}
.btn-primary:active { background: var(--r-accent-press); }
.btn-primary:disabled { opacity: 0.45; }
.btn-ghost {
    background: var(--r-fill); color: var(--r-accent); border: none; border-radius: var(--r-ctl-radius);
    font-weight: 600; font-size: 1rem; min-height: var(--r-tap); padding: 0 20px; cursor: pointer;
}
.btn-ghost:active { background: var(--r-fill-2); }

/* ============================================================
   Food hero — de-gradient → clean tinted hero card
   ============================================================ */
.food-hero {
    position: relative; overflow: hidden;
    background: var(--r-card) !important;
    color: var(--r-label);
}
.food-hero::before {
    content: ""; position: absolute; inset: 0; opacity: 0.10; pointer-events: none;
    background: var(--food-accent, var(--r-accent));
}
.food-hero.chicken { --food-accent: var(--r-green); }
.food-hero.beef    { --food-accent: var(--r-amber); }
.food-hero.turkey  { --food-accent: var(--r-purple); }
.food-hero.pork    { --food-accent: var(--r-accent); }
/* Solid color band across the top of the food card — the day's color, loud and
   named, with auto-contrast ink so it's legible for low-vision use. */
.food-hero-header {
    display: flex; align-items: center; gap: 10px; position: relative;
    margin: -16px -16px 14px; padding: 11px 16px;
    background: var(--food-color, var(--r-accent));
    color: var(--food-color-ink, #fff);
    border-radius: var(--r-card-radius) var(--r-card-radius) 0 0;
}
.food-hero-day { flex: 1 1 auto; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-hero-colorname {
    flex: 0 0 auto; white-space: nowrap;
    font-size: 1.06rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: inherit;
}
.food-hero-today {
    font-size: 0.66rem; font-weight: 800; text-transform: uppercase; color: inherit;
    background: rgba(255, 255, 255, 0.30); padding: 3px 9px; border-radius: 999px;
}
.food-hero-menu {
    width: 32px; height: 32px; border: none; border-radius: 999px;
    background: rgba(255, 255, 255, 0.22); color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.food-hero-menu svg { width: 18px; height: 18px; }
.food-hero-body { position: relative; }
.food-hero-emoji { font-size: 2.2rem; line-height: 1; display: block; margin: 8px 0 2px; }
.food-hero-protein { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; color: var(--r-label); margin: 0 0 12px; }
.food-hero-pills { display: flex; flex-direction: column; gap: 10px; }
.food-pill {
    background: var(--r-fill); border-radius: 14px; padding: 12px 14px;
    display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
    min-width: 0;
}
.food-pill-icon { font-size: 1.5rem; line-height: 1; }
.food-pill-label { font-size: 0.66rem; font-weight: 700; color: var(--r-label-2); text-transform: uppercase; letter-spacing: 0.04em; }
.food-pill-value { font-size: 1.02rem; font-weight: 600; color: var(--r-label); max-width: 100%; overflow-wrap: break-word; }
/* Color "sticker" next to the protein — mirrors the physical colored dot put on
   the food. Inherits the day's --food-color set on the hero. */
.food-protein-value-row { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.food-color-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; background: var(--food-color, var(--r-accent)); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28); }
.food-hero-more {
    margin-top: 12px; width: 100%; border: none; background: var(--r-fill); color: var(--r-accent);
    border-radius: var(--r-ctl-radius); min-height: 40px; font-weight: 600; font-size: 0.92rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.food-more-chevron { width: 16px; height: 16px; transition: transform 0.2s; }
.food-hero-more.open .food-more-chevron, .food-more-details:not(.hidden) ~ * .food-more-chevron { transform: rotate(180deg); }
.food-hero-more-details { margin-top: 10px; display: flex; flex-direction: column; gap: 1px; border-radius: 12px; overflow: hidden; }
.food-detail-row { display: flex; justify-content: space-between; padding: 11px 12px; background: var(--r-fill-2); font-size: 0.92rem; }
.food-detail-row span:first-child { color: var(--r-label-2); }
.food-detail-row span:last-child { color: var(--r-label); font-weight: 500; }
.food-hero-prep {
    margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--r-accent-soft);
    font-size: 0.9rem; color: var(--r-label); display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   Medicines — pills + per-period header + manager
   ============================================================ */
.time-blocks { display: flex; flex-direction: column; gap: 16px; }
.time-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.time-label { display: inline-flex; align-items: center; gap: 7px; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--r-label-2); margin: 0; }
.time-label .period-emoji { font-size: 0.95rem; }
.med-markall {
    border: none; background: var(--r-fill); color: var(--r-accent); font-size: 0.78rem; font-weight: 600;
    min-height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
}
.med-markall.done { background: var(--r-green-soft); color: var(--r-green); }
.med-pills { display: flex; flex-direction: column; gap: 8px; }
.med-pill {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
    background: var(--r-fill-2); border: none; border-radius: 14px; min-height: var(--r-tap);
    transition: background 0.15s;
}
.med-pill:active { background: var(--r-fill); }
.med-pill .check-icon {
    width: 24px; height: 24px; flex: none; border-radius: 50%;
    border: 2px solid var(--r-label-3); position: relative; transition: all 0.15s;
}
.med-pill.given { background: var(--r-green-soft); }
.med-pill.given .check-icon { background: var(--r-green); border-color: var(--r-green); }
.med-pill.given .check-icon::after {
    content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
    border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.med-content { flex: 1; min-width: 0; }
.med-name { font-size: 1rem; font-weight: 600; color: var(--r-label); display: block; }
.med-time { font-size: 0.7rem; font-weight: 600; color: var(--r-accent); background: var(--r-accent-soft); padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.med-dose { font-size: 0.82rem; color: var(--r-label-2); margin-top: 2px; }
.med-pill.given .med-dose { color: var(--r-label-2); }
.meds-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px; color: var(--r-label-3); }

/* ============================================================
   Behaviors — chips
   ============================================================ */
.behavior-container { display: flex; flex-direction: column; gap: 14px; }
.behavior-category-name { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--r-label-2); margin-bottom: 8px; }
.behavior-chips-scroll { display: flex; flex-wrap: wrap; gap: 8px; }
.behavior-chip {
    border: none; background: var(--r-fill); color: var(--r-label); border-radius: 999px;
    min-height: 36px; padding: 0 14px; font-size: 0.9rem; font-weight: 500; cursor: pointer;
}
.behavior-chip.active { background: var(--r-accent); color: #fff; }
.behavior-chip.ideal.active { background: var(--r-green); }

/* ============================================================
   Sleep — segmented control
   ============================================================ */
.sleep-buttons { display: inline-flex; gap: 4px; padding: 3px; background: var(--r-fill); border-radius: 12px; }
.sleep-btn {
    border: none; background: transparent; color: var(--r-label); font-weight: 600; font-size: 0.9rem;
    min-height: 34px; padding: 0 16px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.sleep-btn.selected { background: var(--r-card); box-shadow: var(--r-shadow); color: var(--r-green); }
.sleep-btn.bad.selected { color: var(--r-red); }

/* ============================================================
   Potty tracker — quick buttons, custom time, training, log
   ============================================================ */
.potty-buttons { display: flex; gap: 8px; }
.potty-btn {
    flex: 1; border: none; border-radius: var(--r-ctl-radius); min-height: 40px; cursor: pointer;
    font-size: 0.88rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--r-green-soft); color: var(--r-green);
}
.potty-btn.soft { background: var(--r-amber-soft); color: var(--r-amber); }
.potty-btn.wet  { background: var(--r-red-soft); color: var(--r-red); }
.potty-btn:active { filter: brightness(0.96); }
.potty-custom-time { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.custom-time-label { font-size: 0.82rem; color: var(--r-label-2); }
.time-input, input[type="time"].time-input {
    border: 0.5px solid var(--r-sep); background: var(--r-fill-2); color: var(--r-label);
    border-radius: 10px; min-height: 36px; padding: 0 10px; font-family: var(--r-font);
}
.potty-btn-small {
    width: 40px; height: 36px; border: none; border-radius: 10px; cursor: pointer; font-size: 1rem;
    background: var(--r-green-soft);
}
.potty-btn-small.soft { background: var(--r-amber-soft); }
.potty-btn-small.wet { background: var(--r-red-soft); }
.potty-training { margin-top: 14px; padding-top: 14px; border-top: 0.5px solid var(--r-sep); }
.potty-training-label { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--r-label-2); margin-bottom: 10px; }
.pt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-item { display: inline-flex; align-items: center; gap: 4px; }
.pt-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px;
    background: var(--r-fill); color: var(--r-label); border: none; font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.pt-chip.on { background: var(--r-accent); color: #fff; }
.pt-chip.on.pt_accident { background: var(--r-red); }
.pt-chip-emoji { font-size: 1rem; }
.pt-count { min-width: 20px; height: 20px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: rgba(255,255,255,0.28); color: #fff; font-size: 0.78rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pt-dec { width: 30px; height: 30px; flex: none; border-radius: 50%; border: none; background: var(--r-fill); color: var(--r-label-2); font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.bowel-log { margin-top: 12px; }
.bowel-entries { display: flex; flex-wrap: wrap; gap: 8px; }
.bowel-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
    background: var(--r-green-soft); color: var(--r-label); font-size: 0.82rem;
}
.bowel-chip.type-soft { background: var(--r-amber-soft); }
.bowel-chip.type-bad { background: var(--r-red-soft); }
.bowel-chip .del { cursor: pointer; opacity: 0.5; margin-left: 2px; }
.empty-message { color: var(--r-label-3); font-size: 0.9rem; }

/* ============================================================
   Avoid lists
   ============================================================ */
.avoid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.avoid-box { background: var(--r-fill-2); border-radius: 14px; padding: 12px; }
.avoid-header { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--r-label-2); margin-bottom: 8px; }
.avoid-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.avoid-list li { font-size: 0.84rem; color: var(--r-label); padding-left: 14px; position: relative; }
.avoid-list li::before { content: "•"; position: absolute; left: 2px; color: var(--r-red); }

/* ============================================================
   Notes / Growth / pattern alerts / AI
   ============================================================ */
.daily-notes-input {
    width: 100%; border: 0.5px solid var(--r-sep); background: var(--r-fill-2); color: var(--r-label);
    border-radius: 12px; padding: 12px; font-size: 1rem; font-family: var(--r-font); resize: vertical; min-height: 72px;
}
.save-status { font-size: 0.78rem; color: var(--r-label-3); }
.save-status.saved { color: var(--r-green); }
.growth-display .growth-empty { color: var(--r-label-3); font-size: 0.9rem; }
.growth-stats { display: flex; gap: 10px; }
.growth-stat { flex: 1; background: var(--r-fill-2); border-radius: 14px; padding: 12px; text-align: center; }
.growth-value { font-size: 1.4rem; font-weight: 700; color: var(--r-label); }
.growth-label { font-size: 0.74rem; color: var(--r-label-2); text-transform: uppercase; letter-spacing: 0.03em; }
.growth-date { font-size: 0.78rem; color: var(--r-label-3); margin-top: 8px; }
.pattern-alerts { display: flex; flex-direction: column; gap: 8px; }
.pattern-alert {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
    background: var(--r-amber-soft); color: var(--r-label); font-size: 0.9rem;
}
.pattern-alert.danger { background: var(--r-red-soft); }
.pattern-alert.info { background: var(--r-accent-soft); }
.pattern-alert-icon { font-size: 1.1rem; }
.ai-insights-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ai-insights-title { font-size: 1.06rem; font-weight: 700; color: var(--r-label); }
.ai-refresh-btn { border: none; background: var(--r-fill); color: var(--r-accent); font-weight: 600; font-size: 0.85rem; min-height: 32px; padding: 0 14px; border-radius: 999px; cursor: pointer; }
.ai-insights-content { font-size: 0.95rem; color: var(--r-label); line-height: 1.5; }
.ai-insights-loading { display: flex; align-items: center; gap: 10px; color: var(--r-label-2); }

/* ============================================================
   Visual timeline
   ============================================================ */
.timeline-title { font-size: 1.06rem; font-weight: 700; color: var(--r-label); margin-bottom: 12px; }
.timeline-grid { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.timeline-grid::-webkit-scrollbar { display: none; }
.timeline-day { flex: 0 0 auto; width: 56px; background: var(--r-fill-2); border-radius: 14px; padding: 10px 6px; text-align: center; }
.timeline-day.today { background: var(--r-accent); }
.timeline-day.today .timeline-date, .timeline-day.today .timeline-food { color: #fff; }
.timeline-date { font-size: 0.7rem; font-weight: 600; color: var(--r-label-2); }
.timeline-food { font-size: 1.1rem; margin: 4px 0; }
.timeline-indicators { display: flex; gap: 3px; justify-content: center; }
.timeline-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--r-label-3); }
.timeline-dot.wet { background: var(--r-red); } .timeline-dot.soft { background: var(--r-amber); } .timeline-dot.good, .timeline-dot.normal { background: var(--r-green); }

/* ============================================================
   Bottom nav + FAB + quick menu
   ============================================================ */
.bottom-nav {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 60;
    width: 100%; max-width: 480px;
    display: flex; align-items: stretch; justify-content: space-around;
    padding: 6px 8px calc(6px + var(--safe-bottom, 0px));
    background: color-mix(in srgb, var(--r-card) 80%, transparent);
    -webkit-backdrop-filter: var(--r-blur); backdrop-filter: var(--r-blur);
    border-top: 0.5px solid var(--r-sep);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: none; background: none; cursor: pointer; color: var(--r-label-3); padding: 6px 0;
}
.nav-item svg { width: 25px; height: 25px; stroke-width: 1.8; }
.nav-item span { font-size: 0.62rem; font-weight: 500; }
.nav-item.active { color: var(--r-accent); }
.floating-fab {
    position: fixed; right: max(18px, calc(50% - 392px)); bottom: calc(76px + var(--safe-bottom, 0px)); z-index: 61;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--r-accent); color: #fff; box-shadow: 0 8px 24px rgba(0,122,255,0.4);
    display: inline-flex; align-items: center; justify-content: center;
}
.fab-plus { font-size: 1.9rem; font-weight: 300; line-height: 1; }
.floating-fab:active { transform: scale(0.92); }
.quick-menu-content {
    position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-bottom, 0px)); z-index: 80;
    background: var(--r-card); border-radius: 18px; padding: 8px; box-shadow: var(--r-shadow-pop);
    display: flex; flex-direction: column; gap: 2px;
}
.quick-menu-content button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 14px; border: none;
    background: none; cursor: pointer; font-size: 1.02rem; color: var(--r-label); border-radius: 12px; text-align: left;
}
.quick-menu-content button:active { background: var(--r-fill); }

/* ============================================================
   Responsive — tablet & desktop actually use the width.
   Phone (default, single column) is unchanged.
   ============================================================ */
@media (min-width: 1000px) {
    /* Out of the narrow phone column. */
    #app { max-width: 1120px; }

    /* Food hero headlines the day full-width; its two pills sit side by side. */
    .food-hero-pills { flex-direction: row; }
    .food-hero-pills .food-pill { flex: 1; min-width: 0; }

    /* The day's section cards flow into two balanced columns (cards never split). */
    .main-grid {
        max-width: none;
        display: block;
        column-count: 2;
        column-gap: 18px;
    }
    .main-grid > .section {
        break-inside: avoid;
        -webkit-column-break-inside: avoid;
        margin: 0 0 16px;
    }

    /* Wider centered nav pill; keep the FAB by the content's right edge. */
    .bottom-nav { max-width: 560px; border-radius: 22px 22px 0 0; }
    .floating-fab { right: max(24px, calc(50% - 544px)); }
}

/* ============================================================
   Modals — shared scaffold (hits every modal)
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal-sheet {
    position: relative; z-index: 1; width: 100%; max-width: 640px;
    background: var(--r-bg); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + var(--safe-bottom, 0px));
    max-height: 92vh; overflow-y: auto; box-shadow: var(--r-shadow-pop);
}
.modal-sheet-full { min-height: 86vh; }
.modal-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--r-label-3); margin: 8px auto 14px; }
.modal-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; color: var(--r-label); margin: 0 0 16px; }
.modal-subtitle { font-size: 0.9rem; color: var(--r-label-2); margin: -10px 0 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { flex: 1; }
.modal-tabs { display: inline-flex; gap: 4px; padding: 3px; background: var(--r-fill); border-radius: 12px; margin-bottom: 16px; width: 100%; }
.tab-btn { flex: 1; border: none; background: none; color: var(--r-label-2); font-weight: 600; font-size: 0.92rem; min-height: 34px; border-radius: 9px; cursor: pointer; }
.tab-btn.active { background: var(--r-card); color: var(--r-label); box-shadow: var(--r-shadow); }

/* Bowel modal options */
.bowel-options { display: flex; flex-direction: column; gap: 8px; }
.bowel-option {
    display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--r-sep);
    background: var(--r-card); border-radius: 14px; cursor: pointer; font-size: 1rem; color: var(--r-label);
}
.bowel-option .option-emoji { font-size: 1.3rem; }
.bowel-option.selected { border-color: var(--r-accent); background: var(--r-accent-soft); }
.bowel-option.soft.selected { border-color: var(--r-amber); background: var(--r-amber-soft); }
.bowel-option.warning.selected { border-color: var(--r-red); background: var(--r-red-soft); }
.note-input textarea, #bowelNote, #noteInput textarea {
    width: 100%; border: 0.5px solid var(--r-sep); background: var(--r-fill-2); color: var(--r-label);
    border-radius: 12px; padding: 12px; font-family: var(--r-font); font-size: 1rem; resize: vertical;
}

/* Med manager (kept from prior work, retokenized) */
.med-manager { display: flex; flex-direction: column; }
.med-mgr-top { display: flex; align-items: center; justify-content: space-between; }
.med-mgr-done { border: none; background: none; color: var(--r-accent); font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.med-mgr-tools { display: flex; gap: 8px; margin: 12px 0 14px; }
.med-search { flex: 1; min-height: var(--r-tap); padding: 0 14px; background: var(--r-fill); border: none; border-radius: var(--r-ctl-radius); font-size: 1rem; color: var(--r-label); }
.med-add-btn { min-height: var(--r-tap); padding: 0 16px; background: var(--r-accent); color: #fff; border: none; border-radius: var(--r-ctl-radius); font-weight: 600; cursor: pointer; white-space: nowrap; }
.med-mgr-list { flex: 1; overflow-y: auto; }
.med-card { background: var(--r-card); border: 0.5px solid var(--r-sep); border-radius: 16px; margin-bottom: 10px; overflow: hidden; }
.med-card.expanded { border-color: var(--r-accent); }
.med-card.paused { opacity: 0.6; }
.med-card-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: var(--r-tap); cursor: pointer; }
.med-drag { color: var(--r-label-3); }
.med-card-icon { font-size: 1.4rem; }
.med-card-main { flex: 1; min-width: 0; }
.med-card-name { font-size: 1rem; font-weight: 600; color: var(--r-label); }
.med-card-sched { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.med-chip-mini { font-size: 0.72rem; color: var(--r-label-2); background: var(--r-fill); padding: 2px 8px; border-radius: 999px; }
.med-unscheduled { font-size: 0.75rem; color: var(--r-label-3); font-style: italic; }
.med-paused-tag { font-size: 0.62rem; font-weight: 700; color: var(--r-amber); text-transform: uppercase; margin-left: 6px; }
.med-card-caret { color: var(--r-label-3); font-size: 1.3rem; }
.med-edit { padding: 4px 14px 16px; border-top: 0.5px solid var(--r-sep); }
.med-edit-row2 { display: flex; gap: 8px; margin: 12px 0; }
.med-icon-input { width: 56px; text-align: center; font-size: 1.3rem; min-height: var(--r-tap); border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); }
.med-name-input { flex: 1; min-height: var(--r-tap); padding: 0 12px; font-size: 1rem; border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); }
.med-edit-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--r-label-2); margin: 16px 0 8px; }
.med-when-list { display: flex; flex-direction: column; gap: 8px; }
.med-when-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.med-when-chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; min-width: 130px; background: var(--r-fill); color: var(--r-label-2); border: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.med-when-chip.on { background: var(--r-accent); color: #fff; }
.med-when-amount { flex: 1; min-width: 110px; min-height: 40px; padding: 0 12px; border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); }
.med-when-time input[type="time"] { min-height: 40px; padding: 0 8px; border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); }
.med-time-add { min-height: 40px; padding: 0 12px; background: none; border: 1px dashed var(--r-label-3); border-radius: var(--r-ctl-radius); color: var(--r-accent); cursor: pointer; }
.med-time-clear { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--r-fill); color: var(--r-label-2); cursor: pointer; }
/* Date-aware scheduling: med window + per-period dose ramps */
.med-edit-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--r-label-3); }
.med-dates { display: flex; gap: 12px; flex-wrap: wrap; }
.med-date-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; font-weight: 600; color: var(--r-label-2); }
.med-date-field input[type="date"] { min-height: 40px; padding: 0 10px; border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); font-size: 0.9rem; }
.med-ramp { flex-basis: 100%; width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; margin-top: 2px; background: var(--r-fill); border-radius: 10px; }
.med-ramp-row { display: flex; align-items: center; gap: 6px; }
.med-ramp-tag { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--r-label-2); min-width: 30px; }
.med-ramp-date { min-height: 34px; padding: 0 8px; border: 0.5px solid var(--r-sep); border-radius: 8px; background: var(--r-card); color: var(--r-label); font-size: 0.82rem; }
.med-ramp-amt { flex: 1; min-width: 84px; min-height: 34px; padding: 0 10px; border: 0.5px solid var(--r-sep); border-radius: 8px; background: var(--r-card); color: var(--r-label); font-size: 0.85rem; }
.med-ramp-dash { color: var(--r-label-2); }
.med-ramp-del { width: 28px; min-height: 28px; flex-shrink: 0; border: none; border-radius: 8px; background: var(--r-fill-2); color: var(--r-label-2); font-size: 1rem; line-height: 1; cursor: pointer; }
.med-ramp-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.med-ramp-add { background: none; border: none; color: var(--r-accent); font-weight: 600; font-size: 0.82rem; cursor: pointer; padding: 2px 0; }
.med-ramp-add.ghost { color: var(--r-label-2); }
.med-chip-dated { background: rgba(0,122,255,.12); color: var(--r-accent); }
.med-notes { width: 100%; border: 0.5px solid var(--r-sep); border-radius: var(--r-ctl-radius); background: var(--r-fill-2); color: var(--r-label); padding: 10px 12px; font-family: var(--r-font); font-size: 0.9rem; resize: vertical; }
.med-edit-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }
.med-active-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--r-label); }
.med-active-toggle input { width: 22px; height: 22px; accent-color: var(--r-green); }
.med-delete-btn { border: none; background: none; color: var(--r-red); font-weight: 600; cursor: pointer; }
.med-mgr-empty { text-align: center; color: var(--r-label-3); padding: 40px 20px; }

/* History / trends */
.history-summary, .history-content { display: flex; flex-direction: column; gap: 10px; }
.history-summary { flex-direction: row; gap: 10px; }
.summary-stat { flex: 1; background: var(--r-fill-2); border-radius: 14px; padding: 12px; text-align: center; }
.summary-stat.warning { background: var(--r-amber-soft); }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--r-label); }
.stat-label { font-size: 0.72rem; color: var(--r-label-2); }
.history-day { background: var(--r-fill-2); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.history-day.has-bad { background: var(--r-red-soft); }
.day-header { display: flex; justify-content: space-between; }
.day-date { font-weight: 600; color: var(--r-label); }
.day-count { color: var(--r-label-2); font-size: 0.85rem; }
.type-chip { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 0.74rem; background: var(--r-fill); margin: 4px 4px 0 0; }
.trend-card { background: var(--r-fill-2); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.trend-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.trend-emoji { font-size: 1.3rem; } .trend-title { font-weight: 700; color: var(--r-label); } .trend-days { color: var(--r-label-2); font-size: 0.8rem; margin-left: auto; }
.trend-section-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--r-label-2); margin: 8px 0 6px; }
.trend-metric { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.metric-label { font-size: 0.8rem; color: var(--r-label-2); width: 80px; }
.metric-bar { flex: 1; height: 8px; background: var(--r-fill); border-radius: 999px; overflow: hidden; }
.metric-fill { height: 100%; background: var(--r-green); border-radius: 999px; }
.metric-fill.warning { background: var(--r-amber); } .metric-fill.bad { background: var(--r-red); }
.metric-value { font-size: 0.8rem; color: var(--r-label); width: 36px; text-align: right; }

/* Date picker / schedule grid / growth / food editor / day override */
.date-picker-input, .date-picker-content input[type="date"] {
    width: 100%; border: 0.5px solid var(--r-sep); background: var(--r-fill-2); color: var(--r-label);
    border-radius: 12px; min-height: var(--r-tap); padding: 0 12px; font-family: var(--r-font); font-size: 1rem;
}
.date-quick-buttons { display: flex; gap: 8px; margin-top: 12px; }
.date-quick-buttons .btn-ghost { flex: 1; }
.schedule-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.schedule-day { background: var(--r-fill-2); border-radius: 14px; padding: 10px; display: flex; gap: 8px; align-items: center; }
.schedule-day.today { background: var(--r-accent-soft); }
.schedule-day.skipped { opacity: 0.5; }
.schedule-day-emoji { font-size: 1.3rem; }
.schedule-day-name { font-size: 0.82rem; font-weight: 600; color: var(--r-label); }
.schedule-day-override { font-size: 0.68rem; color: var(--r-amber); }
.growth-form, .food-editor-form { display: flex; flex-direction: column; gap: 12px; }
.growth-input-row, .food-editor-row { display: flex; flex-direction: column; gap: 6px; }
.growth-input-row label, .food-editor-row label { font-size: 0.8rem; font-weight: 600; color: var(--r-label-2); }
.growth-input-row input, .food-editor-row input {
    border: 0.5px solid var(--r-sep); background: var(--r-fill-2); color: var(--r-label);
    border-radius: 10px; min-height: var(--r-tap); padding: 0 12px; font-family: var(--r-font); font-size: 1rem;
}
.override-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.override-btn { min-height: var(--r-tap); border: 1.5px solid var(--r-sep); background: var(--r-card); border-radius: 12px; font-weight: 600; color: var(--r-label); cursor: pointer; }
.override-btn.chicken { color: var(--r-green); } .override-btn.beef { color: var(--r-amber); }
.override-btn.turkey { color: var(--r-purple); } .override-btn.pork { color: var(--r-accent); }
.override-btn.skip { color: var(--r-label-2); } .override-btn.reset { color: var(--r-red); }
.resume-checkbox { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--r-label); }
.resume-checkbox input { width: 20px; height: 20px; accent-color: var(--r-accent); }

/* ============================================================
   Toasts / PIN / loading / install banner
   ============================================================ */
.toast-container { position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-bottom, 0px)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
    pointer-events: auto; background: rgba(40,40,42,0.96); color: #fff; padding: 12px 18px; border-radius: 999px;
    font-size: 0.9rem; box-shadow: var(--r-shadow-pop); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    display: flex; align-items: center; gap: 14px; max-width: 88%;
}
.toast-undo-btn { background: none; border: none; color: #4da3ff; font-weight: 700; cursor: pointer; }
.toast-exit { opacity: 0; transform: translateY(8px); transition: all 0.25s; }
.pin-gate { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; background: var(--r-bg); }
.pin-container { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; }
.pin-icon-img { width: 72px; height: 72px; border-radius: 18px; }
.pin-title { font-size: 1.5rem; font-weight: 700; color: var(--r-label); margin: 0; }
.pin-subtitle { font-size: 0.95rem; color: var(--r-label-2); margin: 0; }
.pin-dots { display: flex; gap: 18px; margin: 16px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--r-label-3); transition: all 0.15s; }
.pin-dot.filled { background: var(--r-accent); border-color: var(--r-accent); }
.pin-dots.shake { animation: pinShake 0.4s; }
.pin-dots.error .pin-dot { border-color: var(--r-red); }
@keyframes pinShake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-8px)} 40%,80%{transform:translateX(8px)} }
.pin-input-hidden { position: absolute; opacity: 0; pointer-events: none; }
.pin-error { color: var(--r-red); font-size: 0.85rem; }
.loading-overlay { position: fixed; inset: 0; z-index: 250; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: color-mix(in srgb, var(--r-bg) 70%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--r-fill); border-top-color: var(--r-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--r-label-2); }
.install-banner { position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-bottom, 0px)); z-index: 120; background: var(--r-card); border-radius: 16px; padding: 14px 16px; box-shadow: var(--r-shadow-pop); display: flex; align-items: center; gap: 12px; }
.install-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.install-btn { background: var(--r-accent); color: #fff; border: none; border-radius: 999px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.dismiss-btn { background: var(--r-fill); border: none; border-radius: 50%; width: 32px; height: 32px; color: var(--r-label-2); cursor: pointer; }
