@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/kalam-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/kalam-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/kalam-bold-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Kalam";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/kalam-bold-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --brown-900: #5c3a24;
  --brown-800: #7f5539;
  --brown-700: #9c6644;
  --brown-500: #b08968;
  --sand-400: #ddb892;
  --sand-300: #e6ccb2;
  --sand-200: #ede0d4;
  --sand-100: #f6eee6;
  --cream: #f6eee6;
  --ink: #3d2b1f;
  --muted: #7a6456;
  --white: #fffdfb;
  --danger: #9b3d2c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(92, 58, 36, 0.08);
  --tabbar-h: 72px;
  --font: "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-display: "Kalam", "Nunito", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { min-height: 100%; background: var(--cream); }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  min-height: 100%;
  line-height: 1.45;
}
[hidden] { display: none !important; }
img, video { max-width: 100%; }
a { color: var(--brown-800); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 0.4em;
  line-height: 1.25;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 1.4rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  color: var(--brown-900);
  background: #fff;
  border-top: 5px solid var(--brown-800);
  box-shadow: 0 18px 56px 10px rgba(61, 43, 31, 0.22);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 1.35rem; font-family: var(--font-display); line-height: 1; }
.topbar .brand { color: var(--brown-900); }
.brand-lg { margin-bottom: 18px; }
.brand-lg p { margin: 0; color: var(--muted); font-weight: 400; font-size: 0.95rem; font-family: var(--font); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: block; object-fit: cover;
  flex: none;
}
.topbar .brand-mark {
  box-shadow: 2px 3px 0 rgba(92, 58, 36, 0.12), 0 6px 16px rgba(92, 58, 36, 0.16);
  transform: rotate(-6deg);
}
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; height: 36px; line-height: 1;
  border-radius: 10px; color: var(--brown-800); font-weight: 600;
}
.topnav a:hover { background: rgba(127, 85, 57, 0.1); }
.topbar-scallop {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='12' viewBox='0 0 22 12'%3E%3Cpath fill='%23ffffff' d='M0 0h22v1C16.5 1 16.5 11 11 11S5.5 1 0 1V0z'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 22px 12px;
  pointer-events: none;
  filter: drop-shadow(0 18px 22px rgba(61, 43, 31, 0.28));
}

.page {
  width: min(1100px, calc(100% - 28px));
  margin: 44px auto 100px;
}

.tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(251, 246, 240, 0.96);
  border-top: 1px solid rgba(176, 137, 104, 0.3);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  grid-template-columns: repeat(4, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.72rem; color: var(--brown-800); padding: 4px;
}
.tabbar svg { width: 22px; height: 22px; fill: currentColor; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid rgba(221, 184, 146, 0.45);
}
.auth-body { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-wrap { width: min(420px, 100%); }
.auth-card h1 { margin-bottom: 8px; }
.lede { color: var(--muted); margin-top: 0; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.opt { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.92rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--sand-400);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  line-height: 1.35;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--brown-700);
  box-shadow: 0 0 0 3px rgba(156, 102, 68, 0.18);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; border-radius: 10px;
  height: 42px; padding: 0 16px;
  font-family: var(--font); font-weight: 600; font-size: 0.95rem;
  line-height: 1; text-decoration: none;
  background: var(--sand-300); color: var(--ink);
}
a.btn { color: inherit; }
.btn-primary,
a.btn-primary { background: var(--brown-800); color: var(--sand-200); }
.btn-ghost { background: #fff; border: 1px solid var(--sand-400); }
.btn-danger-ghost,
a.btn-danger-ghost { background: #fff; color: var(--danger); border: 1px solid rgba(155, 61, 44, 0.3); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--sand-300);
  cursor: pointer; font-size: 1.15rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; flex: none;
}

.flash { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; }
.flash-ok { background: #e8f3e4; color: #2f5d32; }
.flash-err { background: #f8e4df; color: var(--danger); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 10px;
  padding: 0 14px; height: 44px;
  border: 1px solid rgba(176, 137, 104, 0.35);
}
.search-icon { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { border: 0; background: transparent; padding: 0; height: 42px; }
.search input:focus { box-shadow: none; }
.btn-new {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 14px;
  border-radius: 10px; font-weight: 700; font-size: 0.92rem; line-height: 1;
  color: var(--brown-800); background: #fff;
  border: 1px solid rgba(176, 137, 104, 0.35);
  white-space: nowrap;
}
.btn-new:hover { background: var(--sand-300); }
#recipe-results.is-loading { opacity: 0.55; pointer-events: none; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.sort-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.sort-bar + .sort-bar { margin-top: -8px; }
.chip {
  display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 8px;
  background: var(--sand-300); color: var(--ink); font-size: 0.86rem; border: 0; cursor: pointer; line-height: 1;
}
.chip-sm { font-size: 0.75rem; padding: 3px 8px; }
.chip-on { background: var(--brown-800); color: var(--sand-200); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.recipe-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  display: flex; flex-direction: column;
  border: 1px solid rgba(221, 184, 146, 0.4);
  position: relative;
}
.recipe-card-main {
  color: inherit;
  display: flex; flex-direction: column; flex: 1;
  min-width: 0;
}
.recipe-card-tools {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: flex; gap: 6px; align-items: center;
}
.recipe-card-share {
  height: 32px; padding: 0 10px; border: 0; border-radius: 8px;
  background: rgba(255, 253, 251, 0.94); color: var(--brown-800);
  font-weight: 600; font-size: 0.8rem; font-family: var(--font);
  line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(61, 43, 31, 0.16);
}
.recipe-card-share:hover, .recipe-card-fav:hover { background: #fff; }
.recipe-card-fav {
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px;
  background: rgba(255, 253, 251, 0.94); color: var(--brown-800);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(61, 43, 31, 0.16);
}
.recipe-card-fav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.recipe-card-fav.is-on { color: #c45c4a; }
.recipe-card-fav.is-on svg { fill: currentColor; }
.recipe-card-media {
  position: relative; aspect-ratio: 4 / 3; background: var(--sand-300); overflow: hidden;
}
.recipe-card-media img, .recipe-card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 3rem; font-family: var(--font-display); color: var(--brown-800);
  background: var(--sand-200);
}
.play-badge {
  position: absolute; left: 10px; bottom: 10px; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(61, 43, 31, 0.72);
  display: flex; align-items: center; justify-content: center;
}
.play-badge::before {
  content: "";
  width: 0; height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent #fff;
  margin-left: 2px;
}
.recipe-card-body { padding: 14px 16px 16px; }
.recipe-card-body h2 { font-size: 1.15rem; margin: 0 0 6px; }
.recipe-card-body p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(127, 85, 57, 0.9); color: var(--sand-200);
  border-radius: 8px; padding: 4px 10px; font-size: 0.75rem; line-height: 1;
}

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.js-infinite { height: 1px; pointer-events: none; }

.mode-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--sand-300); padding: 4px; border-radius: 12px; margin: 8px 0 16px;
}
.mode-btn {
  border: 0; background: transparent; border-radius: 8px;
  height: 40px; padding: 0 12px; cursor: pointer; font-weight: 600;
  font-family: var(--font); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.mode-btn.is-on { background: var(--white); color: var(--brown-800); box-shadow: var(--shadow); }

.recipe-form { display: flex; flex-direction: column; gap: 16px; padding-bottom: 24px; }
.form-block {
  display: flex; flex-direction: column; gap: 12px;
  margin: 8px 0 4px; padding: 20px 0 8px;
  border-top: 1px solid rgba(176, 137, 104, 0.22);
}
.form-block h2 { margin: 0; }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dropzone {
  border: 2px dashed var(--brown-500); border-radius: var(--radius);
  padding: 22px; text-align: center; background: rgba(255, 253, 251, 0.6); cursor: pointer;
}
.dropzone.is-over { background: var(--sand-300); }
.drop-preview { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }
.preview-item { position: relative; width: 88px; height: 88px; }
.preview-item img, .preview-item video {
  width: 88px; height: 88px; object-fit: cover; border-radius: 12px; display: block;
}
.preview-remove {
  position: absolute; top: -7px; right: -7px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: var(--brown-800); color: var(--sand-200);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.row-list { display: flex; flex-direction: column; gap: 8px; }
#ing-groups { display: flex; flex-direction: column; gap: 14px; }
.ing-group {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--sand-100); border: 1px solid var(--sand-400);
  border-radius: var(--radius); padding: 12px;
}
.ing-group-head { display: flex; gap: 8px; align-items: center; }
.ing-group-head .ing-group-title { font-weight: 700; }
.ing-row, .step-row {
  display: flex; gap: 8px; align-items: center; background: #fff;
  border-radius: var(--radius-sm); padding: 10px; border: 1px solid var(--sand-400);
}
.ing-row.is-dragging, .step-row.is-dragging {
  opacity: 0.7; box-shadow: var(--shadow); z-index: 4; position: relative;
}
.drag-handle {
  flex: none; width: 28px; height: 36px; padding: 0; margin: 0 -2px 0 0;
  border: 0; border-radius: 8px; background: transparent; cursor: grab;
  touch-action: none; color: var(--muted); user-select: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; letter-spacing: -2px; line-height: 1;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:focus { box-shadow: 0 0 0 3px rgba(156, 102, 68, 0.18); }
.ing-row input, .step-row textarea { background: #fff; }
.w-sm { max-width: 72px; }
.w-md { max-width: 100px; }
.step-num {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brown-800); color: var(--sand-200);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; line-height: 1; flex: none;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.media-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.media-edit {
  background: #fff; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--sand-400); cursor: grab;
}
.media-edit:active { cursor: grabbing; }
.media-edit-thumb {
  position: relative; aspect-ratio: 1; background: var(--sand-300);
}
.media-edit-thumb img, .media-edit-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-cover-badge {
  display: none; position: absolute; left: 8px; top: 8px; z-index: 1;
  background: var(--brown-800); color: var(--sand-200);
  font-size: 0.72rem; font-weight: 700; line-height: 1;
  padding: 5px 8px; border-radius: 6px;
}
.media-edit.is-cover .media-cover-badge { display: inline-flex; }
.media-edit-del {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: rgba(255, 253, 251, 0.95); color: var(--danger);
  box-shadow: 0 2px 8px rgba(61, 43, 31, 0.18);
  cursor: pointer; font-size: 1.15rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.media-edit-del:hover { background: #fff; }
.media-edit-bar {
  display: grid; grid-template-columns: 36px 36px minmax(0, 1fr);
  gap: 6px; padding: 8px; align-items: center;
}
.media-edit-bar .icon-btn {
  width: 36px; height: 36px; background: var(--sand-100);
  border: 1px solid var(--sand-400);
}
.media-cover-btn {
  height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--sand-400); background: #fff;
  color: var(--brown-800); font-weight: 600; font-size: 0.82rem;
  font-family: var(--font); cursor: pointer; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-edit.is-cover .media-cover-btn {
  background: var(--brown-800); color: var(--sand-200); border-color: var(--brown-800);
}

.recipe-detail { display: flex; flex-direction: column; gap: 16px; }
.detail-back {
  align-self: flex-start;
  color: var(--brown-800); font-weight: 600; text-decoration: none;
  padding: 4px 0;
}
.detail-back:hover { text-decoration: underline; }
.hero-media {
  border: 0; padding: 0; background: var(--sand-300); border-radius: 14px; overflow: hidden;
  width: 100%; cursor: zoom-in; display: block;
}
.hero-media img, .hero-media video { width: 100%; max-height: 70vh; object-fit: cover; display: block; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.recipe-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: flex-end;
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(127, 85, 57, 0.06);
  border: 1px solid rgba(176, 137, 104, 0.28);
  border-radius: 10px;
}
.fact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 72px;
}
.fact-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  font-family: var(--font);
  line-height: 1;
}
.fact-value { font-weight: 700; color: var(--brown-900); font-size: 1rem; }
.fact-servings { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin: 0; }
.servings-ctrl { display: inline-flex; align-items: center; gap: 4px; }
.servings-ctrl input[type="text"] {
  width: 72px; height: 36px; padding: 6px 8px; text-align: center;
  font-weight: 700; font-size: 1rem;
}
.servings-ctrl button {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--sand-400);
  background: #fff; color: var(--brown-800); cursor: pointer;
  font-size: 1.15rem; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.servings-ctrl button:hover { background: var(--sand-200); }
.chips-user { margin-top: 12px; }
.prose { background: var(--white); border-radius: var(--radius); padding: 18px 20px; white-space: pre-wrap; box-shadow: var(--shadow); }
.check-list {
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.check-list li { border-bottom: 1px solid var(--sand-200); }
.check-list li:last-child { border-bottom: 0; }
.check-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px;
  margin: 0;
  cursor: pointer;
  font-weight: 400;
  font-size: 1rem;
  user-select: none;
}
.check-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 22px; height: 22px; margin: 2px 0 0; padding: 0;
  flex: none; cursor: pointer;
  border: 2px solid var(--brown-500);
  border-radius: 6px;
  background: #fff;
}
.check-item input[type="checkbox"]:checked {
  background: var(--brown-800) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23f8f1e8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.5 5 9l5-6'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--brown-800);
}
.check-item input[type="checkbox"]:focus { box-shadow: 0 0 0 3px rgba(156, 102, 68, 0.18); }
.check-num {
  width: 22px; height: 22px; margin-top: 2px; flex: none;
  border-radius: 6px; background: var(--sand-200); color: var(--brown-800);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; line-height: 1;
}
.check-text { flex: 1; min-width: 0; line-height: 1.45; }
.check-text strong { margin-right: 0.35em; }
.check-item.is-done .check-text,
.check-item.is-done .check-num {
  text-decoration: line-through;
  color: var(--muted);
  background: transparent;
}
.ing-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 16px 0 8px;
  color: var(--brown-900);
}
.recipe-detail h2 + .ing-heading { margin-top: 2px; }
.recipe-detail .check-list + .ing-heading { margin-top: 22px; }
.recipe-detail .check-list + .check-list { margin-top: 12px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.gallery-item { position: relative; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--sand-300); cursor: zoom-in; }
.gallery-item img, .gallery-item video { width: 100%; height: 160px; object-fit: cover; display: block; pointer-events: none; }
.gallery-play, .hero-media .gallery-play {
  position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%;
  background: rgba(251, 246, 240, 0.92); color: var(--brown-800);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; pointer-events: none; line-height: 1; padding: 0 0 1px 3px;
}
.hero-media { position: relative; }
.hero-media .gallery-play { width: 64px; height: 64px; font-size: 1.4rem; }

.player { position: relative; background: #1c120c; border-radius: 12px; overflow: hidden; }
.player video { width: 100%; display: block; max-height: 70vh; background: #000; }
.player-play {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: rgba(251, 246, 240, 0.92); color: var(--brown-800); font-size: 1.4rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0 0 1px 3px;
}
.player.is-playing .player-play { opacity: 0; pointer-events: none; }
.player-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff;
  pointer-events: auto;
  touch-action: auto;
}
.player-bar button { background: transparent; border: 0; color: #fff; cursor: pointer; }
.player-seek {
  position: relative; flex: 1; height: 28px; cursor: pointer; touch-action: none;
}
.player-seek::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px;
  margin-top: -2px; border-radius: 99px; background: rgba(255,255,255,.35);
}
.player-seek-fill {
  position: absolute; left: 0; top: 50%; height: 4px; margin-top: -2px;
  width: 0; border-radius: 99px; background: #fff; pointer-events: none; z-index: 1;
}
.player-time { font-size: 0.8rem; min-width: 64px; }
.player:fullscreen, .player:-webkit-full-screen {
  width: 100%; height: 100%; border-radius: 0; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.player:fullscreen video, .player:-webkit-full-screen video {
  width: 100%; height: 100%; max-height: none; object-fit: contain;
}

.modal {
  position: fixed; inset: 0; background: rgba(61, 43, 31, 0.45);
  display: grid; place-items: end center; z-index: 50; padding: 12px;
}
.modal-card {
  background: var(--cream); width: min(520px, 100%);
  border-radius: 16px; padding: 22px 22px 26px;
  max-height: 86vh; overflow: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-card header h2,
.modal-card h3 { margin: 0; }
.modal-card > p { margin: 0; }
.result-list { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.result-list:empty { display: none; }
.result-list button {
  text-align: left; border: 0; background: var(--white); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.share-list { list-style: none; padding: 0; margin: 0; }
.share-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; }
.chip-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.group-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.member-list { list-style: none; padding: 0; margin: 0 0 10px; }
.member-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }

.invite-list { list-style: none; padding: 0; }
.invite-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--sand-300); }
.invite-list .is-dead { opacity: 0.55; }
.invite-link { background: var(--sand-300); padding: 4px 8px; border-radius: 8px; }

.opt-progress { margin: 4px 0; }
.opt-bar {
  height: 10px; background: var(--sand-300); border-radius: 99px; overflow: hidden;
}
.opt-bar > span {
  display: block; height: 100%; width: 0;
  background: var(--brown-800);
}
.opt-log {
  list-style: none; padding: 0; margin: 0;
  max-height: 180px; overflow: auto; font-size: 0.86rem;
}
.opt-log li { padding: 6px 0; border-bottom: 1px solid var(--sand-300); }
.opt-log .is-miss { color: var(--danger); }

.lightbox {
  position: fixed; inset: 0; background: rgba(28, 18, 12, 0.92); z-index: 80;
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.lightbox-stage { width: 100%; height: 100%; overflow: hidden; display: grid; place-items: center; padding: 56px 72px; box-sizing: border-box; }
.lightbox-stage img {
  max-width: calc(100vw - 144px);
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  width: auto; height: auto; object-fit: contain;
  transform-origin: center center; user-select: none;
}
.lightbox-player {
  width: min(1100px, calc(100vw - 144px));
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  touch-action: auto;
}
.lightbox-player video {
  width: 100%;
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  object-fit: contain;
}
.lightbox-close, .lightbox-nav {
  position: absolute; z-index: 2; border: 0; background: rgba(251,246,240,.9);
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 1.4rem;
}
.lightbox-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lightbox-nav.prev { left: 10px; }
.lightbox-nav.next { right: 10px; }

.update-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + 12px);
  background: var(--brown-800); color: var(--sand-200);
  border-radius: 12px; padding: 12px 14px; z-index: 60;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.update-banner button { background: var(--sand-200); color: var(--brown-800); border: 0; border-radius: 10px; height: 36px; padding: 0 12px; cursor: pointer; line-height: 1; }

.hide-mobile { display: inline-flex; }

.tag-box { position: relative; }
.tag-field {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: #fff; border: 1px solid var(--sand-400); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 46px;
}
.tag-field:focus-within {
  border-color: var(--brown-700);
  box-shadow: 0 0 0 3px rgba(156, 102, 68, 0.18);
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--sand-300); border-radius: 8px; padding: 6px 8px;
  font-size: 0.86rem; line-height: 1;
}
.tag-chip button {
  border: 0; background: transparent; cursor: pointer; padding: 0 2px;
  line-height: 1; font-size: 1rem; color: var(--muted);
}
.tag-field input[type="text"] {
  flex: 1; min-width: 140px; border: 0; background: transparent; padding: 6px 4px; height: auto;
}
.tag-field input[type="text"]:focus { box-shadow: none; }
.tag-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 8;
  background: #fff; border: 1px solid var(--sand-400); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 240px; overflow: auto;
}
.tag-suggest button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; cursor: pointer; line-height: 1.25; font-family: var(--font);
}
.tag-suggest button:hover, .tag-suggest button.is-active { background: var(--sand-200); }
.tag-create { font-weight: 700; color: var(--brown-800); }

.preview-item { cursor: grab; }
.drop-preview { justify-content: flex-start; }

@media (max-width: 760px) {
  .topnav { display: none; }
  .tabbar { display: grid; }
  .page { margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
  .recipe-grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none; }
  .meta-grid { grid-template-columns: 1fr; }
  .ing-row { flex-wrap: wrap; }
  .w-sm, .w-md { max-width: none; flex: 1; }
  .modal { place-items: end stretch; }
  .update-banner { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
  .lightbox-stage { padding: 56px 12px; }
  .lightbox-stage img {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
  }
  .lightbox-player,
  .lightbox-player video {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
  }
}

@media (min-width: 761px) {
  .modal { place-items: center; }
  .modal-card { border-radius: 16px; }
}
