/* NutriJubs — estilo "liquid glass" com 3 paletas: rosa (padrão), escuro e claro */
:root, :root[data-theme="rosa"] {
  --bg1: #ffd9e8; --bg2: #ffb6d3; --bg3: #e9a8ff;
  --blob1: #ff7eb3; --blob2: #c79bff; --blob3: #ffc2a1;
  --glass: rgba(255, 255, 255, .42);
  --glass-strong: rgba(255, 255, 255, .62);
  --glass-border: rgba(255, 255, 255, .7);
  --glass-edge: rgba(190, 60, 120, .16);
  --text: #3d1330;
  --muted: #86506d;
  --line: rgba(190, 60, 120, .18);
  --brand: #d6336c;
  --brand2: #ff7eb3;
  --brand-soft: rgba(214, 51, 108, .13);
  --brand-ink: #ffffff;
  --warn: #b45309;
  --warn-soft: rgba(255, 214, 140, .6);
  --danger: #b42318;
  --protein: #3b6df0;
  --carb: #d97706;
  --fat: #9333ea;
  --shadow: 0 8px 28px rgba(190, 60, 120, .18);
  --logo: #a8265c;
  color-scheme: light;
}
:root[data-theme="claro"] {
  --bg1: #f4f7fb; --bg2: #e8eef7; --bg3: #eef3f0;
  --blob1: #9cc7ff; --blob2: #b9e4d4; --blob3: #ffe0b8;
  --glass: rgba(255, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-border: rgba(255, 255, 255, .9);
  --glass-edge: rgba(30, 60, 100, .12);
  --text: #15233a;
  --muted: #5a6b82;
  --line: rgba(30, 60, 100, .14);
  --brand: #0f766e;
  --brand2: #34c3b3;
  --brand-soft: rgba(15, 118, 110, .12);
  --brand-ink: #ffffff;
  --warn: #b45309;
  --warn-soft: rgba(253, 230, 190, .7);
  --danger: #b42318;
  --protein: #2563eb;
  --carb: #d97706;
  --fat: #9333ea;
  --shadow: 0 8px 26px rgba(30, 60, 100, .12);
  --logo: #0f4f4a;
  color-scheme: light;
}
:root[data-theme="escuro"] {
  --bg1: #120b1a; --bg2: #1a1026; --bg3: #0d1220;
  --blob1: #b02a6b; --blob2: #4b3fb8; --blob3: #1e6f8a;
  --glass: rgba(255, 255, 255, .08);
  --glass-strong: rgba(255, 255, 255, .14);
  --glass-border: rgba(255, 255, 255, .18);
  --glass-edge: rgba(255, 255, 255, .06);
  --text: #f3ebf7;
  --muted: #b3a3c0;
  --line: rgba(255, 255, 255, .13);
  --brand: #ff7eb3;
  --brand2: #c79bff;
  --brand-soft: rgba(255, 126, 179, .16);
  --brand-ink: #2a0a1c;
  --warn: #f0b35a;
  --warn-soft: rgba(240, 179, 90, .16);
  --danger: #ff8a7a;
  --protein: #7aa8ff;
  --carb: #f2a64a;
  --fat: #c99bff;
  --shadow: 0 10px 32px rgba(0, 0, 0, .45);
  --logo: #ffd1e6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  background-attachment: fixed;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
/* bolhas de cor que dão o "líquido" por trás do vidro */
body::before, body::after {
  content: ""; position: fixed; z-index: 0; border-radius: 50%; filter: blur(50px); opacity: .75; pointer-events: none;
}
body::before { width: 62vmax; height: 62vmax; left: -22vmax; top: -18vmax; background: radial-gradient(circle at 35% 35%, var(--blob1), transparent 65%); animation: drift1 22s ease-in-out infinite alternate; }
body::after { width: 56vmax; height: 56vmax; right: -20vmax; bottom: -16vmax; background: radial-gradient(circle at 60% 60%, var(--blob2), transparent 65%); animation: drift2 26s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(8vmax, 10vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-9vmax, -7vmax) scale(1.08); } }

.app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }

/* vidro: base compartilhada */
.glass, .card, .tabbar, .topbar-pill, .bubble.bot, .chip, .composer textarea, .macro, .stat, input[type="text"], input[type="password"], input[type="url"], .disclaimer, .banner, .theme-opt {
  -webkit-backdrop-filter: blur(22px) saturate(1.7);
  backdrop-filter: blur(22px) saturate(1.7);
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.logo {
  width: 50px; height: 50px; flex: none; background: var(--logo);
  -webkit-mask: url(logo.png) center / contain no-repeat; mask: url(logo.png) center / contain no-repeat;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand b { font-size: 1.15rem; letter-spacing: -.01em; }
.brand span { font-size: .78rem; color: var(--muted); }
.topbar h1 { margin: 0; font-size: 1rem; font-weight: 600; margin-left: auto; padding: 6px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6); }
.badge { align-self: flex-start; margin-top: 3px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--warn-soft); color: var(--warn); padding: 3px 8px; border-radius: 999px;
}
main { flex: 1; overflow-y: auto; padding: 6px 16px 20px; outline: none; }

/* barra de abas flutuante em vidro */
.tabbar {
  display: flex; margin: 0 12px calc(10px + env(safe-area-inset-bottom)); padding: 6px 4px; gap: 2px;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 26px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 var(--glass-edge);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .72rem;
  padding: 7px 2px; border-radius: 20px; cursor: pointer; transition: background .25s, color .25s, transform .2s;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] {
  color: var(--brand); font-weight: 700;
  background: var(--glass-strong); box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 10px var(--brand-soft);
}
.tabbar button:active { transform: scale(.94); }
.tabbar button:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, .chip:focus-visible, .theme-opt:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

.card {
  position: relative; background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 24px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 var(--glass-edge);
}
.card h2 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }

/* anel de calorias */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: var(--brand); transition: stroke-dashoffset .5s ease; filter: drop-shadow(0 0 6px var(--brand-soft)); }
.ring .bar.over { stroke: var(--warn); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 1.6rem; line-height: 1; }
.ring-center span { font-size: .75rem; color: var(--muted); }
.kv { display: grid; gap: 4px; }
.kv b { font-size: 1.1rem; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.macro { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; padding: 10px; min-width: 0; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.macro > span:first-child { white-space: nowrap; font-size: .74rem; }
.macro .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.macro b { display: block; font-size: 1.15rem; }
.macro span { font-size: .78rem; color: var(--muted); }

.meal { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.meal:first-of-type { border-top: 0; }
.meal .tag { flex: none; width: 82px; font-size: .8rem; font-weight: 700; color: var(--brand); }
.meal .tag::first-letter { text-transform: uppercase; }
.meal .what { flex: 1; min-width: 0; }
.meal .what p { margin: 0; overflow-wrap: anywhere; }
.meal .kcal { flex: none; font-weight: 600; text-align: right; }

.empty { text-align: center; padding: 22px 8px; color: var(--muted); }
.btn {
  appearance: none; border: 1px solid rgba(255,255,255,.45); color: var(--brand-ink);
  background: linear-gradient(135deg, var(--brand2), var(--brand));
  font: inherit; font-weight: 700; padding: 11px 18px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 18px var(--brand-soft), inset 0 1px 0 rgba(255,255,255,.55);
  transition: transform .15s, filter .2s;
}
.btn:active { transform: scale(.96); }
.btn.secondary { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.btn.ghost { background: var(--glass); color: var(--muted); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.btn:disabled { opacity: .55; cursor: default; }

/* semana */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 190px; position: relative; padding-top: 8px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar-col .fill { width: 100%; max-width: 38px; border-radius: 12px 12px 6px 6px; background: linear-gradient(180deg, var(--brand2), var(--brand)); min-height: 3px; box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 4px 12px var(--brand-soft); }
.bar-col .fill.over { background: var(--warn); }
.bar-col .fill.none { background: var(--line); box-shadow: none; }
.bar-col .val { font-size: .7rem; color: var(--muted); }
.bar-col .lbl { font-size: .75rem; color: var(--muted); text-transform: capitalize; }
.bar-col.today .lbl { color: var(--brand); font-weight: 700; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--warn); pointer-events: none; }
.goal-line span { position: absolute; right: 0; top: -20px; font-size: .72rem; color: var(--warn); background: var(--glass-strong); border-radius: 8px; padding: 0 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 16px; padding: 10px; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.stat b { display: block; font-size: 1.2rem; }
.stat span { font-size: .78rem; color: var(--muted); }

/* chat */
.chat-view { display: flex; flex-direction: column; height: 100%; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 10px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 20px; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, var(--brand2), var(--brand)); color: var(--brand-ink); border-bottom-right-radius: 6px; box-shadow: 0 6px 16px var(--brand-soft), inset 0 1px 0 rgba(255,255,255,.5); }
.bubble.bot { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-border); border-bottom-left-radius: 6px; box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.bubble.err { align-self: flex-start; background: var(--warn-soft); color: var(--warn); border-bottom-left-radius: 6px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.chip { flex: none; border: 1px solid var(--glass-border); background: var(--glass); color: var(--text); font: inherit; font-size: .85rem; padding: 7px 13px; border-radius: 999px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.45); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 4px; }
.composer textarea {
  flex: 1; resize: none; max-height: 120px; font: inherit; color: var(--text);
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 20px; padding: 10px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
::placeholder { color: var(--muted); opacity: .8; }

/* dicas */
.tip h3 { margin: 0 0 4px; font-size: 1rem; }
.tip p { margin: 0; color: var(--muted); }
.disclaimer { font-size: .85rem; color: var(--muted); background: var(--glass); border: 1px solid var(--glass-border); border-radius: 18px; padding: 12px; }

/* ajustes */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type="text"], input[type="password"], input[type="url"] {
  width: 100%; font: inherit; color: var(--text); background: var(--glass-strong);
  border: 1px solid var(--glass-border); border-radius: 16px; padding: 10px 14px;
}
.notice { margin-top: 10px; font-size: .88rem; }
.notice.ok { color: var(--brand); }
.notice.bad { color: var(--danger); }
.banner { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--glass-border); border-radius: 18px; padding: 12px; margin-bottom: 12px; font-size: .9rem; }
.skeleton { height: 120px; border-radius: 24px; background: linear-gradient(90deg, var(--glass), var(--glass-strong), var(--glass)); background-size: 200% 100%; animation: sh 1.4s infinite; margin-bottom: 12px; }
@keyframes sh { to { background-position: -200% 0; } }

/* seletor de tema */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px;
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: 18px;
  color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.theme-opt[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand), 0 6px 16px var(--brand-soft); font-weight: 700; }
.swatch { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.swatch.rosa { background: linear-gradient(135deg, #ffd9e8, #ff7eb3 55%, #d6336c); }
.swatch.escuro { background: linear-gradient(135deg, #3a2650, #1a1026 55%, #b02a6b); }
.swatch.claro { background: linear-gradient(135deg, #ffffff, #dfe9f5 55%, #34c3b3); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* sem suporte a blur: usa fundo mais opaco para manter a leitura */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255,255,255,.8); }
  :root[data-theme="escuro"] { --glass: rgba(40, 28, 56, .92); --glass-strong: rgba(60, 44, 80, .95); }
}
