:root {
  --bg: #ffffff;
  --surface: #f5f5f1;
  --card: #ffffff;
  --ink: #0b0b0b;
  --muted: #6b6b66;
  --line: #e7e7e1;
  --accent: #c1f474;
  --accent-ink: #0b0b0b;
  --accent-soft: #eef9d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px rgba(11, 11, 11, .05);
  --radius: 22px;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #141414;
  --card: #121212;
  --ink: #f4f4f0;
  --muted: #9a9a92;
  --line: #242424;
  --accent-soft: #1b240d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; text-wrap: balance; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 108px);
}

/* Cabeçalho */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600; }
.brand i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--ink); display: inline-block; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); }
.icon-btn svg { width: 18px; height: 18px; }

.hello { margin-bottom: 20px; }
.hello .date { color: var(--muted); font-size: 13px; }
.hello h1 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1.02; letter-spacing: -.01em; margin-top: 4px; }
.hello h1 em { font-style: italic; }

/* Cartões */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .card + .section, .section + .card { margin-top: 14px; }
.label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.hero { background: var(--ink); color: var(--bg); border-color: var(--ink); display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
:root[data-theme="dark"] .hero { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hero .label { color: inherit; opacity: .62; }
.hero h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.05; margin-top: 8px; }
.hero p { margin-top: 8px; font-size: 14px; opacity: .8; }
.ring { position: relative; width: 76px; height: 76px; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring .bg { stroke: currentColor; opacity: .18; }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .5s ease; }
:root[data-theme="dark"] .ring .fg { stroke: var(--accent-ink); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 600; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.btn { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 999px; padding: 10px 16px; font-size: 14px; white-space: nowrap; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--surface); border-radius: 18px; padding: 12px; }
.stat b { display: block; font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }

/* Água */
.water-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.water-head b { font-family: var(--serif); font-weight: 400; font-size: 34px; }
.water-head span { color: var(--muted); font-size: 13px; }
.bar { position: relative; height: 12px; border-radius: 999px; background: var(--surface); margin: 14px 0 10px; overflow: visible; }
.bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); box-shadow: inset 0 0 0 1px rgba(11, 11, 11, .15); transition: width .4s ease; }
.bar .mark { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--ink); border-radius: 2px; }
.water-status { font-size: 13px; color: var(--muted); }
.water-actions { display: flex; gap: 8px; margin-top: 14px; }
.water-actions .btn { flex: 1; text-align: center; }
.water-actions .ghost { flex: 0 0 auto; }

/* Linha do tempo */
.section { margin-top: 26px; }
.section h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin-bottom: 12px; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 52px 1fr 34px; gap: 10px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.tl li:first-child { border-top: 0; }
.tl time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl h4 { margin: 0; font-size: 16px; font-weight: 600; text-wrap: balance; }
.tl p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.tl .kcal { display: inline-block; margin-top: 6px; font-size: 12px; background: var(--surface); border-radius: 999px; padding: 3px 9px; color: var(--muted); }
.tl li.now { background: var(--accent-soft); margin: 0 -12px; padding: 14px 12px; border-radius: 16px; border-top-color: transparent; }
.tl li.done h4 { text-decoration: line-through; text-decoration-thickness: 1px; opacity: .5; }
.tl li.done p, .tl li.done .kcal { opacity: .5; }
.check { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; background: transparent; }
.check svg { width: 14px; height: 14px; opacity: 0; }
li.done .check { background: var(--accent); border-color: var(--ink); }
li.done .check svg { opacity: 1; }
.check[disabled] { opacity: .35; cursor: default; }

/* Seletor de dia */
.days { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: 0 0 auto; min-width: 52px; padding: 10px 0; text-align: center; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; }
.day small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; margin-top: 2px; }
.day.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
:root[data-theme="dark"] .day.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.day.on small { color: inherit; opacity: .7; }

/* Semana */
.week-row { width: 100%; text-align: left; display: block; }
.week-row + .week-row { margin-top: 12px; }
.week-row h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; display: flex; align-items: center; gap: 10px; margin: 0; }
.tag { font-family: var(--sans); font-size: 11px; font-weight: 600; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 3px 9px; letter-spacing: .04em; }
.week-row .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; background: var(--surface); border-radius: 999px; padding: 4px 10px; color: var(--muted); }
.week-row p { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* Dieta */
.meal + .meal { margin-top: 12px; }
.meal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.meal-head h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0; }
.meal-head time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.items { list-style: none; margin: 12px 0 0; padding: 0; }
.items li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.items li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meal-foot { margin-top: 10px; font-size: 12px; color: var(--muted); }
.note { margin-top: 16px; font-size: 13px; color: var(--muted); }

/* Navegação inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 16px calc(env(safe-area-inset-bottom) + 12px); pointer-events: none; }
.tabs nav { pointer-events: auto; width: 100%; max-width: 448px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.tab { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 0; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab svg { width: 18px; height: 18px; }
.tab.on { background: var(--accent); color: var(--accent-ink); }

/* Lembrete */
#overlay:empty { display: none; }
#overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 16px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 16px); background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet { width: 100%; max-width: 448px; background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 24px 22px 22px; box-shadow: var(--shadow); animation: up .28s ease; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 36px; line-height: 1.05; margin-top: 10px; }
.sheet p { margin-top: 10px; color: var(--muted); }
.sheet .actions { display: grid; gap: 10px; margin-top: 20px; }
.sheet .btn { padding: 14px 16px; font-size: 15px; text-align: center; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Login */
.auth form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.field input { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; outline: none; width: 100%; }
.field input:focus { border-color: var(--ink); background: var(--card); }
.btn.full { width: 100%; padding: 15px 16px; font-size: 15px; margin-top: 4px; }
.btn[disabled] { opacity: .6; cursor: default; }
.auth-msg { font-size: 14px; background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; }
.auth-links { display: flex; justify-content: center; gap: 22px; margin-top: 18px; }
.link { font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; color: var(--ink); }

/* Ajustes */
.set-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.set-row:first-of-type { margin-top: 8px; }
.set-row span { color: var(--muted); }
.set-row b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Aviso rápido e carregamento */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px); width: max-content; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); text-align: center; }
.boot { display: grid; place-items: center; min-height: 50vh; }
.boot i { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
