/* ==========================================================
   Kétogenic — Application
   ========================================================== */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid var(--border); background: var(--bg-2); backdrop-filter: blur(20px); z-index: 50;
}
.sidebar .logo { padding: 0 8px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 14px 12px 6px; }
.side-nav button {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; text-align: left;
  transition: background .25s, color .25s, transform .25s var(--ease);
}
.side-nav button .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; background: rgba(31,38,28,.04); transition: background .25s, transform .4s var(--ease-spring); }
.side-nav button:hover { background: var(--surface); color: var(--text); }
.side-nav button:hover .ic { transform: scale(1.1) rotate(-6deg); }
.side-nav button.active { background: linear-gradient(90deg, rgba(69,86,44,.14), rgba(69,86,44,.02)); color: var(--text); }
.side-nav button.active .ic { background: var(--lime); }
.side-nav button.active::before { content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--lime); box-shadow: 0 0 14px var(--lime); }
.side-nav .pro-tag { margin-left: auto; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: var(--grad-warm); color: var(--on-accent); }

.upgrade {
  margin-top: auto; padding: 20px; border-radius: var(--r-md); position: relative; overflow: hidden;
  background: linear-gradient(150deg, rgba(217,164,65,.16), rgba(196,98,58,.06)); border: 1px solid rgba(217,164,65,.3);
}
.upgrade::after { content: "⭐"; position: absolute; right: -6px; top: -10px; font-size: 64px; opacity: .14; transform: rotate(12deg); }
.upgrade b { display: block; font-size: 15px; margin-bottom: 4px; }
.upgrade p { margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.upgrade .btn { width: 100%; background: var(--grad-warm); color: var(--on-accent); }

/* Main */
.main { padding: 26px 34px 80px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.topbar h1 { font-size: clamp(26px, 3vw, 36px); margin: 0; }
.topbar .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.streak { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: rgba(196,98,58,.1); border: 1px solid rgba(196,98,58,.25); font-weight: 700; font-size: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad-brand); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; cursor: pointer; border: 0; }

/* Views */
.view { display: none; }
.view.active { display: block; animation: viewIn .6s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } }
.view.active .stagger > * { animation: viewIn .7s var(--ease) both; }
.view.active .stagger > *:nth-child(2) { animation-delay: .05s; }
.view.active .stagger > *:nth-child(3) { animation-delay: .1s; }
.view.active .stagger > *:nth-child(4) { animation-delay: .15s; }
.view.active .stagger > *:nth-child(5) { animation-delay: .2s; }
.view.active .stagger > *:nth-child(6) { animation-delay: .25s; }

.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-side { grid-template-columns: 380px 1fr; align-items: start; }
.g-side-r { grid-template-columns: 1fr 360px; align-items: start; }
.span-2 { grid-column: span 2; }
.panel { padding: 24px; }
.panel h3 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.panel .panel-sub { color: var(--text-3); font-size: 13px; margin: 0 0 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head .panel-sub { margin: 0; }
.form-stack { display: grid; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-stack .segmented { flex-wrap: nowrap; }
.form-stack .segmented button { padding: 8px 4px; font-size: 12.5px; min-width: 0; }
.modal, .food-grid, .plate, .entries { scrollbar-width: thin; scrollbar-color: rgba(31,38,28,.12) transparent; }
.side-nav { scrollbar-width: thin; scrollbar-color: rgba(31,38,28,.1) transparent; }

/* KPI */
.kpi { padding: 20px; position: relative; overflow: hidden; }
.kpi .k-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; margin-bottom: 14px; }
.kpi .k-label { font-size: 13px; color: var(--text-3); font-weight: 600; }
.kpi .k-val { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .k-val small { font-size: 15px; font-weight: 600; color: var(--text-3); margin-left: 4px; }
.kpi .k-foot { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.kpi .bar { height: 6px; border-radius: 99px; background: rgba(31,38,28,.07); margin-top: 12px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; border-radius: inherit; background: var(--grad-brand); width: 0; transition: width 1.2s var(--ease); }

/* Hero banner in dashboard */
.welcome {
  padding: 30px; border-radius: var(--r-xl); position: relative; overflow: hidden;
  background: radial-gradient(600px 300px at 90% 0%, rgba(69,86,44,.18), transparent 60%), linear-gradient(140deg, rgba(232,220,198,.6), rgba(31,38,28,.02));
  border: 1px solid rgba(69,86,44,.2); display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
}
.welcome h2 { font-size: clamp(24px, 3vw, 34px); margin: 8px 0; }
.welcome p { margin: 0; color: var(--text-2); max-width: 520px; }

/* Macro rings */
.rings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.ring-item { text-align: center; }
.ring-box { position: relative; width: 100%; max-width: 120px; margin: 0 auto 10px; aspect-ratio: 1; }
.ring-box svg { width: 100%; height: 100%; }
.ring-box .rc { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-box .rc b { font-size: 20px; font-weight: 800; display: block; line-height: 1; }
.ring-box .rc span { font-size: 11px; color: var(--text-3); }
.ring-item .rl { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* Checklist */
.checklist { display: grid; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 14px; cursor: pointer;
  background: rgba(31,38,28,.025); border: 1px solid var(--border); transition: background .25s, border-color .25s;
  user-select: none;
}
.check:hover { background: var(--surface); }
.check .box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; transition: all .35s var(--ease-spring); }
.check .box svg { width: 14px; opacity: 0; transform: scale(.4); transition: all .35s var(--ease-spring); }
.check.done { border-color: rgba(69,86,44,.3); background: rgba(69,86,44,.06); }
.check.done .box { background: var(--lime); border-color: var(--lime); }
.check.done .box svg { opacity: 1; transform: none; }
.check.done .ct { color: var(--text-3); text-decoration: line-through; }
.check .ct { flex: 1; font-size: 14px; font-weight: 600; transition: color .25s; }
.check .ce { font-size: 18px; }

/* Big donut */
.donut-xl { position: relative; width: 240px; height: 240px; margin: 0 auto; }
.donut-xl svg { width: 100%; height: 100%; }
.donut-xl .dc { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut-xl .dc b { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; display: block; }
.donut-xl .dc span { font-size: 12px; color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; }

.macro-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; }
.mc { padding: 16px; border-radius: 16px; background: rgba(31,38,28,.03); border: 1px solid var(--border); position: relative; overflow: hidden; }
.mc::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.mc .ml { font-size: 12px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.mc .mv { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.mc .mp { font-size: 13px; color: var(--c); font-weight: 700; }

.stat-list { display: grid; gap: 2px; }
.stat-line { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.stat-line:last-child { border: 0; }
.stat-line span { color: var(--text-2); }
.stat-line b { font-variant-numeric: tabular-nums; }

.info {
  padding: 14px 16px; border-radius: 14px; background: rgba(111,159,181,.07); border: 1px solid rgba(111,159,181,.2);
  font-size: 13px; color: var(--text-2); display: flex; gap: 12px;
}
.info.warn { background: rgba(217,164,65,.07); border-color: rgba(217,164,65,.25); }
.info.good { background: rgba(69,86,44,.07); border-color: rgba(69,86,44,.25); }

/* Charts */
.chart { width: 100%; height: 300px; position: relative; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: rgba(31,38,28,.06); }
.chart .tip {
  position: absolute; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: var(--surface-solid);
  border: 1px solid var(--border-strong); font-size: 12px; white-space: nowrap; transform: translate(-50%, -120%);
  opacity: 0; transition: opacity .2s; box-shadow: var(--shadow-lg); z-index: 5;
}
.chart .tip b { display: block; font-size: 14px; }
.chart .draw { animation: draw 1.6s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .fade-area { opacity: 0; animation: fadeA 1.2s .5s var(--ease) forwards; }
@keyframes fadeA { to { opacity: 1; } }

.big-result { text-align: center; padding: 10px 0 6px; }
.big-result .br-label { font-size: 13px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.big-result .br-val { font-family: var(--font-display); font-size: clamp(38px, 4.5vw, 56px); line-height: 1.1; margin: 6px 0; }
.big-result .br-sub { color: var(--text-2); font-size: 14px; }

.milestones { display: grid; gap: 10px; }
.ms { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(31,38,28,.03); border: 1px solid var(--border); }
.ms .mi { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: rgba(69,86,44,.1); flex: none; }
.ms .mt { flex: 1; }
.ms .mt b { display: block; font-size: 14px; }
.ms .mt span { font-size: 12px; color: var(--text-3); }
.ms .md { font-weight: 700; font-size: 13px; color: var(--lime); text-align: right; }

/* Ketosis */
.gauge { position: relative; width: 100%; max-width: 320px; margin: 0 auto; }
.gauge svg { width: 100%; }
.gauge .needle { transform-origin: 160px 160px; transition: transform 1.4s var(--ease-spring); }
.timeline { display: grid; gap: 0; position: relative; }
.tl { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: start; padding-bottom: 20px; position: relative; }
.tl:not(:last-child)::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--border); }
.tl .tn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: var(--surface-2); border: 1px solid var(--border); position: relative; z-index: 1; }
.tl b { display: block; font-size: 15px; }
.tl p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.tl .tt { font-size: 13px; font-weight: 700; color: var(--lime); white-space: nowrap; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.toggle input { display: none; }
.toggle .sw { width: 46px; height: 26px; border-radius: 99px; background: rgba(31,38,28,.1); position: relative; transition: background .3s; flex: none; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .35s var(--ease-spring); }
.toggle input:checked + .sw { background: var(--lime); }
.toggle input:checked + .sw::after { transform: translateX(20px); }
.toggle span.tl-label { font-size: 14px; font-weight: 600; color: var(--text-2); }

/* Meal analyzer */
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; color: var(--text-3); }
.search .input { padding-left: 42px; }
.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 18px; }
.cat-chips button { border: 1px solid var(--border); background: transparent; padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .25s var(--ease); }
.cat-chips button.active, .cat-chips button:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.cat-chips button.active { border-color: var(--lime); color: var(--lime); }
.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.food {
  padding: 14px; border-radius: 16px; background: rgba(31,38,28,.03); border: 1px solid var(--border); cursor: pointer; text-align: left;
  transition: transform .35s var(--ease-spring), border-color .25s, background .25s; display: flex; flex-direction: column; gap: 6px;
}
.food:hover { transform: translateY(-3px); border-color: var(--border-strong); background: var(--surface-2); }
.food:active { transform: scale(.96); }
.food .fe { font-size: 26px; }
.food .fn { font-size: 13px; font-weight: 700; line-height: 1.3; }
.food .fc { font-size: 12px; color: var(--text-3); }
.grade { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; width: fit-content; }
.grade.ok { color: var(--lime); background: rgba(69,86,44,.1); }
.grade.mid { color: var(--amber); background: rgba(217,164,65,.1); }
.grade.bad { color: var(--coral); background: rgba(196,98,58,.12); }

.plate { display: grid; gap: 8px; margin: 16px 0; max-height: 300px; overflow-y: auto; }
.plate-empty { text-align: center; padding: 30px 10px; color: var(--text-3); font-size: 14px; border: 2px dashed var(--border); border-radius: 16px; }
.plate-empty div { font-size: 40px; margin-bottom: 8px; animation: float 4s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.pi { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(31,38,28,.03); border: 1px solid var(--border); animation: popIn .45s var(--ease-spring); }
@keyframes popIn { from { opacity: 0; transform: scale(.9) translateX(-10px); } }
.pi .pe { font-size: 22px; }
.pi .pn { flex: 1; min-width: 0; }
.pi .pn b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi .pn span { font-size: 11px; color: var(--text-3); }
.pi input { width: 64px; padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,.3); border: 1px solid var(--border); text-align: right; font-size: 13px; font-weight: 700; }
.pi .x { width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-size: 16px; }
.pi .x:hover { background: rgba(196,98,58,.15); color: var(--coral); }

.score-wrap { display: flex; align-items: center; gap: 18px; padding: 16px; border-radius: 18px; background: rgba(0,0,0,.2); border: 1px solid var(--border); }
.score-ring { position: relative; width: 86px; height: 86px; flex: none; }
.score-ring svg { width: 100%; height: 100%; }
.score-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; font-weight: 800; }
.score-wrap .sv b { font-size: 16px; display: block; }
.score-wrap .sv span { font-size: 13px; color: var(--text-2); }
.ratio-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: rgba(31,38,28,.06); margin: 16px 0 8px; }
.ratio-bar i { display: block; height: 100%; transition: width .8s var(--ease); }
.ratio-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); flex-wrap: wrap; gap: 8px; }
.ratio-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 6px; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.totals div { text-align: center; padding: 10px 4px; border-radius: 12px; background: rgba(31,38,28,.03); }
.totals b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.totals span { font-size: 11px; color: var(--text-3); }

/* Planner */
.week-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; }
.week-tabs button { flex: none; min-width: 84px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--border); background: rgba(31,38,28,.03); cursor: pointer; text-align: center; transition: all .3s var(--ease); }
.week-tabs button b { display: block; font-size: 15px; }
.week-tabs button span { font-size: 11px; color: var(--text-3); }
.week-tabs button.active { background: var(--lime); color: var(--on-accent); border-color: var(--lime); transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(69,86,44,.6); }
.week-tabs button.active span { color: rgba(251,248,241,.75); }
.meals { display: grid; gap: 12px; }
.meal {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: center; padding: 16px; border-radius: 18px;
  background: rgba(31,38,28,.03); border: 1px solid var(--border); transition: border-color .3s, transform .3s var(--ease);
  animation: popIn .5s var(--ease-spring) both;
}
.meal:hover { border-color: var(--border-strong); transform: translateX(4px); }
.meal .me { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; background: linear-gradient(140deg, rgba(69,86,44,.15), rgba(31,38,28,.03)); }
.meal .mtype { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--lime); }
.meal .mname { font-weight: 700; font-size: 15px; margin: 2px 0 4px; }
.meal .mmeta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: transparent; cursor: pointer; display: grid; place-items: center; font-size: 16px; transition: all .3s var(--ease); color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); transform: rotate(-20deg); }
.day-total { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.shop-group { margin-bottom: 18px; }
.shop-group h4 { margin: 0 0 8px; font-size: 13px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; font-size: 14px; cursor: pointer; border-bottom: 1px dashed var(--border); }
.shop-item .box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border-strong); display: grid; place-items: center; transition: all .3s var(--ease-spring); flex: none; }
.shop-item.done .box { background: var(--lime); border-color: var(--lime); }
.shop-item.done .box::after { content: "✓"; color: var(--on-accent); font-size: 12px; font-weight: 900; }
.shop-item.done .sn { text-decoration: line-through; color: var(--text-3); }
.shop-item .sn { flex: 1; }
.shop-item .sq { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Fasting */
.fast-wrap { display: grid; place-items: center; padding: 10px 0 20px; }
.fast-ring { position: relative; width: min(320px, 100%); aspect-ratio: 1; }
.fast-ring svg { width: 100%; height: 100%; }
.fast-ring .fc { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.fast-ring .fc .lbl { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.fast-ring .fc .time { font-size: clamp(36px, 5vw, 52px); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.fast-ring .fc .phase { font-size: 14px; color: var(--lime); font-weight: 700; margin-top: 4px; }
.fast-ring.running svg { filter: drop-shadow(0 0 24px rgba(69,86,44,.25)); }
.phases { display: grid; gap: 8px; }
.phase-item { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: rgba(31,38,28,.02); opacity: .55; transition: all .4s var(--ease); }
.phase-item.reached { opacity: 1; border-color: rgba(69,86,44,.25); }
.phase-item.current { opacity: 1; background: rgba(69,86,44,.08); border-color: var(--lime); transform: scale(1.02); }
.phase-item .pe { font-size: 22px; }
.phase-item b { display: block; font-size: 14px; }
.phase-item span { font-size: 12px; color: var(--text-2); }
.phase-item .ph { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--text-3); white-space: nowrap; }

/* Hydration */
.bottle { position: relative; width: 140px; height: 260px; margin: 0 auto; border-radius: 30px 30px 40px 40px; border: 3px solid var(--border-strong); overflow: hidden; background: rgba(31,38,28,.02); }
.bottle::before { content: ""; position: absolute; top: -3px; left: 50%; transform: translateX(-50%); width: 50px; height: 14px; border-radius: 0 0 8px 8px; background: var(--border-strong); z-index: 2; }
.bottle .water { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(180deg, #6cc8ff, #2b8fd6); transition: height 1s var(--ease); }
.bottle .water::before, .bottle .water::after {
  content: ""; position: absolute; top: -11px; left: 0; width: 200%; height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='12' viewBox='0 0 70 12'%3E%3Cpath d='M0 6 Q17.5 0 35 6 T70 6 V12 H0Z' fill='%236cc8ff'/%3E%3C/svg%3E") repeat-x;
  background-size: 70px 12px; animation: wave 3s linear infinite;
}
.bottle .water::after { opacity: .45; top: -8px; animation-duration: 5s; animation-direction: reverse; }
@keyframes wave { to { transform: translateX(-70px); } }
.bottle .bl { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; font-weight: 800; font-size: 24px; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.glasses { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.glass { width: 34px; height: 42px; border-radius: 4px 4px 10px 10px; border: 2px solid var(--border-strong); cursor: pointer; position: relative; overflow: hidden; transition: transform .3s var(--ease-spring); background: transparent; padding: 0; }
.glass:hover { transform: translateY(-3px); }
.glass::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--sky); transition: height .5s var(--ease); }
.glass.full::after { height: 80%; }
.elec { display: grid; gap: 14px; }
.elec-item { padding: 16px; border-radius: 16px; background: rgba(31,38,28,.03); border: 1px solid var(--border); }
.elec-item .eh { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.elec-item .eh b { font-size: 15px; }
.elec-item .eh strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.elec-item p { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.elec-item .bar { height: 8px; border-radius: 99px; background: rgba(31,38,28,.07); overflow: hidden; }
.elec-item .bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); width: 0; transition: width 1s var(--ease); }
.elec-item .eb { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.symptoms { display: flex; flex-wrap: wrap; gap: 8px; }
.symptoms button { padding: 9px 14px; border-radius: 99px; border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .3s var(--ease-spring); }
.symptoms button.on { background: rgba(196,98,58,.14); border-color: var(--coral); color: var(--text); transform: scale(1.04); }
.advice { display: grid; gap: 10px; margin-top: 16px; }

/* Journal */
.entries { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.entry { display: grid; grid-template-columns: 54px 1fr auto auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(31,38,28,.03); border: 1px solid var(--border); }
.entry .ed { text-align: center; line-height: 1.1; }
.entry .ed b { display: block; font-size: 18px; }
.entry .ed span { font-size: 11px; color: var(--text-3); text-transform: uppercase; }
.entry .ew { font-weight: 800; font-size: 16px; }
.entry .en { font-size: 12px; color: var(--text-3); }
.mood { display: flex; gap: 8px; }
.mood button { flex: 1; font-size: 22px; padding: 8px 0; border-radius: 12px; border: 1px solid var(--border); background: transparent; cursor: pointer; transition: all .3s var(--ease-spring); filter: grayscale(1); opacity: .6; }
.mood button.active { filter: none; opacity: 1; background: rgba(69,86,44,.1); border-color: var(--lime); transform: scale(1.08); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 16px 10px; border-radius: 16px; border: 1px solid var(--border); background: rgba(31,38,28,.02); filter: grayscale(1); opacity: .45; transition: all .5s var(--ease); }
.badge.got { filter: none; opacity: 1; border-color: rgba(217,164,65,.35); background: linear-gradient(160deg, rgba(217,164,65,.12), transparent); }
.badge .bi { font-size: 32px; }
.badge b { display: block; font-size: 12px; margin-top: 6px; }
.badge span { font-size: 11px; color: var(--text-3); }

/* Onboarding */
.overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(31,38,28,.4); backdrop-filter: blur(14px); animation: fadeIn .4s; }
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; padding: 34px; border-radius: var(--r-xl); background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: modalIn .6s var(--ease-spring); }
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(.95); } }
.modal h2 { font-size: 30px; margin: 10px 0 6px; }
.modal .lead { color: var(--text-2); margin: 0 0 26px; }
.steps-dots { display: flex; gap: 6px; }
.steps-dots i { height: 6px; flex: 1; border-radius: 99px; background: rgba(31,38,28,.1); transition: background .4s; }
.steps-dots i.on { background: var(--lime); }
.ob-step { display: none; }
.ob-step.active { display: grid; gap: 18px; animation: viewIn .5s var(--ease); }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choice { padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: rgba(31,38,28,.03); cursor: pointer; text-align: left; transition: all .3s var(--ease-spring); }
.choice:hover { border-color: var(--border-strong); }
.choice.active { border-color: var(--lime); background: rgba(69,86,44,.08); transform: scale(1.02); }
.choice .ci { font-size: 26px; }
.choice b { display: block; font-size: 14px; margin-top: 6px; }
.choice span { font-size: 12px; color: var(--text-3); }

/* Confetti */
.confetti { position: fixed; top: -20px; width: 10px; height: 14px; z-index: 300; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Pro modal */
.pro-modal .modal { text-align: center; }
.pro-modal ul { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; text-align: left; }
.pro-modal li { display: flex; gap: 10px; color: var(--text-2); }
.pro-modal li::before { content: "✓"; color: var(--lime); font-weight: 900; }

.disclaimer { margin-top: 40px; font-size: 12px; color: var(--text-3); text-align: center; }

/* Responsive */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-side, .g-side-r { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 8px; flex-direction: row;
    border-right: 0; border-top: 1px solid var(--border); background: rgba(243,236,223,.97);
  }
  .sidebar .logo, .upgrade, .side-label { display: none; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 2px; width: 100%; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav button { flex-direction: column; gap: 4px; padding: 6px 10px; font-size: 10px; flex: none; }
  .side-nav button .pro-tag { display: none; }
  .side-nav button.active::before { display: none; }
  .main { padding: 18px 16px 110px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .rings { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr 1fr; }
  .kpi .k-val { font-size: 24px; }
  .macro-cards { grid-template-columns: 1fr; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .meal { grid-template-columns: 48px 1fr auto; gap: 12px; }
  .meal .me { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
  .modal { padding: 24px; }
  .entry { grid-template-columns: 46px 1fr auto; }
  .entry .en { display: none; }
  .streak span { display: none; }
}

/* ==========================================================
   Harmonisation avec la landing (palette naturelle)
   ========================================================== */
.sidebar { backdrop-filter: none; }
.side-label { font-family: var(--font-hand); font-size: 19px; letter-spacing: 0; text-transform: none; color: var(--coral); font-weight: 500; padding: 16px 12px 4px; }
.side-nav button { color: var(--text-2); font-size: 15px; }
.side-nav button .ic { background: transparent; width: 26px; height: 26px; }
.side-nav button .ic svg { width: 20px; height: 20px; }
.side-nav button:hover { background: rgba(31,38,28,.05); }
.side-nav button:hover .ic { transform: none; }
.side-nav button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 rgba(31,38,28,.06), 0 6px 16px -12px rgba(31,38,28,.4); }
.side-nav button.active .ic { background: transparent; color: var(--lime); }
.side-nav button.active::before { display: none; }
.side-nav .pro-tag { color: var(--text); font-size: 10px; }
.upgrade { background: var(--surface); border: 1px solid var(--border); }
.upgrade::after { display: none; }
.upgrade b { font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.upgrade .btn { color: var(--text); }

.topbar h1 { font-size: clamp(28px, 3vw, 40px); }
.streak { background: var(--surface); border-color: var(--border); color: var(--coral); }
.streak b { color: var(--text); }
.avatar { background: var(--lime); color: var(--on-accent); font-family: var(--font-display); font-weight: 400; font-size: 18px; }

.panel h3 { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.kpi .k-label { color: var(--text-2); font-weight: 700; }
.kpi .k-val { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.kpi .bar { background: var(--bg-2); }
.mc .mv, .big-result .br-val, .donut-xl .dc b, .fast-ring .fc .time, .totals b, .ring-box .rc b, .score-ring b, .entry .ew, .week-tabs button b { font-family: var(--font-display); font-weight: 400; }
.ms .mi, .tl .tn { background: var(--bg-2); border-color: transparent; }

.welcome { background: var(--bg-2); border: 0; padding: 34px 34px 34px 38px; display: grid; grid-template-columns: 1fr auto 260px; overflow: hidden; }
.welcome .eyebrow { font-size: 22px; }
.welcome-photo { align-self: stretch; margin: -34px -34px -34px 0; min-height: 200px; }
.welcome-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 0 0 0 999px; }

.check.done { background: rgba(69,86,44,.06); }
.food .fe, .pi .pe { filter: saturate(.85); }
.meal .me { background: var(--bg-2); }
.week-tabs button.active { box-shadow: none; transform: none; }
.score-wrap { background: var(--bg); }
.toggle .sw::after { box-shadow: 0 1px 3px rgba(31,38,28,.3); }
.glass { border-color: rgba(31,38,28,.25); }
.bottle { border-color: rgba(31,38,28,.25); }
.bottle::before { background: rgba(31,38,28,.25); }
.bottle .bl { color: var(--text); text-shadow: 0 1px 0 rgba(255,255,255,.6); }
.modal { box-shadow: 0 40px 80px -30px rgba(31,38,28,.5); }
.choice.active { background: rgba(69,86,44,.08); }
.badge.got { background: linear-gradient(160deg, rgba(217,164,65,.14), transparent); }
.disclaimer { color: var(--text-3); }

@media (max-width: 900px) {
  .sidebar { background: rgba(243,236,223,.97); backdrop-filter: blur(10px); }
  .side-nav button.active { box-shadow: none; }
  .welcome { grid-template-columns: 1fr; }
  .welcome-photo { display: none; }
}
