:root {
  --green: #1f3b2d;
  --green-2: #2f5a44;
  --cream: #faf6ee;
  --paper: #ffffff;
  --sand: #efe6d4;
  --gold: #c9a24b;
  --ink: #1d1d1b;
  --muted: #6c6a63;
  --line: #e4dccb;
  --warn-bg: #fff4dc;
  --warn: #8a5a00;
  --danger: #a23a2a;
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
a.chip, a.btn, a.ghost, a.card { text-decoration: none; display: inline-block; }
a.card { display: flex; }

/* Topo */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--green); color: var(--cream);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--cream); font-family: var(--serif); font-weight: 650;
}
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.brand-name em { font-style: italic; color: var(--gold); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top select {
  background: transparent; color: var(--cream);
  border: 1px solid rgba(250,246,238,.35); border-radius: 999px;
  padding: 6px 10px; font-weight: 600; font-size: 14px;
}
.top select option { color: var(--ink); }
.top .ghost { color: var(--cream); border-color: rgba(250,246,238,.35); }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 96px; }

/* Botões */
button { cursor: pointer; }
.btn, .ghost {
  border-radius: 999px; padding: 11px 20px; font-weight: 600; font-size: 15px;
  border: 1px solid transparent; transition: background .15s, transform .1s;
}
.btn { background: var(--green); color: var(--cream); }
.btn:hover { background: var(--green-2); }
.btn:active, .ghost:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.ghost { background: transparent; border-color: var(--line); }
.ghost:hover { background: var(--sand); }
.small { padding: 6px 12px; font-size: 13px; }
.danger { color: var(--danger); border-color: #e8c4bd; }
.fab {
  position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom));
  box-shadow: 0 8px 24px rgba(31,59,45,.3); padding: 14px 22px; font-size: 16px;
}

/* Login */
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login form { display: grid; gap: 12px; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--paper);
}
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.6; }

/* Lista */
.head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 6vw, 40px); margin: 0; line-height: 1.1; }
.seal {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--green); background: var(--sand); border-radius: 999px; padding: 4px 10px;
}
.seal::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--green); color: var(--cream); border-color: var(--green); }
.search { margin-bottom: 18px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.06); }
.card .thumb { aspect-ratio: 4/3; background: var(--sand); object-fit: cover; width: 100%; }
.thumb-empty {
  aspect-ratio: 4/3; display: grid; place-items: center; background: var(--sand);
  font-family: var(--serif); font-size: 44px; color: var(--green); opacity: .5;
}
.card-body { padding: 12px 14px 14px; }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0 0 6px; line-height: 1.25; }
.meta { color: var(--muted); font-size: 13px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { font-family: var(--serif); font-weight: 500; color: var(--ink); }

/* Receita */
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: 14px; }
.recipe-hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; background: var(--sand); }
.recipe-hero img { width: 100%; max-height: 460px; object-fit: cover; }
.recipe h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 6vw, 44px); line-height: 1.1; margin: 8px 0 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; font-weight: 600; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.cols { display: grid; gap: 28px; margin-top: 24px; }
@media (min-width: 760px) { .cols { grid-template-columns: 1fr 1.5fr; } }
.cols h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0 0 12px; }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 18px 44px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green); color: var(--cream); font-weight: 600; font-size: 14px;
}
.recipe-actions { display: flex; gap: 8px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.missing { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-top: 14px; }

/* Editor */
.editor h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 0 0 18px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 4px; }
.panel .hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.drop {
  display: grid; place-items: center; gap: 6px; text-align: center;
  border: 2px dashed var(--line); border-radius: 12px; padding: 26px 16px;
  cursor: pointer; background: var(--cream);
}
.drop:hover { border-color: var(--gold); }
.drop strong { font-size: 16px; }
.drop span { color: var(--muted); font-size: 13px; }
.drop input { display: none; }
.preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 10px; }
.notes { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 12px 14px 12px 32px; margin: 0 0 16px; font-size: 14px; }
.notes-title { font-weight: 600; margin: 0 0 4px -18px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); }
label.f { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
label.f small { font-weight: 400; color: var(--muted); }
.catpick { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.loading { display: flex; gap: 12px; align-items: center; color: var(--muted); margin-top: 12px; }
.spin { width: 20px; height: 20px; border: 3px solid var(--sand); border-top-color: var(--green); border-radius: 50%; animation: r 0.8s linear infinite; }
@keyframes r { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; max-width: calc(100% - 32px);
}

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

.req { color: var(--danger); }
.panel.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(162,58,42,.12); }
.panel.invalid .hint { color: var(--danger); font-weight: 600; }

/* Várias fotos */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.thumbs:empty { display: none; }
.thumb-item { position: relative; width: 92px; height: 92px; }
.thumb-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb-item img[data-cover] { cursor: pointer; }
.thumb-item .x {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.thumb-item .badge {
  position: absolute; left: 6px; bottom: 6px; background: var(--green); color: var(--cream);
  font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px;
}
#readBtn { margin-top: 4px; }
.ok { color: var(--green); font-weight: 600; margin: 12px 0 0; }
.paste-target.active { border-color: var(--gold); }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin: -8px 0 18px; padding-bottom: 4px; }
.g-item { flex: 0 0 auto; width: 72px; height: 72px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: none; }
.g-item img { width: 100%; height: 100%; object-fit: cover; }
.g-item[aria-pressed="true"] { border-color: var(--green); }
