:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --line: #e7e1d6;
  --text: #2d2b28;
  --muted: #6f6a64;
  --accent: #d97706;
  --accent-soft: #fff1dd;
  --accent-deep: #9a5a00;
  --danger: #b42318;
  --radius: 22px;
  --shadow: 0 20px 50px rgba(31, 41, 55, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #faf7f2 0%, #f6f4ef 100%);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
.shell { max-width: 1180px; margin: 0 auto; }
.topbar {
  display: flex; justify-content: space-between; gap: 2rem; align-items: flex-end;
  padding: 2rem 1.2rem 1rem;
}
.topbar h1 { margin: 0; font-size: 2rem; }
.topbar p { margin: .3rem 0 0; color: var(--muted); }
.topbar nav { display: flex; flex-wrap: wrap; gap: .8rem; }
.topbar nav a {
  padding: .7rem 1rem; border-radius: 999px; background: rgba(255,255,255,.8);
  border: 1px solid var(--line);
}
.container { padding: 1rem 1.2rem 2.4rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; box-shadow: var(--shadow);
}
.soft-card { background: linear-gradient(180deg, #fff8ef 0%, #ffffff 100%); }
.hero, .detail-head, .page-head, .title-row, .actions-row, .meta-row, .search-grid, .two-col, .three-col, .triple-row { display: flex; gap: 1rem; }
.hero, .detail-head, .title-row { justify-content: space-between; align-items: center; }
.hero h2, .page-head h2, .detail-head h2 { margin: 0; }
.page-head { align-items: baseline; flex-direction: column; margin-bottom: 1rem; }
.actions-row { align-items: center; flex-wrap: wrap; }
.full-width { grid-column: 1 / -1; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 14px;
  padding: .8rem 1rem; font: inherit; cursor: pointer; transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.soft { background: var(--accent-soft); color: var(--accent-deep); border-color: #f5d7aa; }
.btn.ghost { background: transparent; }
.btn.danger, .danger { color: white; background: var(--danger); border-color: var(--danger); }
.btn.danger.ghost { color: var(--danger); background: #fff; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: .85rem 1rem; font: inherit; color: var(--text);
}
textarea { resize: vertical; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .96rem; }
.stack-form { display: grid; gap: 1rem; }
.stack-form.compact { gap: .75rem; }
.search-grid { display: grid; grid-template-columns: 1.8fr 1fr auto auto; margin: 1rem 0 1.4rem; align-items: center; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; }
.recipe-card { position: relative; overflow: hidden; padding: 0; }
.card-link { position: absolute; inset: 0; z-index: 1; }
.recipe-thumb { position: relative; aspect-ratio: 16/10; background: #f4efe7; }
.recipe-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { display: grid; place-items: center; height: 100%; font-size: 3rem; color: #c1b7a7; }
.edit-pill {
  position: absolute; z-index: 2; top: .9rem; right: .9rem; background: rgba(255,255,255,.92);
  border: 1px solid var(--line); width: 42px; height: 42px; display: grid; place-items: center; border-radius: 999px;
}
.recipe-content { padding: 1rem 1rem 1.1rem; display: grid; gap: .7rem; position: relative; z-index: 2; }
.stars { margin: 0; color: #f59e0b; letter-spacing: .08em; }
.emoji-row { display: flex; gap: .35rem; flex-wrap: wrap; font-size: 1.4rem; }
.emoji-row.big { font-size: 1.9rem; }
.meta-row { flex-wrap: wrap; font-size: .92rem; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
.pill {
  padding: .45rem .8rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid #f2d7a9; font-size: .92rem;
}
.pill.big { font-size: 1rem; }
.editor-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1rem; }
.editor-grid > :nth-child(2), .editor-grid > :nth-child(3), .editor-grid > :nth-child(4) { min-width: 0; }
.triple-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.ingredient-row { display: grid; gap: .7rem; padding: .85rem; border-radius: 18px; background: #fbfaf8; border: 1px solid #eee7dc; }
.ingredient-meta { grid-template-columns: 1fr 1.4fr 0; }
.ingredient-meta datalist { display: none; }
.equipment-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .75rem; }
.equip-tile {
  display: grid; gap: .35rem; padding: .85rem; border-radius: 18px; background: #fbfaf8; border: 1px solid #eee7dc;
  text-align: center; cursor: pointer; min-height: 96px; align-items: center;
}
.equip-tile span { font-size: 1.7rem; }
.equip-tile input { display: none; }
.equip-tile:has(input:checked) { border-color: #f2c17a; background: #fff1dd; }
.equip-tile.static { cursor: default; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.image-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; }
.image-card, .gallery-item {
  display: grid; gap: .5rem; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; padding: .6rem; background: #fffaf4;
}
.image-card img, .gallery-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 14px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.gallery-item.primary { border-color: #f0c276; background: #fff2df; }
.gallery-item figcaption { font-size: .9rem; color: var(--accent-deep); }
.inline-check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.inline-check input { width: auto; }
.danger-check { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1.15fr .85fr; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); }
.wide-gap { gap: 1rem; }
.top-gap { margin-top: 1rem; }
.clean-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .65rem; }
.clean-list.with-actions li, .inline-editor {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .6rem;
}
.inline-editor {
  grid-template-columns: 80px 1.5fr 1.5fr auto auto; padding: .65rem 0; border-top: 1px solid #f0ebe3;
}
.inline-editor input, .inline-editor select { padding: .7rem .8rem; }
.ingredient-editor { grid-template-columns: 72px 1.4fr 1fr auto auto; }
.tiny-btn {
  border: 0; background: #f4ede1; color: var(--text); border-radius: 999px; width: 34px; height: 34px; cursor: pointer;
}
.ingredient-pills { display: grid; gap: .7rem; }
.ingredient-pill {
  display: flex; align-items: center; gap: .8rem; border: 1px solid #efe6da; background: #fffaf4; border-radius: 18px; padding: .8rem .9rem;
}
.ingredient-pill .emoji { font-size: 1.7rem; }
.steps-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .8rem; }
.flash-stack { display: grid; gap: .6rem; margin-bottom: 1rem; }
.flash { border-radius: 16px; padding: .9rem 1rem; border: 1px solid; }
.flash.success { background: #ecfdf3; border-color: #b7ebc6; color: #146c2e; }
.flash.error { background: #fff2f0; border-color: #f5c2c7; color: #9f1239; }
.narrow { max-width: 460px; margin: 4rem auto 0; }
.empty { text-align: center; color: var(--muted); }
.shopping-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.shopping-group { padding: .9rem; border-radius: 18px; background: #fbfaf8; border: 1px solid #efe6da; }
.count-badge { background: #f4ede1; padding: .18rem .5rem; border-radius: 999px; font-size: .85rem; }
.accordion-list { display: grid; gap: .8rem; }
.accordion { border: 1px solid #efe6da; border-radius: 18px; background: #fbfaf8; overflow: hidden; }
.accordion summary { cursor: pointer; list-style: none; padding: 1rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion-body { padding: 0 1rem 1rem; display: grid; gap: .4rem; }
@media (max-width: 960px) {
  .topbar, .hero, .detail-head, .title-row { flex-direction: column; align-items: flex-start; }
  .editor-grid, .two-col, .three-col { grid-template-columns: 1fr; }
  .search-grid { grid-template-columns: 1fr; }
  .inline-editor, .ingredient-editor, .clean-list.with-actions li { grid-template-columns: 1fr; }
  .triple-row { grid-template-columns: 1fr; }
}


.image-panel { display: grid; gap: .8rem; }
.image-panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.gallery-compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.gallery-compact .gallery-item { padding: .5rem; }
.gallery-compact .gallery-item img { aspect-ratio: 1 / 1; max-height: 160px; object-fit: cover; }
.ingredient-groups { display: grid; gap: .85rem; }
.ingredient-group-card { border: 1px solid #efe6da; background: linear-gradient(180deg, #fffdf9 0%, #fff7ec 100%); border-radius: 20px; padding: .9rem; }
.ingredient-group-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .7rem; }
.ingredient-pills.pretty { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ingredient-pill.pretty { align-items: flex-start; background: rgba(255,255,255,.8); }
.ingredient-pill.pretty small { display: block; margin-top: .15rem; color: var(--muted); }
.compact-textarea { min-height: 88px; }
.comment-textarea { min-height: 120px; }
.step-textarea { min-height: 82px; }
.quick-nav { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.quick-chip { padding: .6rem .9rem; border-radius: 999px; background: #fff9ef; border: 1px solid #f3ddbb; color: var(--accent-deep); font-weight: 600; }
.quick-chip:hover { background: #fff1dd; }
.inline-create-grid { display: grid; grid-template-columns: 1.5fr 110px auto; gap: .75rem; align-items: center; }
.inline-create-grid-wide { grid-template-columns: 1.5fr 110px 1.3fr auto; }
.vocab-list { display: grid; gap: .7rem; }
.compact-editor { background: #fbfaf8; border: 1px solid #efe6da; border-radius: 18px; padding: .8rem; }
.compact-editor input, .compact-editor select { min-width: 0; }
.vocab-editor { grid-template-columns: 90px 1fr auto auto; }
.unit-editor { grid-template-columns: 1.5fr .8fr 120px auto auto; }
.filters-row { display: grid; gap: .75rem; }
.filters-row input { max-width: 480px; }
.roomy-accordion .accordion summary { padding: 1rem 1.1rem; }
.ingredient-listing { gap: .7rem; }
.vocab-bottom-grid { align-items: start; }

@media (max-width: 960px) {
  .gallery-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-create-grid, .inline-create-grid-wide, .vocab-editor, .unit-editor { grid-template-columns: 1fr; }
  .filters-row input { max-width: none; }
}


* { box-sizing: border-box; }
.form-field { display:flex; flex-direction:column; gap:.45rem; align-self:start; }
input, select { min-height: 52px; height: 52px; }
textarea { min-height: 96px; }
input[type="file"] { min-height: auto; height: auto; padding: .95rem 1rem; }
.search-grid-wide { grid-template-columns: minmax(220px, 1.5fr) minmax(170px, .9fr) minmax(190px, 1fr) auto auto; }
.inline-import-form { margin: 0; }
.file-inline { position: relative; overflow: hidden; cursor: pointer; display:inline-flex; align-items:center; gap:.5rem; padding:.8rem 1rem; border:1px solid var(--line); border-radius:14px; background:#fff; color:var(--text); }
.file-inline input { position:absolute; inset:0; opacity:0; cursor:pointer; min-height:auto; height:auto; }
.card-tools { position:absolute; top:.9rem; right:.9rem; display:flex; gap:.45rem; z-index:2; }
.card-tools form { margin:0; }
.danger-pill { background: rgba(220, 38, 38, .94); color:#fff; border-color: rgba(220, 38, 38, .94); }
.compact-image-list { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.compact-image-card img { aspect-ratio: 1 / 1; max-height: 120px; object-fit: cover; }
.ingredient-grid-top, .ingredient-grid-bottom { display:grid; gap:.7rem; }
.ingredient-grid-top { grid-template-columns: 180px 1fr; }
.ingredient-grid-bottom { grid-template-columns: minmax(120px, .7fr) minmax(140px, .8fr) auto; align-items:center; }
.ingredient-row { gap:.8rem; }
.gallery-compact .gallery-item img { max-height: 150px; }
@media (max-width: 960px) {
  input, select { min-height: 48px; height: 48px; }
  .search-grid-wide { grid-template-columns: 1fr; }
  .ingredient-grid-top, .ingredient-grid-bottom { grid-template-columns: 1fr; }
  .card-tools { right:.6rem; top:.6rem; }
}

/* V5 refinements */
.recipe-thumb-link { display:block; text-decoration:none; }
.title-link { color: inherit; text-decoration: none; }
.title-link:hover { color: var(--accent-deep); }
.dashboard-card { overflow: hidden; }
.card-actions { display:flex; flex-wrap:wrap; gap:.55rem; margin-top:.2rem; }
.card-actions form { margin:0; }
.btn.mini { padding:.68rem .9rem; font-size:.92rem; border-radius:12px; }
.recipe-content .btn.mini.soft { background:#fff5e7; }
.recipe-content .btn.mini.danger { background:#fff0ee; color:#b42318; border-color:#f4c7c3; }
.recipe-card .recipe-thumb { aspect-ratio: 16 / 9; }

form.editor-grid input,
form.editor-grid select,
form.editor-grid textarea { width:100%; max-width:100%; }
.triple-row { align-items:start; grid-template-columns: minmax(0,1.15fr) minmax(0,.9fr) minmax(0,.9fr); }
.triple-row .form-field input,
.triple-row .form-field select { width:100%; }
.ingredient-grid-top input,
.ingredient-grid-top select,
.ingredient-grid-bottom input,
.ingredient-grid-bottom select { width:100%; }
.ingredient-grid-bottom { grid-template-columns: minmax(120px,.7fr) minmax(140px,.8fr) auto; }
.ingredient-grid-bottom .btn { white-space:nowrap; }
input[type="number"] { appearance:textfield; -moz-appearance:textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { opacity:1; }
.file-inline,
input[type="file"] { width:100%; }
.stack-form { gap: .95rem; }
.compact-textarea { min-height: 74px; }
.comment-textarea { min-height: 110px; }
.step-textarea { min-height: 72px; }
.recipe-card .placeholder { min-height: 180px; }

@media (max-width: 960px) {
  .card-actions { flex-direction:column; align-items:stretch; }
  .card-actions .btn, .card-actions form { width:100%; }
}
