:root {
  --bg: #f7f1e6;
  --card: #fffdf8;
  --ink: #2b2420;
  --muted: #7a6e64;
  --line: #e4d8c6;
  --accent: #c8323c;
  --accent-ink: #ffffff;
  --chip: #efe4d2;
  --focus: #e58a2e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1916; --card: #27221e; --ink: #f2ebe2; --muted: #b3a597;
    --line: #3d352e; --accent: #e0545d; --chip: #352e28;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 17px; line-height: 1.7;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px 80px; }
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header.top .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: .02em; text-decoration: none; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .1em; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--accent); border-color: var(--accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.search { display: flex; gap: 8px; margin: 18px 0 10px; }
.search input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--chip); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.card {
  display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); text-decoration: none;
}
.thumb {
  flex: none; width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: var(--chip);
  display: grid; place-items: center; font-size: 28px; color: var(--muted);
}
.card h3 { margin: 0; font-size: 17px; line-height: 1.4; }
.card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.recipe h1 { font-size: 26px; line-height: 1.35; margin: 18px 0 4px; }
.meta { color: var(--muted); font-size: 14px; }
.hero { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); margin: 14px 0; }
section.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
section.block h2 { font-size: 18px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scale { display: inline-flex; gap: 6px; margin-left: auto; }
.scale button { min-width: 48px; min-height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.scale button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
table.ing { width: 100%; border-collapse: collapse; font-size: 18px; }
table.ing td { padding: 8px 4px; border-bottom: 1px dashed var(--line); vertical-align: top; }
table.ing td.amt { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
ol.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
ol.steps li { counter-increment: s; display: grid; grid-template-columns: 40px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 18px; }
ol.steps li::before {
  content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
ol.steps img { display: block; max-width: 100%; border-radius: 10px; margin-top: 8px; }
.tips { white-space: pre-wrap; font-size: 18px; }

/* editor */
.form label { display: block; font-weight: 700; margin: 14px 0 6px; }
.form input[type=text], .form textarea, .form select {
  width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
.form textarea { min-height: 90px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 90px 80px 40px; gap: 6px; margin-bottom: 6px; }
.row.step { grid-template-columns: 1fr 40px; }
.row button { min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.photo-pick { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.photo-pick img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; }
.step-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--chip); margin: 12px 0; }
.notice.err { background: #fbe1e1; color: #8a1c22; }
@media (prefers-color-scheme: dark) { .notice.err { background: #4a2124; color: #ffd9db; } }
.confirm { display: none; }
.confirm.open { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; text-align: center; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.login input { width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); margin-bottom: 12px; font-size: 18px; }
.login .btn { width: 100%; }

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr 70px 56px 40px; }
  .recipe h1 { font-size: 23px; }
}
@media print {
  header.top, .scale, .actions, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  section.block { border-color: #999; break-inside: avoid; }
}
