/* Cyntia Receitas — caderno de receitas da família.
   Celular primeiro; tablet a partir de 640px; computador a partir de 1024px.
   Sem fontes externas: serifada e sem serifa do próprio sistema. */

:root {
  color-scheme: light;
  --paper: #faf6ef;
  --surface: #fffdf9;
  --surface-2: #f3ece1;
  --surface-3: #ebe2d4;
  --ink: #2d2723;
  --ink-2: #4a423b;
  --muted: #6a6057;
  --line: #e6ddcf;
  --line-strong: #d3c6b3;
  --field-border: #968772;
  --terra: #a94f2d;
  --terra-strong: #8f3f22;
  --terra-soft: #f7e5da;
  --terra-ink: #97431f;
  --on-primary: #ffffff;
  --orchid: #8a4a76;
  --orchid-soft: #f2e4ee;
  --sage: #4f6a48;
  --sage-soft: #e3ebdc;
  --gold: #d9a441;
  --gold-soft: #f8ecd2;
  --gold-ink: #6e5012;
  --rose-soft: #f9e3e3;
  --rose-ink: #9a3b48;
  --danger: #a3332a;
  --danger-soft: #f8e1dd;
  --whatsapp: #1a7f4b;
  --focus: #8a4a76;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, .06), 0 2px 8px rgba(60, 40, 20, .05);
  --shadow-md: 0 6px 24px rgba(60, 40, 20, .10);
  --shadow-lg: 0 18px 50px rgba(60, 40, 20, .18);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 18px;
  --gutter: max(16px, env(safe-area-inset-left));
  --gutter-r: max(16px, env(safe-area-inset-right));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #1d1916;
    --surface: #26211d;
    --surface-2: #2f2924;
    --surface-3: #3a332c;
    --ink: #f3ebe0;
    --ink-2: #dcd1c3;
    --muted: #b8ab9b;
    --line: #3d362f;
    --line-strong: #52493f;
    --field-border: #85786a;
    --terra: #e08a64;
    --terra-strong: #eba07f;
    --terra-soft: #3d2a22;
    --terra-ink: #f0a07c;
    --on-primary: #1d1310;
    --orchid: #dba3c8;
    --orchid-soft: #3a2834;
    --sage: #a9c29c;
    --sage-soft: #2b3327;
    --gold: #e0b45c;
    --gold-soft: #3b3120;
    --gold-ink: #ecc983;
    --rose-soft: #3d2528;
    --rose-ink: #eba1a9;
    --danger: #f08a7e;
    --danger-soft: #3f2522;
    --focus: #dba3c8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body:has(dialog[open]) { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .6; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--terra-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.eyebrow, .dialog-eyebrow {
  display: flex; align-items: center; gap: 8px;
  color: var(--orchid); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.orchid-mark { width: 22px; height: 22px; flex: none; color: var(--orchid); }
.orchid-center { fill: var(--gold); }

/* ---------- botões ---------- */
.primary-button, .secondary-button, .soft-button, .whatsapp-button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; border-radius: 14px; font-size: 16px; font-weight: 650; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.primary-button { border: 0; background: var(--terra); color: var(--on-primary); box-shadow: 0 2px 6px rgba(169, 79, 45, .25); }
.secondary-button { border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.soft-button {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 15px; font-weight: 600;
}
.soft-button .icon { color: var(--terra-ink); }
.whatsapp-button { border: 0; background: var(--whatsapp); color: #fff; }
.text-button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 8px; border: 0; background: none; color: var(--terra-ink);
  font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.icon-button {
  width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2);
}
.icon-button .icon { width: 22px; height: 22px; }
.wide { width: 100%; }
.primary-button:active, .secondary-button:active, .soft-button:active, .whatsapp-button:active { transform: scale(.98); }
@media (hover: hover) {
  .primary-button:hover:not(:disabled) { background: var(--terra-strong); }
  .secondary-button:hover:not(:disabled), .soft-button:hover { background: var(--surface-2); border-color: var(--line-strong); }
  .icon-button:hover { background: var(--surface-3); }
  .whatsapp-button:hover { filter: brightness(.93); }
}

/* ---------- campos ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 15px; font-weight: 650; color: var(--ink); }
.field-label small { font-size: 14px; font-weight: 400; color: var(--muted); }
.field-hint { font-size: 14px; color: var(--muted); line-height: 1.45; }
.field-hint em { font-style: normal; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--field-border); border-radius: 12px;
  background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; line-height: 1.55; min-height: 120px; field-sizing: content; max-height: 60vh; }
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887b6c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 22px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .85; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--terra); box-shadow: 0 0 0 4px var(--terra-soft);
}
.field input[readonly] { background: var(--surface-2); }
.field-row { display: grid; gap: 16px; }
.field-row.keep-row { grid-template-columns: 1fr 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
.form-error {
  padding: 12px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger);
  font-size: 15px; font-weight: 600;
}
.note { color: var(--muted); font-size: 14px; line-height: 1.55; }

/* mostrar/ocultar senha (criado pelo app.js) */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 56px; }
.password-toggle {
  position: absolute; top: 50%; right: 3px; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.password-toggle svg { width: 22px; height: 22px; }
.password-toggle[aria-pressed="true"] { color: var(--terra-ink); }

/* caixa de seleção grande (ingredientes e livro) */
.check-input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 26px; height: 26px; margin: 0; border: 2px solid var(--field-border); border-radius: 8px;
  background: var(--surface) center / 18px no-repeat; transition: background-color .15s ease, border-color .15s ease;
}
.check-input:checked {
  border-color: var(--sage); background-color: var(--sage);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  .check-input:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1916' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
}

/* ---------- entrada e convite ---------- */
.auth-screen {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter-r) max(24px, var(--safe-bottom)) var(--gutter);
  background:
    radial-gradient(circle at 12% 12%, var(--orchid-soft) 0, transparent 34%),
    radial-gradient(circle at 92% 88%, var(--sage-soft) 0, transparent 36%),
    radial-gradient(circle at 85% 8%, var(--gold-soft) 0, transparent 22%),
    var(--paper);
}
.auth-card {
  width: min(100%, 440px); padding: 32px 24px 24px; text-align: center;
  border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.auth-logo { width: 88px; height: 88px; margin: 0 auto 14px; display: block; }
.auth-card .eyebrow { justify-content: center; }
.wordmark { margin: 8px 0 10px; font-size: 38px; font-weight: 600; letter-spacing: -.01em; }
.wordmark span, .brand-name span { color: var(--orchid); font-style: italic; font-weight: 500; }
.auth-intro { margin: 0 auto 24px; max-width: 32ch; color: var(--muted); font-size: 16px; line-height: 1.5; }
.auth-form { display: grid; gap: 16px; text-align: left; }
.auth-form .primary-button { margin-top: 6px; min-height: 54px; font-size: 17px; }
.auth-form .field-hint { margin-top: -8px; }
.setup-help {
  margin-top: 20px; padding: 16px; border-radius: 16px; text-align: left;
  background: var(--gold-soft); color: var(--ink-2); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere;
}
.setup-help strong { color: var(--gold-ink); }
.install-link { margin-top: 14px; }
.auth-footnote { color: var(--muted); font-size: 14px; font-family: var(--serif); font-style: italic; text-align: center; }
@media (min-width: 480px) { .auth-card { padding: 40px 40px 28px; } }

/* ---------- cabeçalho ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px; height: 64px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter-r) 0 var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.sync-status {
  min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.sync-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 639px) {
  .sync-status { padding: 0; width: 44px; }
  .sync-status .sync-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.sync-dot {
  width: 10px; height: 10px; flex: none; border-radius: 50%;
  background: #4f9a5a; box-shadow: 0 0 0 3px color-mix(in srgb, #4f9a5a 22%, transparent);
}
.sync-dot[data-sync-tone="busy"] { background: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.sync-dot[data-sync-tone="offline"] { background: #c0563d; box-shadow: 0 0 0 3px color-mix(in srgb, #c0563d 22%, transparent); }
@keyframes pulse { 50% { opacity: .45; } }

.account-menu { position: relative; }
.account-button {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  list-style: none; cursor: pointer;
}
.account-button::-webkit-details-marker { display: none; }
.avatar {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: var(--orchid); color: var(--surface); font-family: var(--serif); font-size: 18px; font-weight: 600;
}
.account-menu[open] .account-button .avatar { box-shadow: 0 0 0 3px var(--orchid-soft); }
.avatar-large { width: 48px; height: 48px; font-size: 22px; }
.account-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40;
  width: min(310px, calc(100vw - 32px)); padding: 8px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg);
  animation: pop-in .16s ease-out;
}
.account-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 14px; }
.account-head div > * { display: block; }
.account-head strong { font-size: 17px; }
.account-head div span { color: var(--muted); font-size: 14px; }
.account-sync {
  display: flex; align-items: center; gap: 10px; margin: 0 4px 6px; padding: 10px 12px;
  border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: 14px;
}
.menu-item {
  width: 100%; min-height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  border: 0; border-radius: 12px; background: none; color: var(--ink); font-size: 16px; font-weight: 550; text-align: left;
}
.menu-item .icon { width: 22px; height: 22px; color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .icon { color: var(--danger); }
@media (hover: hover) { .menu-item:hover { background: var(--surface-2); } }

.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px var(--gutter-r) 8px var(--gutter);
  background: var(--gold-soft); color: var(--gold-ink); font-size: 14px; font-weight: 600; text-align: center;
}
.offline-banner:not([data-sync-tone="offline"]) { display: none; }

/* ---------- conteúdo ---------- */
.main-content {
  max-width: 1200px; margin: 0 auto;
  padding: 20px var(--gutter-r) calc(120px + var(--safe-bottom)) var(--gutter);
}
.hero { display: grid; gap: 16px; padding: 4px 0 18px; }
.hero h1 { margin: 8px 0 6px; font-size: 32px; font-weight: 500; letter-spacing: -.01em; }
.hero h1 em { color: var(--terra-ink); font-style: italic; }
.intro { color: var(--muted); font-size: 16px; }
#recipe-count { color: var(--ink-2); font-weight: 650; }
.hero-actions { display: flex; align-items: center; gap: 8px; }
.hero-actions .soft-button { flex: 0 1 auto; min-width: 0; }
.wide-only { display: none; }
@media (min-width: 420px) { .wide-only { display: inline; } }
/* caderno vazio: o convite para a primeira receita já está no centro da tela */
.main-content:has(#empty-state:not([hidden])) :is(.filters, .section-heading) { display: none; }
@media (max-width: 1023px) {
  .main-content:has(#empty-state:not([hidden])) .fab { display: none; }
}

/* botão flutuante “Nova receita” no celular e tablet */
.fab {
  position: fixed; z-index: 25;
  right: max(16px, calc(env(safe-area-inset-right) + 12px));
  bottom: calc(16px + var(--safe-bottom));
  min-height: 58px; padding: 0 24px 0 20px; border-radius: 999px;
  font-size: 17px; box-shadow: 0 10px 28px rgba(143, 63, 34, .35), 0 2px 6px rgba(143, 63, 34, .25);
}
.fab .icon { width: 24px; height: 24px; stroke-width: 2.2; }

.filters { display: grid; gap: 4px; margin-bottom: 8px; }
.search-box {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 54px;
  padding: 0 14px; border: 1.5px solid var(--line-strong); border-radius: 16px; background: var(--surface);
  box-shadow: var(--shadow-sm); cursor: text; transition: border-color .15s ease, box-shadow .15s ease;
}
.search-box > .icon { width: 22px; height: 22px; color: var(--muted); }
.search-box:focus-within { border-color: var(--terra); box-shadow: 0 0 0 4px var(--terra-soft); }
.search-box input {
  flex: 1; min-width: 0; height: 50px; border: 0; outline: none; background: transparent; font-size: 16px;
}
.search-box input::placeholder { color: var(--muted); }
.search-box kbd {
  padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2);
  color: var(--muted); font: 600 12px var(--sans);
}
.desktop-only { display: none; }
@media (min-width: 1024px) and (hover: hover) { .desktop-only { display: inline-block; } }

.category-chips {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter));
  padding: 10px var(--gutter-r) 6px var(--gutter);
}
.category-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; scroll-snap-align: start;
  border: 1.5px solid var(--line-strong); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.chip[aria-pressed="true"] { border-color: var(--terra); background: var(--terra); color: var(--on-primary); }
@media (hover: hover) { .chip:hover:not([aria-pressed="true"]) { background: var(--surface-2); } }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 12px 0 14px; }
.section-heading h2 { font-size: 22px; }
.result-count { color: var(--muted); font-size: 14px; }

/* ---------- cartões de receita ---------- */
.recipe-grid { display: grid; gap: 12px; }
.recipe-card {
  position: relative; display: grid; grid-template-columns: 92px 1fr; min-height: 116px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.recipe-card:active { transform: scale(.985); }
@media (hover: hover) { .recipe-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); } }
.recipe-art {
  display: grid; place-items: center; background: var(--art-bg); color: var(--art-ink);
  background-image: radial-gradient(color-mix(in srgb, var(--art-ink) 14%, transparent) 1.2px, transparent 1.3px);
  background-size: 14px 14px;
}
.recipe-art .icon { width: 44px; height: 44px; stroke-width: 1.4; }
.tone-0 { --art-bg: var(--terra-soft); --art-ink: var(--terra-ink); }
.tone-1 { --art-bg: var(--orchid-soft); --art-ink: var(--orchid); }
.tone-2 { --art-bg: var(--sage-soft); --art-ink: var(--sage); }
.tone-3 { --art-bg: var(--gold-soft); --art-ink: var(--gold-ink); }
.tone-4 { --art-bg: var(--rose-soft); --art-ink: var(--rose-ink); }
.recipe-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px 16px; }
.recipe-category { color: var(--art-ink, var(--orchid)); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.recipe-title {
  font-size: 19px; font-weight: 600; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-description {
  color: var(--muted); font-size: 14px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: auto; padding-top: 6px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.recipe-meta span { display: inline-flex; align-items: center; gap: 5px; }
.recipe-meta .icon { width: 16px; height: 16px; color: var(--muted); }

.no-results {
  grid-column: 1 / -1; display: grid; justify-items: center; gap: 8px; padding: 36px 16px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
}
.no-results strong { color: var(--ink); font-family: var(--serif); font-size: 20px; font-weight: 600; }

/* ---------- caderno vazio ---------- */
.empty-state {
  display: grid; justify-items: center; gap: 12px; margin-top: 8px; padding: 36px 20px 28px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: 24px; background: var(--surface);
}
.empty-illustration {
  width: 144px; height: 144px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--orchid-soft), var(--gold-soft));
}
.empty-illustration img { width: 112px; height: 112px; }
.empty-state h2 { font-size: 25px; font-weight: 500; }
.empty-state p { max-width: 40ch; color: var(--muted); }
.empty-state .primary-button { margin-top: 8px; }

.page-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 48px;
  color: var(--muted); font-family: var(--serif); font-size: 15px; font-style: italic; text-align: center;
}
.footer-heart { width: 16px; height: 16px; color: var(--terra-ink); fill: currentColor; }

/* ---------- folhas (diálogos) ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(35, 24, 18, .5); }
.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0;
  width: 100%; max-width: 100%; max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
  padding: 0; border: 0; border-radius: 24px 24px 0 0;
  background: var(--surface); box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1); }
.sheet[open]::backdrop { animation: fade-in .25s ease; }
.sheet-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 16px 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-header h2 { margin-top: 4px; font-size: 24px; }
.sheet-body { display: grid; gap: 18px; padding: 20px; }
.sheet-intro { color: var(--muted); font-size: 16px; }
.sheet-footer {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.sheet-footer > button { flex: 1; }
.sheet-footer .spacer { flex: 1; }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (min-width: 768px) {
  .sheet {
    inset: 0; margin: auto; width: min(680px, calc(100% - 48px));
    max-height: min(92dvh, 960px); border-radius: 24px;
  }
  .sheet[open] { animation: pop-in .2s ease-out; }
  .sheet-header { padding: 22px 20px 16px 28px; }
  .sheet-body { padding: 24px 28px; }
  .sheet-footer { justify-content: flex-end; padding: 14px 20px; }
  .sheet-footer > button { flex: 0 0 auto; min-width: 140px; }
  .install-dialog { width: min(560px, calc(100% - 48px)); }
  .detail-dialog { width: min(1000px, calc(100% - 48px)); }
}

/* ---------- receita aberta ---------- */
.detail-category {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--art-bg, var(--orchid-soft)); color: var(--art-ink, var(--orchid));
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.detail-header { align-items: center; border-bottom: 0; }
.detail-content { padding: 4px 20px 28px; }
.detail-title { font-size: 32px; font-weight: 600; letter-spacing: -.01em; }
.detail-description { margin-top: 10px; color: var(--ink-2); font-family: var(--serif); font-size: 18px; font-style: italic; line-height: 1.5; }
.detail-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin: 20px 0 8px; }
.detail-facts div {
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px;
  padding: 10px 14px; border-radius: 14px; background: var(--surface-2);
}
.detail-facts .icon { grid-row: span 2; width: 22px; height: 22px; color: var(--terra-ink); }
.detail-facts dt, .detail-facts dd { margin: 0; }
.detail-facts dt { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.detail-facts dd { font-size: 17px; font-weight: 650; }
.detail-section h3 {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 26px 0 8px; color: var(--terra-ink); font-size: 24px;
}
.detail-section h3 small { color: var(--muted); font-family: var(--sans); font-size: 13px; font-weight: 500; }
.ingredient-list, .step-list { margin: 0; padding: 0; list-style: none; }
.ingredient-list li { border-bottom: 1px dashed var(--line-strong); }
.ingredient-list li:last-child { border-bottom: 0; }
.ingredient-list label { display: flex; align-items: flex-start; gap: 14px; min-height: 54px; padding: 13px 2px; font-size: 18px; line-height: 1.45; cursor: pointer; }
.ingredient-list .check-input { margin-top: 1px; }
.ingredient-list strong { color: var(--ink); }
.ingredient-list .notes { color: var(--muted); }
.ingredient-list label:has(.check-input:checked) .ingredient-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.step-list { counter-reset: step; }
.step-list li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 14px 0; font-size: 18px; line-height: 1.65; }
.step-list li + li { border-top: 1px solid var(--line); }
.step-number {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%;
  background: var(--terra-soft); color: var(--terra-ink); font-family: var(--serif); font-size: 19px; font-weight: 700;
}
.delete-button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px;
  border: 1.5px solid transparent; border-radius: 14px; background: var(--danger-soft); color: var(--danger);
  font-size: 16px; font-weight: 650;
}
.sheet-footer .delete-button { flex: 0 0 auto; }
@media (min-width: 768px) {
  .detail-content { padding: 4px 32px 36px; }
  .detail-title { font-size: 40px; }
  .detail-header { padding-left: 32px; }
}
@media (min-width: 900px) {
  .detail-columns { display: grid; grid-template-columns: minmax(280px, 5fr) 7fr; gap: 44px; align-items: start; }
  .detail-ingredients { position: sticky; top: 76px; }
}

/* ---------- livro ---------- */
.book-selection-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 6px; }
.book-selection-heading strong { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.book-selection-heading span { color: var(--muted); font-size: 14px; }
.book-recipe-list { display: grid; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.book-recipe-option { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 14px; background: var(--surface); }
.book-recipe-option + .book-recipe-option { border-top: 1px solid var(--line); }
.book-recipe-label { flex: 1; min-width: 0; min-height: 56px; display: flex; align-items: center; gap: 14px; cursor: pointer; }
.book-recipe-label span { display: grid; min-width: 0; }
.book-recipe-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.book-recipe-label small { color: var(--muted); font-size: 13px; }
.book-order { display: flex; gap: 2px; }
.book-order .icon-button { background: transparent; }
.book-order .icon-button:disabled { opacity: .3; }

.book-preview-dialog {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 0; border: 0;
  background: var(--paper);
}
.book-preview-dialog[open] { display: flex; flex-direction: column; animation: fade-in .2s ease; }
.book-preview-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter-r) 10px var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.book-preview-toolbar h2 { font-size: 20px; margin-top: 2px; }
.book-preview-actions { display: flex; align-items: center; gap: 8px; }
#book-preview-frame { flex: 1; width: 100%; border: 0; background: #f4eee4; }
@media (max-width: 520px) {
  .book-preview-toolbar > div:first-child { flex: 1 1 100%; }
  .book-preview-actions { flex: 1 1 100%; }
  .book-preview-actions .primary-button { flex: 1; }
  #download-book span { display: none; }
  #download-book { padding: 0 14px; }
}

/* ---------- pessoas e convites ---------- */
.invite-form { display: grid; gap: 14px; }
@media (min-width: 640px) {
  .invite-form { grid-template-columns: 1fr 1fr; align-items: end; }
  .invite-form .primary-button, .invite-form .form-error { grid-column: 1 / -1; justify-self: start; }
}
.invite-link-box { display: grid; gap: 14px; padding: 18px; border-radius: 18px; background: var(--sage-soft); }
.invite-ready { display: flex; gap: 10px; color: var(--ink); font-size: 15px; line-height: 1.5; }
.invite-ready .icon { width: 24px; height: 24px; color: var(--sage); stroke-width: 2.4; }
.invite-send { display: flex; flex-wrap: wrap; gap: 10px; }
.invite-send > button { flex: 1 1 200px; }
#copy-invite-link { justify-self: start; }
.sharing-section h3 { margin: 6px 0 4px; font-size: 21px; }
.sharing-list { display: grid; }
.sharing-row { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.sharing-row:last-child { border-bottom: 0; }
.sharing-row-main { display: grid; min-width: 0; }
.sharing-row-main strong { font-size: 16px; overflow-wrap: anywhere; }
.sharing-row-main span { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.sharing-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sharing-row-actions select {
  min-height: 44px; padding: 0 40px 0 12px; border: 1.5px solid var(--field-border); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887b6c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 20px;
  appearance: none; -webkit-appearance: none; font-size: 16px;
}
.sharing-row-actions .secondary-button { min-height: 44px; padding: 0 14px; font-size: 15px; }
.sharing-status { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; }
.sharing-empty { padding: 12px 0; color: var(--muted); }
@media (min-width: 640px) {
  .sharing-row { grid-template-columns: 1fr auto; align-items: center; }
  .sharing-row-actions { justify-content: flex-end; }
}

/* ---------- instalar ---------- */
.install-dialog h3 { margin-bottom: 10px; font-size: 21px; }
.install-steps { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: passo; }
.install-steps li { position: relative; padding-left: 46px; font-size: 16px; line-height: 1.55; counter-increment: passo; }
.install-steps li::before {
  content: counter(passo); position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%;
  background: var(--orchid-soft); color: var(--orchid); font-family: var(--serif); font-weight: 700;
}

/* ---------- aviso rápido ---------- */
.toast {
  position: fixed; left: 50%; right: auto; top: auto; bottom: calc(92px + var(--safe-bottom)); z-index: 1000;
  width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 14px 20px;
  border: 0; border-radius: 16px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg);
  font-size: 15px; font-weight: 550; text-align: center; overflow: visible;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* ---------- tablet ---------- */
@media (min-width: 640px) {
  .topbar-inner { height: 70px; padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
  .main-content { padding: 32px max(24px, env(safe-area-inset-right)) calc(120px + var(--safe-bottom)) max(24px, env(safe-area-inset-left)); }
  .category-chips { margin: 0; padding: 12px 0 6px; flex-wrap: wrap; overflow: visible; }
  .hero h1 { font-size: 42px; }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .recipe-card { grid-template-columns: 1fr; grid-template-rows: 128px auto; min-height: 0; }
  .recipe-art .icon { width: 56px; height: 56px; }
  .recipe-card-body { padding: 16px 18px 18px; }
  .recipe-title { font-size: 21px; }
  .toast { bottom: calc(100px + var(--safe-bottom)); }
}

/* ---------- computador e tablet deitado ---------- */
@media (min-width: 1024px) {
  .main-content { padding: 40px 32px 48px; }
  .hero { grid-template-columns: 1fr auto; align-items: end; gap: 24px; padding-bottom: 26px; }
  .hero h1 { font-size: 50px; }
  .fab {
    position: static; min-height: 48px; padding: 0 22px; border-radius: 14px; font-size: 16px;
    box-shadow: 0 2px 6px rgba(169, 79, 45, .25);
  }
  .fab .icon { width: 20px; height: 20px; }
  .search-box { max-width: 560px; }
  .recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
  .toast { bottom: 32px; }
}

/* ---------- movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, *::backdrop {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ---------- filtro por autor ---------- */
.author-chips { padding-bottom: 0; }
.author-chip[aria-pressed="true"] { border-color: var(--orchid, #8e4a78); background: var(--orchid, #8e4a78); }
.recipe-author { margin: 6px 0 0; color: var(--muted); font-size: 13px; font-style: italic; }
.detail-author { margin: -4px 0 16px; color: var(--muted); font-size: 15px; font-style: italic; }
