:root {
  --bg: #F6F5F1;
  --card: #FFFFFF;
  --ink: #12161C;
  --muted: #5F646C;
  --line: #E4E2DC;
  --glass: rgba(18, 22, 28, 0.035);
  --glass-edge: rgba(18, 22, 28, 0.18);
  --glass-strong: rgba(18, 22, 28, 0.06);
  --water: #2F86EB;
  --coffee: #8A5A3B;
  --juice: #F0A13A;
  --other: #A3A8B1;
  --ok: #167A52;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0E13;
    --card: #141922;
    --ink: #EEF1F5;
    --muted: #9AA1AB;
    --line: #232A35;
    --glass: rgba(255, 255, 255, 0.035);
    --glass-edge: rgba(255, 255, 255, 0.22);
    --glass-strong: rgba(255, 255, 255, 0.08);
    --water: #4A9BFF;
    --coffee: #B07E5A;
    --juice: #F5B354;
    --other: #7E8692;
    --ok: #3CC48E;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--water); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; }
.view {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 20px calc(env(safe-area-inset-bottom) + 24px);
}

/* cores por bebida (fundo e SVG) */
.fill-water  { fill: var(--water);  background: var(--water); }
.fill-coffee { fill: var(--coffee); background: var(--coffee); }
.fill-juice  { fill: var(--juice);  background: var(--juice); }
.fill-other  { fill: var(--other);  background: var(--other); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- barra superior ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.eyebrow { margin: 0; font-size: 15px; color: var(--muted); font-weight: 500; }
.title { margin: 0; font-size: 17px; font-weight: 600; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--glass); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 36px; height: 36px; font-size: 13px; color: var(--muted); }
.icon-btn-spacer { width: 44px; }
.link-btn { border: 0; background: none; padding: 6px 2px; color: var(--water); font-weight: 600; cursor: pointer; }

/* ---------- tela principal ---------- */
#home { display: flex; flex-direction: column; }
.home-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn.filled { background: var(--glass-strong); }
.vessel-wrap { display: grid; place-items: center; margin: 3vh 0 0; }
#vessel { width: min(56vw, 230px); height: auto; max-height: 42dvh; overflow: visible; }
.glass-body { fill: var(--glass); }
.glass-outline { fill: none; stroke: var(--glass-edge); stroke-width: 2.5; stroke-linejoin: round; }
.layer, .wave { transition: transform .7s cubic-bezier(.3,.9,.3,1), opacity .4s; }
.wave-path { animation: wave 3.6s linear infinite; }
.wave-back { opacity: .45; }
.wave-back .wave-path { animation-duration: 5.2s; animation-direction: reverse; }
@keyframes wave { to { transform: translateX(-100px); } }
.wave-back .wave-path { animation-name: wave-back; }
@keyframes wave-back { to { transform: translateX(-120px); } }

.readout { text-align: center; margin-top: 20px; }
.total { margin: 0; font-size: 64px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.total .unit { font-size: 22px; font-weight: 600; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.goal-link {
  margin-top: 6px; min-height: 44px; border: 0; background: none; color: var(--muted);
  font-size: 17px; font-weight: 500; padding: 6px 14px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.goal-link:hover { background: var(--glass); }
.goal-met .goal-link { color: var(--ok); font-weight: 600; }

.home-actions {
  margin-top: auto; padding-top: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.quick-add {
  min-width: 200px; height: 64px; padding: 0 32px; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: transform .15s;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.quick-add:active { transform: scale(.96); }
.quick-add svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; fill: none; }
.link-btn.muted { color: var(--muted); font-weight: 500; font-size: 14px; min-height: 44px; padding: 6px 12px; margin-top: 4px; }
.today-btn {
  min-height: 44px; padding: 6px 14px; border: 0; border-radius: 999px; background: none;
  color: var(--muted); font-size: 15px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.today-btn:hover:not(:disabled) { background: var(--glass); }
.today-btn:disabled { opacity: 1; cursor: default; }
.today-btn:disabled svg { display: none; }
.today-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.entry-list { list-style: none; margin: 4px 0 0; padding: 0; }
.entry-list li {
  display: flex; align-items: center; gap: 10px; min-height: 48px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.entry-list li:last-child { border-bottom: 0; }
.e-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 44px; }
.e-type { flex: 1; }
.e-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-row { color: var(--muted); justify-content: center; }

.tip {
  margin: 20px 0 0; padding: 14px 8px 14px 16px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
  display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.45;
}
.tip p { margin: 0; flex: 1; color: var(--muted); }
.tip strong { color: var(--ink); }
.tip-actions { display: flex; align-items: center; }

/* ---------- onboarding ---------- */
#onboarding { display: grid; place-items: center; }
.ob-inner { width: 100%; text-align: center; padding: 4vh 0; }
.ob-mark { width: 56px; height: 56px; margin-bottom: 12px; }
.ob-glass { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.6; }
#onboarding h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.02em; }
.lead { margin: 0 auto 28px; color: var(--muted); font-size: 16px; line-height: 1.45; max-width: 320px; }
.primary-btn {
  width: 100%; min-height: 54px; border: 0; border-radius: 16px;
  background: var(--ink); color: var(--bg); font-size: 17px; font-weight: 600; margin-top: 24px;
}
.primary-btn:active { transform: scale(.98); }

/* ---------- seletor de meta ---------- */
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); font-weight: 600; font-size: 15px;
}
.chip.on { border-color: var(--water); background: color-mix(in srgb, var(--water) 10%, var(--card)); color: var(--water); }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 20px; }
.step-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--card); font-size: 24px; line-height: 1;
}
.step-value { min-width: 130px; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.step-value small { font-size: 16px; color: var(--muted); font-weight: 600; }
.weight { margin-top: 18px; font-size: 15px; }
.weight summary { color: var(--water); font-weight: 600; cursor: pointer; list-style: none; padding: 6px; }
.weight summary::-webkit-details-marker { display: none; }
.weight-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 8px; }
.weight input {
  width: 90px; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 17px; text-align: center;
}
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---------- sheets ---------- */
.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px);
  border: 0; border-radius: 26px 26px 0 0; background: var(--bg); color: var(--ink);
  max-height: 88dvh; overflow-y: auto;
}
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2,.9,.3,1); }
.sheet.closing { animation: sheet-out .18s ease-in forwards; }
.sheet:focus { outline: none; }
.sheet::backdrop { background: rgba(0,0,0,.35); }
.sheet[open]::backdrop { animation: fade .28s; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
.sheet-title { margin: 0 0 16px; font-size: 20px; text-align: center; }
.sheet-sub { margin: -8px 0 18px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.45; }
#goal-sheet .goal-picker { text-align: center; }
#day-sheet .entry-list { background: var(--card); border-radius: var(--radius); padding: 4px 8px 4px 16px; }

.drink-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.drink {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card);
  font-size: 14px; font-weight: 600;
}
.drink .dot { width: 14px; height: 14px; }
.drink.on { border-color: var(--ink); }
.amounts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.amount {
  min-height: 72px; border-radius: 18px; border: 0; background: var(--card);
  box-shadow: var(--shadow); font-size: 15px; color: var(--muted);
}
.amount b { font-size: 26px; color: var(--ink); margin-right: 2px; letter-spacing: -0.02em; }
.amount.other b { font-size: 18px; }
.amount:active { transform: scale(.97); }
.custom-amount { text-align: center; }

/* ---------- instalar ---------- */
.install { text-align: center; }
.install-icon { width: 64px; height: 64px; border-radius: 15px; margin: 4px auto 10px; display: block; box-shadow: var(--shadow); }
.install .sheet-title { font-size: 22px; letter-spacing: -0.01em; margin-bottom: 14px; }
.install .sheet-sub { margin: 0 0 4px; }
.install .tip.warn { display: block; text-align: left; margin: 12px 0 0; color: var(--ink); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 16px 0 0; text-align: left; display: grid; gap: 10px; }
.steps li {
  counter-increment: step; display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.4;
}
.steps li::before {
  content: counter(step); flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.step-ico { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--glass-strong); display: grid; place-items: center; color: var(--water); }
.step-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step-ico img { width: 36px; height: 36px; border-radius: 9px; }
.link-btn.block { display: block; width: 100%; min-height: 44px; margin-top: 8px; font-size: 16px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 200px);
  transform: translate(-50%, 12px); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 10px 8px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: opacity .2s, transform .2s; z-index: 20;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body:not([data-view="home"]) .toast { bottom: calc(env(safe-area-inset-bottom) + 24px); }
.toast .link-btn { color: color-mix(in srgb, var(--water) 70%, var(--bg)); padding: 6px 8px; }

/* ---------- histórico ---------- */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-top: 8px;
  border-radius: 14px; background: var(--glass);
}
.segmented button {
  min-height: 38px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 15px; color: var(--muted);
}
.segmented [aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.period-nav { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 4px; }
.period-nav p { margin: 0; font-weight: 600; font-size: 16px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.chart-card { padding: 14px 10px 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart .goal-line { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 4; opacity: .45; }
.chart .bar-empty { fill: var(--line); }
.chart .check { fill: none; stroke: var(--ok); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart .goal-label { font-size: 11px; font-weight: 600; fill: var(--muted); text-anchor: end; font-family: var(--font); }
.chart .axis { font-size: 11px; fill: var(--muted); text-anchor: middle; font-family: var(--font); }
.chart .axis.today { fill: var(--ink); font-weight: 700; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--glass); }
.chart-legend { margin: 6px 6px 0; font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 12px 0; padding: 14px 4px; }
.stats div { padding: 0 12px; min-width: 0; display: flex; flex-direction: column; }
.stats div + div { border-left: 1px solid var(--line); }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: auto 0 0; padding-top: 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats dd small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

.card-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.mix-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.mix-empty { flex: 1; background: var(--line); }
.mix-legend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.mix-legend li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.mix-legend small { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.mix-legend b { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.mix-legend li.zero { color: var(--muted); font-size: 14px; }

.backup { margin-top: 24px; text-align: center; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.backup .link-btn { font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
@media (min-height: 800px) { .vessel-wrap { margin-top: 5vh; } }
