/* === Tokens — receita. (Barro + Fervura) === */
:root {
  /* Papel / Tinta — herdadas da mãe */
  --bg:          #EFEBE0;   /* papel */
  --bg-2:        #E7E1D3;   /* papel sombreado */
  --paper:       #F6F3EC;   /* papel claro — superfícies elevadas */
  --paper-2:     #FFFFFF;
  --ink:         #0F1922;   /* tinta */
  --ink-2:       #2B3742;
  --muted:       #6D7580;   /* marginal */
  --muted-2:     #8A919B;
  --line:        #D9D3C6;
  --line-strong: #C2BBAA;

  /* Próprias da receita. */
  --barro:        #8B4423;  /* primária */
  --barro-claro:  #A25A38;
  --barro-escuro: #6E351B;
  --fervura:      #D9A05B;  /* secundária / acento */
  --filete:       #A62A3A;  /* sinal da família — usar pouco, aparecer sempre */
  --papel-barro:  #F0E5DA;  /* fundo aquecido para cards claros */
  --linha-barro:  rgba(255,235,220,0.15);  /* filete sobre fundo Barro */

  /* Slots semânticos herdados do sistema anterior — repontados.
     Templates existentes usam .pill-sage / .pill-terra / .pill-amber;
     mantêm-se os nomes, mudam-se os valores. */
  --sage:       #8B4423;   /* = barro   (primária, botões, links) */
  --sage-soft:  #F0E5DA;   /* = papel-barro */
  --terra:      #A62A3A;   /* = filete  (sinal, erros, destaques) */
  --terra-soft: #F5E3E3;
  --amber:      #D9A05B;   /* = fervura (avisos, acentos quentes) */
  --amber-soft: #F7EBD8;
  --plum:       #6E351B;   /* = barro escuro */
  --plum-soft:  #EDE2D8;
  --ink-soft:   #EDE7DA;

  /* Macros — quatro tons distinguíveis dentro da paleta da família */
  --m-cal:  #0F1922;   /* tinta   */
  --m-pro:  #8B4423;   /* barro   */
  --m-carb: #D9A05B;   /* fervura */
  --m-fat:  #A62A3A;   /* filete  */

  /* Tipografia — três Google Fonts, nada mais */
  --display: "Instrument Serif", "Georgia", "Times New Roman", serif;
  --sans:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  /* Cantos rectos — o sistema é editorial, não SaaS */
  --r-sm: 0px;
  --r-md: 0px;
  --r-lg: 2px;
  --r-xl: 2px;

  /* Grelha */
  --max-w:      1180px;
  --max-w-text: 640px;
}

/* Sombras e véus — derivados da Tinta #0F1922 (rgba documentada). */
:root {
  --veu:         rgba(15,25,34,0.32);   /* scrims / overlays */
  --veu-forte:   rgba(15,25,34,0.45);   /* modal overlay */
  --sombra-sm:   0 2px 8px rgba(15,25,34,0.06);
  --sombra-md:   0 8px 28px rgba(15,25,34,0.10);
  --sombra-card: 0 8px 32px rgba(15,25,34,0.22);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

/* receita. links — clean by default; rich-text regions (.stretched-content) can
   opt back into the underline so embedded URLs stay discoverable. */
a { color: inherit; text-decoration: none; }
a:hover, a:focus, a:active, a:visited { text-decoration: none; }
.stretched-content a { color: var(--barro); text-decoration: underline; text-underline-offset: 2px; }
.stretched-content a:hover { color: var(--barro-escuro); }

/* Family helpers — three faces, nothing else. */
.serif { font-family: var(--display); font-weight: 400; }
.mono  { font-family: var(--mono); }

/* Default icon sizing — SVG sprite refs need explicit dimensions or they render at default 300×150. */
.ico { width: 14px; height: 14px; flex-shrink: 0; display: inline-block; vertical-align: text-bottom; }
.btn .ico, .btn-icon .ico, .suggest-pill .ico, .pill .ico { width: 14px; height: 14px; }
.ai-input .send .ico { width: 14px; height: 14px; }
.btn-sm .ico { width: 12px; height: 12px; }

/* Loading spinner — used by lock overlays, vision uploads, async modals.
   Round by design: a circle is the shape of the thing. */
@keyframes m-spin { to { transform: rotate(360deg); } }
.m-spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--barro);
  border-radius: 50%;
  animation: m-spin 0.9s linear infinite;
  vertical-align: middle;
}
.m-spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.m-spinner.lg { width: 44px; height: 44px; border-width: 3px; }
.m-loading {
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.m-loading .m-spinner { display: block; margin: 0 auto 14px; }

/* === Typography === */
.display { font-family: var(--display); font-weight: 400; letter-spacing: -0.02em; line-height: 1.02; }
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--filete);
  font-weight: 500;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* === Editorial furniture — o sistema § ===
   Section headers, mono rótulos and the 60×6 filete bar. */
.rotulo {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--filete);
}
.filete {
  display: block;
  width: 60px;
  height: 6px;
  background: var(--filete);
  flex-shrink: 0;
}
.filete--fino { height: 2px; width: 40px; }

.sec-cab {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 48px;
}
.sec-num {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.sec-num__hash { color: var(--filete); }
.sec-num__nome { color: var(--muted); }
.sec-titulo {
  font-family: var(--display);
  font-size: clamp(38px, 6vw, 64px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  max-width: 900px;
  margin: 0;
}
.sec-titulo em { color: var(--barro); font-style: italic; }
.sec-intro {
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 620px;
  margin-top: 12px;
}
@media (min-width: 900px) {
  .sec-cab { grid-template-columns: 240px 1fr; gap: 64px; }
  .sec-cab .sec-num { align-self: start; padding-top: 8px; }
}

/* Barro surfaces — everything inverts on clay. */
.dark, .on-barro {
  background: var(--barro);
  color: var(--bg);
}
.dark .sec-titulo, .on-barro .sec-titulo { color: var(--bg); }
.dark .sec-titulo em, .on-barro .sec-titulo em { color: var(--fervura); }
.dark .sec-intro, .on-barro .sec-intro { color: var(--papel-barro); }
.dark .sec-num__nome, .on-barro .sec-num__nome { color: var(--papel-barro); }
.dark .rotulo, .on-barro .rotulo,
.dark .eyebrow, .on-barro .eyebrow { color: var(--fervura); }
.dark .filete, .on-barro .filete { background: var(--fervura); }
.dark hr, .on-barro hr { border: none; border-top: 1px solid var(--linha-barro); }
/* Links on clay stay papel (Fervura on Barro is only ~3:1) — Fervura on hover. */
.dark a, .on-barro a { color: var(--bg); text-underline-offset: 2px; }
.dark a:hover, .on-barro a:hover { color: var(--fervura); }

/* === App shell === */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}
.app[data-layout="topnav"] { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.app[data-layout="split"] { grid-template-columns: 232px 1fr 360px; }

/* === Sidebar === */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 28px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
/* The mark is the favicon tile: a square "r." in papel over Barro. */
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--barro);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 16px;
}
.brand-name { font-family: var(--display); font-size: 22px; letter-spacing: -0.01em; }
.brand-name .ponto { color: var(--filete); font-weight: 500; }
.brand-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-2);
  text-align: left; width: 100%;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover { background: var(--papel-barro); color: var(--barro-escuro); text-decoration: none; }
.nav-item:focus, .nav-item:active, .nav-item:visited { text-decoration: none; }
.nav-item.active { background: var(--barro); color: var(--bg); border-left-color: var(--filete); }
.sidebar a, .sidebar a:hover, .sidebar a:focus, .sidebar a:active, .sidebar a:visited,
.m-topbar a, .m-topbar a:hover, .m-topbar a:focus, .m-topbar a:active { text-decoration: none; }
.nav-item .ico { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; font-family: var(--mono); font-size: 10px; opacity: .7; }
.nav-item.active .badge { opacity: .9; }

.user-card {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line);
}
/* Round by design — an avatar is a face. */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--fervura), var(--barro));
  color: var(--bg); display: grid; place-items: center;
  font-family: var(--display); font-size: 14px;
  flex-shrink: 0;
}
.user-card .name { font-size: 13px; font-weight: 500; }
.user-card .meta { font-size: 11px; color: var(--muted); }

/* === Top nav variant === */
.topnav {
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  align-items: center;
  gap: 28px;
  position: sticky; top: 0; z-index: 20;
}
.app[data-layout="topnav"] .sidebar { display: none; }
.app[data-layout="topnav"] .topnav { display: flex; }
.topnav .nav { flex-direction: row; gap: 2px; flex: 1; }
.topnav .nav-item { padding: 7px 12px; border-left: none; border-bottom: 2px solid transparent; }
.topnav .nav-item.active { border-left: none; border-bottom-color: var(--filete); }
.topnav .nav-section { display: none; }
.topnav .user-card { margin: 0; padding: 6px 10px 6px 6px; }
.topnav .brand-sub { display: none; }

/* === Main === */
.main {
  padding: 36px 48px 80px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.app[data-layout="split"] .main { padding: 36px 36px 80px; max-width: none; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 32px;
}
.page-head .left { flex: 1; }
.page-head h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 5vw, 52px);
  margin: 6px 0 0;
  line-height: 1;
  letter-spacing: -0.02em;
}
/* The filete under every page title — o sinal da família. */
.page-head h1::after {
  content: "";
  display: block;
  width: 60px; height: 6px;
  background: var(--filete);
  margin-top: 18px;
}
.page-head h1 em { font-style: italic; color: var(--barro); }
.page-head .sub { color: var(--muted); margin-top: 14px; max-width: 520px; }

/* === Buttons ===
   Mono, uppercase, .14em tracking, square. Three weights of intent:
   primary (Barro), accent (Fervura), and the quiet outline/soft/ghost trio. */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover, .btn:focus, .btn:active, .btn:visited { text-decoration: none; }
.btn-primary { background: var(--barro); color: var(--bg); border-color: var(--barro); }
.btn-primary:hover { background: transparent; color: var(--barro); }
/* Fervura fill — never Fervura *text* on light paper (2:1); the text is Barro. */
.btn-accent { background: var(--fervura); color: var(--barro); border-color: var(--fervura); }
.btn-accent:hover { background: transparent; color: var(--barro); border-color: var(--barro); }
.btn-outline { background: transparent; color: var(--barro); border-color: var(--barro); }
.btn-outline:hover { background: var(--barro); color: var(--bg); }
.btn-ghost { color: var(--ink-2); border-color: var(--line-strong); background: transparent; }
.btn-ghost:hover { background: var(--papel-barro); color: var(--barro-escuro); border-color: var(--barro); }
.btn-soft { background: var(--papel-barro); color: var(--barro); border-color: var(--line); }
.btn-soft:hover { border-color: var(--barro); }
.btn-danger { background: var(--filete); color: var(--bg); border-color: var(--filete); }
.btn-danger:hover { background: transparent; color: var(--filete); }
.btn-sm { padding: 7px 12px; font-size: 10.5px; letter-spacing: 0.12em; }
.btn-lg { padding: 14px 22px; font-size: 12px; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; }
/* Circular icon button — the sanctioned round exception. */
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
}
.btn-icon:hover { border-color: var(--barro); color: var(--barro); }

/* Buttons on a Barro surface flip to papel / fervura. */
.dark .btn-primary, .on-barro .btn-primary { background: var(--fervura); color: var(--barro); border-color: var(--fervura); }
.dark .btn-primary:hover, .on-barro .btn-primary:hover { background: transparent; color: var(--fervura); }
.dark .btn-accent:hover, .on-barro .btn-accent:hover { background: transparent; color: var(--fervura); border-color: var(--fervura); }
.dark .btn-outline, .on-barro .btn-outline,
.dark .btn-ghost, .on-barro .btn-ghost { color: var(--bg); border-color: var(--bg); background: transparent; }
.dark .btn-outline:hover, .on-barro .btn-outline:hover,
.dark .btn-ghost:hover, .on-barro .btn-ghost:hover { background: var(--bg); color: var(--barro); }
.dark .btn-icon, .on-barro .btn-icon { background: transparent; color: var(--bg); border-color: var(--linha-barro); }
.dark .btn-icon:hover, .on-barro .btn-icon:hover { border-color: var(--fervura); color: var(--fervura); }

/* === Cards === */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
/* Warmed variant — papel barro with a clay spine. */
.card--barro {
  background: var(--papel-barro);
  border-color: var(--line);
  border-left: 3px solid var(--barro);
}
.card--barro .card-title { color: var(--barro); }
/* Full Barro card — for hero/feature surfaces inside the app. */
.card--escuro {
  background: var(--barro);
  border-color: var(--barro);
  color: var(--bg);
}
.card--escuro .card-title { color: var(--bg); }
.card--escuro .card-eyebrow { color: var(--fervura); }
.card-pad { padding: 22px; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 22px 0; gap: 12px;
}
.card-title { font-family: var(--display); font-weight: 400; font-size: 24px; letter-spacing: -0.01em; }
.card-eyebrow { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }

/* === Pills — the one round exception === */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--ink-soft); color: var(--ink-2);
}
.pill-sage { background: var(--sage-soft); color: var(--sage); }
.pill-terra { background: var(--terra-soft); color: var(--terra); }
/* Fervura reads as a fill only — the text on it is Barro escuro. */
.pill-amber { background: var(--amber-soft); color: var(--plum); }
.pill-plum { background: var(--plum-soft); color: var(--plum); }
.pill-outline { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.dark .pill-outline, .on-barro .pill-outline { border-color: var(--linha-barro); color: var(--papel-barro); }

/* AI marker - very subtle */
.ai-mark {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--muted); text-transform: uppercase;
}
.ai-mark::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--filete);
}
.dark .ai-mark, .on-barro .ai-mark { color: var(--papel-barro); }

/* === Macro rings === */
.macro-ring { position: relative; }
.macro-ring svg { display: block; transform: rotate(-90deg); }
.macro-ring .center {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center;
}
.macro-ring .center .big { font-family: var(--display); font-size: 42px; line-height: 1; }
.macro-ring .center .small { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-top: 4px; }

.macro-legend { display: flex; flex-direction: column; gap: 12px; }
.macro-legend .row { display: flex; align-items: center; gap: 10px; }
.macro-legend .swatch { width: 10px; height: 10px; border-radius: var(--r-sm); flex-shrink: 0; }
.macro-legend .label { flex: 1; font-size: 13px; color: var(--ink-2); }
.macro-legend .val { font-family: var(--mono); font-size: 12px; }
.macro-legend .target { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* === Meal planner grid === */
.planner {
  display: grid;
  grid-template-columns: 90px repeat(7, 1fr);
  gap: 10px;
}
.planner .day-head {
  padding: 10px 4px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.planner .day-head .dow { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.planner .day-head .num { font-family: var(--display); font-size: 32px; line-height: 1; margin-top: 2px; }
.planner .day-head.today { border-bottom-color: var(--filete); }
.planner .day-head.today .num { color: var(--filete); }
.planner .day-head.today .dow { color: var(--filete); }

.planner .row-label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase;
  border-top: 1px solid var(--line);
}
.planner .corner { border: none; }

.meal-cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 11px;
  display: flex; flex-direction: column;
  gap: 6px;
  min-height: 96px;
  text-align: left;
  transition: all .15s;
  position: relative;
}
.meal-cell:hover { border-color: var(--barro); transform: translateY(-1px); }
.meal-cell.empty { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); justify-content: center; align-items: center; }
.meal-cell.empty:hover { border-color: var(--barro); color: var(--barro); }
.meal-cell .title { font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.meal-cell .meta { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: auto; }
.meal-cell .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }
.meal-cell .accent { position: absolute; top: 10px; right: 10px; width: 6px; height: 6px; border-radius: 50%; }
.meal-cell.b .accent { background: var(--fervura); }
.meal-cell.l .accent { background: var(--filete); }
.meal-cell.d .accent { background: var(--barro); }

/* === AI panel === */
.ai-panel {
  background: var(--paper);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  height: 100vh;
  position: sticky; top: 0;
}
.ai-panel-head {
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.ai-panel-body { flex: 1; overflow-y: auto; padding: 22px; }
.ai-panel-foot {
  padding: 14px 18px 22px;
  border-top: 1px solid var(--line);
}

.app:not([data-layout="split"]) > .ai-panel { display: none; }

.msg { margin-bottom: 18px; }
.msg.user .bubble {
  background: var(--barro); color: var(--bg);
  margin-left: 24px;
  border-radius: var(--r-md);
}
.msg.bot .bubble {
  background: var(--papel-barro); color: var(--ink);
  margin-right: 24px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--barro);
}
.msg .bubble { padding: 12px 14px; font-size: 13px; line-height: 1.55; }
.msg .author { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.msg.user .author { text-align: right; }

.ai-input {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 8px 8px 14px;
  transition: border-color .15s;
}
.ai-input:focus-within { border-color: var(--barro); }
.ai-input textarea {
  flex: 1; border: none; background: transparent; resize: none;
  font-size: 13px; line-height: 1.45; outline: none;
  min-height: 22px; max-height: 120px; padding: 6px 0;
}
/* Circular icon button — sanctioned round exception. */
.ai-input .send {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--barro); color: var(--bg);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s;
}
.ai-input .send:hover { background: var(--barro-escuro); }
.ai-input .send:disabled { opacity: 0.4; }

/* === FAB AI button (when not in split layout) === */
.ai-fab {
  position: fixed; bottom: 26px; right: 26px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--barro); color: var(--bg);
  display: grid; place-items: center;
  box-shadow: var(--sombra-md);
  z-index: 30;
  transition: transform .2s, background .2s;
}
.ai-fab:hover { transform: translateY(-2px); background: var(--barro-escuro); }
.app[data-layout="split"] ~ .ai-fab,
.app[data-layout="split"] .ai-fab { display: none; }

/* === Drawer (AI when not split) === */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--veu);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 92vw;
  background: var(--paper);
  border-left: 1px solid var(--line);
  z-index: 41;
  transform: translateX(100%);
  transition: transform .25s ease-out;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0; background: var(--veu-forte);
  z-index: 50;
  display: grid; place-items: center;
  padding: 32px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-card);
  width: 100%; max-width: 920px;
  max-height: 88vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  transform: translateY(8px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

/* === Recipe card (app grid tile) ===
   Not to be confused with .receita-card, the signature editorial card
   defined in receita-brand.css. */
.recipe-card {
  background: var(--paper);
  border-radius: var(--r-md);
  overflow: hidden;
  text-align: left;
  transition: all .2s;
  display: flex; flex-direction: column;
  width: 100%;
  border: 1px solid var(--line);
}
.recipe-card:hover { transform: translateY(-2px); border-color: var(--barro); }
.recipe-card .img {
  aspect-ratio: 4 / 3;
  background: var(--bg-2);
  position: relative;
  overflow: hidden;
}
.recipe-card .img-grad {
  position: absolute; inset: 0;
}
.recipe-card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.recipe-card .meal-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--filete); text-transform: uppercase; }
.recipe-card .name { font-family: var(--display); font-size: 24px; line-height: 1.1; letter-spacing: -0.01em; }
.recipe-card .meta { display: flex; gap: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.recipe-card .difficulty,
.difficulty { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }

/* === Image placeholder gradients ===
   No stock photography in this system — recipe tiles get flat clay/ember
   washes built only from palette tokens. */
.ph-1 { background: linear-gradient(135deg, var(--fervura) 0%, var(--barro) 60%, var(--barro-escuro) 100%); }
.ph-2 { background: linear-gradient(135deg, var(--papel-barro) 0%, var(--barro-claro) 55%, var(--barro-escuro) 100%); }
.ph-3 { background: linear-gradient(135deg, var(--bg-2) 0%, var(--fervura) 55%, var(--barro) 100%); }
.ph-4 { background: linear-gradient(135deg, var(--fervura) 0%, var(--filete) 55%, var(--ink) 100%); }
.ph-5 { background: linear-gradient(135deg, var(--paper) 0%, var(--line-strong) 45%, var(--muted) 100%); }
.ph-6 { background: linear-gradient(135deg, var(--bg) 0%, var(--muted-2) 50%, var(--ink-2) 100%); }
.ph-7 { background: linear-gradient(160deg, var(--fervura) 0%, var(--barro-claro) 50%, var(--filete) 100%); }
.ph-8 { background: linear-gradient(200deg, var(--papel-barro) 0%, var(--fervura) 45%, var(--barro-escuro) 100%); }

/* Light/dark speckle over the washes — neutral rgba, intentionally colourless. */
.ph-grain {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 30% 40%, rgba(255,255,255,0.35) 0%, transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.15) 0%, transparent 40%);
  mix-blend-mode: overlay;
}

/* === Stat box === */
.stat {
  padding: 18px 20px;
  border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--barro);
}
.stat .lbl { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.stat .val { font-family: var(--display); font-size: 38px; line-height: 1.1; margin-top: 6px; letter-spacing: -0.02em; }
.stat .delta { font-family: var(--mono); font-size: 11px; margin-top: 4px; }
.stat .delta.up { color: var(--sage); }
.stat .delta.down { color: var(--terra); }

/* === Sparkline === */
.spark { width: 100%; height: 36px; }

/* Mini toast — transient notification anchored top-right. */
.m-toast {
  position: fixed; top: 22px; right: 22px;
  background: var(--ink); color: var(--bg);
  padding: 11px 16px; border-radius: var(--r-sm);
  border-left: 3px solid var(--fervura);
  font-family: var(--mono);
  font-size: 11.5px; letter-spacing: 0.06em;
  box-shadow: var(--sombra-md);
  z-index: 9998;
}
.m-toast.danger { background: var(--filete); border-left-color: var(--ink); }

/* Django messages stack (rendered by receita_base.html) */
.receita-messages { display: block; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--barro); }
::-webkit-scrollbar-track { background: transparent; }

/* Focus — always visible, never `outline: none`. */
:focus-visible { outline: 2px solid var(--barro); outline-offset: 2px; }
.dark :focus-visible, .on-barro :focus-visible { outline-color: var(--fervura); }
.btn-primary:focus-visible, .btn-accent:focus-visible { outline-offset: 3px; }

/* Tabs — square segmented control */
.tabs { display: flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); padding: 3px; border-radius: var(--r-sm); width: fit-content; }
.tab {
  padding: 7px 14px; border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--barro); }
.tab.active { background: var(--paper); color: var(--barro); box-shadow: var(--sombra-sm); }

/* Section header */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin: 0 0 16px;
}
.section-head h2 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 0; line-height: 1; letter-spacing: -0.02em; }
.section-head h2 em { font-style: italic; color: var(--barro); }
.section-head .meta { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* List rows */
.row-list { display: flex; flex-direction: column; }
.row-list .row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row-list .row:last-child { border-bottom: none; }
.row-thumb {
  width: 48px; height: 48px; border-radius: var(--r-sm);
  flex-shrink: 0; position: relative; overflow: hidden;
}

/* Progress bar */
.bar { width: 100%; height: 6px; background: var(--bg-2); border-radius: var(--r-sm); overflow: hidden; }
.bar > div { height: 100%; border-radius: var(--r-sm); background: var(--barro); transition: width .4s; }

/* Editor card prompt suggestions — pill-shaped by name and by nature */
.suggest-row { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest-pill {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
  font-size: 11.5px; color: var(--ink-2);
  transition: all .15s;
}
.suggest-pill:hover { border-color: var(--barro); color: var(--barro); }

/* Tool badges in the nutritionist chat */
.tool-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--papel-barro); color: var(--barro);
  border: 1px solid var(--line);
}

/* Subtle fade in */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .25s ease-out both; }

/* === receita. lock overlay — for long-running AI jobs === */
.m-lock {
  position: fixed; inset: 0; z-index: 9999;
  /* papel #EFEBE0 at 94% — documented rgba of var(--bg) */
  background: rgba(239, 235, 224, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 22px;
  color: var(--ink);
  padding: 32px;
  animation: m-lock-in 0.35s ease-out both;
}
@keyframes m-lock-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.m-lock.closing { animation: m-lock-out 0.22s ease-in both; }
@keyframes m-lock-out { to { opacity: 0; } }

.m-lock__logo {
  width: 96px; height: 96px;
  color: var(--barro);
  animation: m-lock-breathe 2.8s ease-in-out infinite;
  /* soft lift — documented rgba of var(--ink) */
  filter: drop-shadow(0 4px 16px rgba(15,25,34,0.10));
}
.m-lock__logo svg, .m-lock__logo img { width: 100%; height: 100%; display: block; }
@keyframes m-lock-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.m-lock__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 4px 0 0;
  max-width: 640px;
  color: var(--ink);
}
.m-lock__title em { font-style: italic; color: var(--barro); }
.m-lock__title .m-lock__dots::after {
  content: '\2026'; /* ellipsis fallback */
  display: inline-block;
  margin-left: 4px;
  color: var(--muted);
  animation: m-lock-dots 1.6s infinite steps(4, end);
}
@keyframes m-lock-dots {
  0%   { content: ''; }
  25%  { content: '\B7'; }
  50%  { content: '\B7\B7'; }
  75%  { content: '\B7\B7\B7'; }
  100% { content: '\B7\B7\B7'; }
}

.m-lock__sub {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
  min-height: 1.5em;
  transition: opacity .25s ease;
  max-width: 480px;
}
.m-lock__sub.swap { opacity: 0; }

/* The family filete, standing in for the old hairline divider. */
.m-lock__divider {
  width: 60px; height: 6px; background: var(--filete);
  margin: 4px 0 0;
}

.m-lock__elapsed {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.m-lock__elapsed .num { color: var(--ink-2); }

.m-lock__cancel {
  margin-top: 12px;
  padding: 9px 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .15s;
}
.m-lock__cancel:hover { color: var(--filete); border-color: var(--filete); }

/* Decorative corner mark (faded brand logo) */
.m-lock__corner {
  position: absolute;
  bottom: -50px; right: -50px;
  width: 260px; height: 260px;
  opacity: 0.06;
  pointer-events: none;
  color: var(--barro);
}
.m-lock__corner svg, .m-lock__corner img { width: 100%; height: 100%; }

@media (max-width: 640px) {
  .m-lock__logo { width: 72px; height: 72px; }
  .m-lock__title { font-size: clamp(28px, 8vw, 40px); }
  .m-lock__sub { font-size: 11px; letter-spacing: 0.12em; }
  .m-lock__corner { width: 180px; height: 180px; bottom: -36px; right: -36px; }
}

/* === Mobile top bar (hidden on desktop, shown on tablet/phone) === */
.m-topbar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  align-items: center;
  gap: 12px;
}
.m-topbar .m-menu-toggle {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line);
}
.m-topbar .m-menu-toggle:hover { background: var(--papel-barro); color: var(--barro); border-color: var(--barro); }
.m-topbar .m-brand-line { font-family: var(--display); font-size: 20px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: baseline; gap: 8px; }
.m-topbar .m-brand-line .ponto { color: var(--filete); font-weight: 500; }
.m-topbar .m-brand-line small { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }
.m-topbar .receita-logo { width: 22px; height: 22px; }

.m-scrim {
  position: fixed; inset: 0;
  background: var(--veu);
  z-index: 39;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
body.menu-open .m-scrim { opacity: 1; pointer-events: auto; }

/* === Tablet (≤ 1024px) === */
@media (max-width: 1024px) {
  .main { padding: 28px 28px 64px; }
  .page-head h1 { font-size: clamp(32px, 5vw, 46px); }
}

/* === Tablet narrow & phone (≤ 920px): sidebar becomes drawer === */
@media (max-width: 920px) {
  .app, .app[data-layout="sidebar"], .app[data-layout="split"], .app[data-layout="topnav"] {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .m-topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px; max-width: 88vw;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    box-shadow: var(--sombra-md);
    overflow-y: auto;
  }
  body.menu-open .sidebar { transform: translateX(0); }

  .main { padding: 22px 20px 60px; max-width: none; }

  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head h1 { font-size: clamp(30px, 7vw, 40px); }
  .page-head h1::after { margin-top: 14px; }
  .page-head .sub { max-width: none; }
  .page-head > div:last-child { flex-wrap: wrap; }

  .sec-cab { margin-bottom: 32px; }
  .section-head { flex-wrap: wrap; gap: 8px; }
  .section-head h2 { font-size: 24px; }

  /* Collapse multi-column inline-styled grids to single column. */
  .main [style*="repeat(2,"], .main [style*="repeat(3,"], .main [style*="repeat(4,"],
  .main [style*="repeat(2, "], .main [style*="repeat(3, "], .main [style*="repeat(4, "] {
    grid-template-columns: 1fr !important;
  }
  .main [style*="232px 1fr"], .main [style*="260px 1fr"], .main [style*="280px 1fr"],
  .main [style*="320px 1fr"], .main [style*="340px 1fr"], .main [style*="360px 1fr"],
  .main [style*="200px 1fr"], .main [style*="1fr 320px"], .main [style*="1fr 340px"],
  .main [style*="1fr 360px"], .main [style*="1fr 1fr"], .main [style*="1.1fr 1fr"],
  .main [style*="1.4fr 1fr auto"] {
    grid-template-columns: 1fr !important;
  }
  .planner { overflow-x: auto; grid-template-columns: 70px repeat(7, minmax(110px, 1fr)) !important; }

  .recipe-grid { grid-template-columns: 1fr 1fr !important; }
  .plans-grid { grid-template-columns: 1fr !important; }
  .plan.featured { transform: none !important; }
  .feat-grid { grid-template-columns: 1fr !important; }

  .hero, .brand-hero { padding: 44px 28px 36px !important; min-height: auto !important; margin-bottom: 28px !important; }
  .hero h1, .brand-hero__title { font-size: clamp(36px, 7vw, 52px) !important; }
  .hero .gen-form { max-width: 100% !important; padding: 4px 4px 4px 16px !important; }
  .hero .gen-form input { font-size: 14px !important; }
  .hero .gen-form button { padding: 10px 14px !important; font-size: 11.5px !important; }

  .recipe-hero { height: 280px !important; }
  .macro-ring svg { width: 180px !important; height: 180px !important; }

  .floater { right: 14px !important; }
  .timer-container { width: calc(100vw - 28px) !important; max-width: 320px; }

  .meal-table, .hist-table { display: block; overflow-x: auto; white-space: nowrap; }

  .modal-overlay { padding: 16px; }
  .modal { max-width: 100% !important; }
  .topnav .brand-sub { display: none; }
  .receita-messages { margin-bottom: 14px; }
}

/* === Phone (≤ 640px) === */
@media (max-width: 640px) {
  .main { padding: 18px 14px 48px; }
  .page-head h1 { font-size: clamp(28px, 8vw, 34px); line-height: 1.05; }
  .page-head .sub { font-size: 13.5px; }
  .section-head h2 { font-size: 22px; }
  .sec-titulo { font-size: clamp(30px, 9vw, 40px); }
  .card-pad { padding: 18px; }
  .card-head { padding: 14px 18px 0; }
  .card-title { font-size: 21px; }
  .recipe-grid { grid-template-columns: 1fr !important; }
  .main [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr 1fr !important; }

  .hero, .brand-hero { padding: 36px 22px 28px !important; border-radius: var(--r-lg) !important; }
  .hero h1, .brand-hero__title { font-size: clamp(28px, 9vw, 40px) !important; line-height: 1.05 !important; }
  .hero .sub, .brand-hero__sub { font-size: 14px !important; }
  .hero .gen-form { flex-direction: column; gap: 6px; border-radius: var(--r-lg) !important; padding: 8px !important; align-items: stretch !important; }
  .hero .gen-form input { padding: 10px 12px !important; }
  .hero .gen-form button { width: 100%; justify-content: center !important; padding: 12px !important; }

  .recipe-hero { height: 220px !important; }
  .recipe-hero .gradient { padding: 14px 18px !important; flex-direction: column; align-items: flex-start; gap: 8px; }
  .macro-ring svg { width: 150px !important; height: 150px !important; }

  .page-head > div:last-child { width: 100%; }
  .page-head > div:last-child .btn { flex: 1; justify-content: center; }

  .sidebar { padding: 22px 16px 20px; }
  .nav-item { padding: 11px 12px; font-size: 14px; }
  .stat { padding: 14px 16px; }
  .stat .val { font-size: 30px; }

  .step { grid-template-columns: 1fr !important; gap: 12px !important; padding: 32px 0 !important; }
  .step .num { font-size: 64px !important; }
  .step .body h2 { font-size: 32px !important; }

  .m-footer > div:first-child { grid-template-columns: 1fr !important; gap: 28px !important; }
  .m-footer { padding: 32px 22px 18px !important; }

  .plan { padding: 28px 22px !important; }
}

@media (max-width: 380px) {
  .main [style*="repeat(4, 1fr)"] { grid-template-columns: 1fr !important; }
  .main [style*="repeat(2, 1fr)"] { grid-template-columns: 1fr !important; }
  .page-head h1 { font-size: 28px; }
  .hero h1, .brand-hero__title { font-size: 28px !important; }
}

/* ============================================================
 * PALETA — receita. (Barro + Fervura)
 * ------------------------------------------------------------
 * Barro   #8B4423  primária — nav, botões, ligações, estados activos
 * Fervura #D9A05B  acento — só como *fundo* ou marca gráfica.
 *                  NUNCA como texto sobre papel (2:1); sobre Barro, sim.
 * Filete  #A62A3A  o sinal da família — usar pouco, aparecer sempre
 *                  (barra 60×6, pontos finais, sublinhados de secção)
 * Papel   #EFEBE0 / Papel claro #F6F3EC / Papel Barro #F0E5DA
 * Tinta   #0F1922  texto; Marginal #6D7580 texto secundário (4.6:1)
 *
 * Cantos rectos em todo o sistema (--r-sm/--r-md = 0). Excepções redondas:
 * .pill, .suggest-pill, .tool-pill, .avatar, .m-spinner, .btn-icon,
 * .ai-input .send, .ai-fab, e os pontos decorativos.
 *
 * Três tipos, nada mais: Instrument Serif (títulos), IBM Plex Sans (corpo),
 * IBM Plex Mono (rótulos, botões, meta). Nenhuma cor fora do bloco :root.
 * O card-assinatura .receita-card vive em receita-brand.css.
 * ============================================================ */
