:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--brand); text-decoration: none; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 16px; position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { background: #eef2ff; color: var(--brand); }
.menu-toggle { display: none; font-size: 22px; background: none; border: none; cursor: pointer; }
.logout { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

button, .btn {
  background: var(--brand); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button.secondary { background: #eef2ff; color: var(--brand); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.small { padding: 4px 10px; font-size: 13px; }

input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
textarea { resize: vertical; min-height: 70px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.recipe-card { cursor: pointer; overflow: hidden; padding: 0; transition: transform .1s, box-shadow .1s; }
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.recipe-card img { width: 100%; height: 150px; object-fit: cover; background: #eef2ff; }
.recipe-card .body { padding: 12px; }
.recipe-card h3 { margin: 0 0 4px; font-size: 16px; }
.tag { display: inline-block; background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 2px 10px; font-size: 12px; margin: 2px 3px 0 0; }
.pill { background: #f1f5f9; color: var(--muted); border-radius: 999px; padding: 2px 9px; font-size: 12px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 140px; }

.ing-row, .step-row { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; flex-wrap: wrap; }
.ing-row input[type=text], .ing-row input[type=number] { width: auto; flex: 1; min-width: 90px; }
.ing-row .name { min-width: 140px; flex: 2; }
.ing-row select { width: auto; }
.drag-handle { cursor: grab; padding: 8px 4px; color: var(--muted); user-select: none; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 10px;
  transition: transform .25s; z-index: 100; max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 14px; }
.error-box { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 8px; margin: 8px 0; }

.section-block { margin-bottom: 18px; }
.section-block h3 { margin: 0 0 6px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.list-item.checked span.name { text-decoration: line-through; color: var(--muted); }
.list-item input[type=checkbox] { width: 20px; height: 20px; }
.list-item .name { flex: 1; }

.detail-hero img { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--radius); }
table.ing { width: 100%; border-collapse: collapse; }
table.ing td, table.ing th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }

.sidebar-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.sidebar { max-height: 75vh; overflow-y: auto; }
.mini-recipe { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; }
.mini-recipe img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #eef2ff; }

@media (max-width: 720px) {
  .topbar nav { display: none; position: absolute; top: 52px; left: 0; right: 0; background: #fff; flex-direction: column; border-bottom: 1px solid var(--line); padding: 8px; }
  .topbar nav.open { display: flex; }
  .menu-toggle { display: block; }
  .sidebar-layout { grid-template-columns: 1fr; }
  .brand { flex: 1; }
}
