:root {
  --bg: #fff7f0;
  --card: #ffffff;
  --ink: #2a1d17;
  --muted: #8b7a70;
  --line: #f0e2d6;
  --brand: #e8552b;
  --brand-dark: #c8431e;
  --brand-soft: #ffe9df;
  --green: #3f9d5a;
  --danger: #d43d3d;
  --shadow: 0 6px 24px rgba(120, 70, 40, 0.10);
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- buttons ---------- */
button { font: inherit; cursor: pointer; border: none; border-radius: 12px; }
.btn-primary {
  background: var(--brand); color: #fff; padding: 11px 16px; font-weight: 600;
  transition: background .15s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: transparent; color: var(--muted); padding: 9px 12px; font-weight: 600;
}
.btn-ghost:hover { background: var(--line); color: var(--ink); }
.btn-danger {
  background: transparent; color: var(--danger); padding: 11px 16px; font-weight: 600;
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---------- login ---------- */
.login-view {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #ffd9c7 0%, var(--bg) 55%);
}
.login-card {
  background: var(--card); width: 100%; max-width: 360px; padding: 32px 26px;
  border-radius: 22px; box-shadow: var(--shadow); text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.login-emoji { font-size: 52px; line-height: 1; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -0.5px; }
.login-card p { margin: 0 0 8px; }
.login-card input, .toolbar input, .modal-card input, .modal-card textarea {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); font: inherit;
}
.login-card input:focus, .toolbar input:focus,
.modal-card input:focus, .modal-card textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* ---------- app shell ---------- */
.app-view { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; padding: 16px 4px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.brand span { margin-right: 4px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.toolbar { padding: 4px 0 16px; }

/* ---------- list ---------- */
.list { display: grid; gap: 12px; }
.recipe {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, border-color .12s;
}
.recipe:hover { transform: translateY(-2px); border-color: #f0cdb9; }
.recipe-img { width: 100%; height: 168px; background: var(--brand-soft); }
.recipe-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-body { padding: 16px 18px; }
.recipe h3 { margin: 0 0 6px; font-size: 18px; }
.recipe .snippet { color: var(--muted); font-size: 14px; margin: 0; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  background: var(--brand-soft); color: var(--brand-dark); font-size: 12px;
  font-weight: 600; padding: 3px 9px; border-radius: 999px;
}

.empty { text-align: center; color: var(--muted); padding: 60px 20px; display: grid; gap: 12px; place-items: center; }
.empty-emoji { font-size: 48px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; }
@media (min-width: 640px) { .modal { place-items: center; } }
.modal-backdrop { position: absolute; inset: 0; background: rgba(40, 25, 15, 0.45); }
.modal-card {
  position: relative; background: var(--card); width: 100%; max-width: 520px;
  max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 20px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
@media (min-width: 640px) { .modal-card { border-radius: 22px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 20px; }
/* image field in modal */
.image-field { display: flex; gap: 14px; align-items: center; }
.img-preview {
  width: 96px; height: 96px; border-radius: 14px; overflow: hidden; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--brand-soft);
  display: grid; place-items: center;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-placeholder { font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }
.image-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.file-btn { border: 1px solid var(--line); cursor: pointer; }
.file-btn:hover { background: var(--brand-soft); color: var(--brand-dark); }

.modal-card label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.modal-card textarea { resize: vertical; line-height: 1.45; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.modal-foot .spacer { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 40; box-shadow: var(--shadow);
}
