:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --text: #2b2118;
  --hint: #8c7b6b;
  --line: #efe6dc;
  --accent: #e2553b;
  --accent-soft: #fbe3dc;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(60, 35, 15, .06), 0 8px 24px rgba(60, 35, 15, .08);
  --serif: "Lora", Georgia, serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --r: 20px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #17120e;
  --surface: #221b16;
  --text: #f3eae0;
  --hint: #a08f80;
  --line: #2e251f;
  --accent: #ff7a5c;
  --accent-soft: #3a2620;
  --on-accent: #1a0f0a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

main, article {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- list ---------- */

.top { padding: 22px 2px 14px; }
.eyebrow {
  margin: 0 0 4px;
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.page-title {
  margin: 0;
  font: 700 32px/1.1 var(--serif);
  letter-spacing: -.01em;
}
.page-title em { font-style: italic; font-weight: 600; color: var(--accent); }

.search {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.search svg {
  position: absolute; left: 30px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; fill: none; stroke: var(--hint); stroke-width: 2; stroke-linecap: round;
}
.search input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: 500 15px var(--sans);
  outline: none; box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--hint); }
.search input:focus { border-color: var(--accent); }

.tags {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 2px -16px 0; padding: 4px 16px 12px;
  scrollbar-width: none;
}
.tags::-webkit-scrollbar { display: none; }
.tag {
  flex: none; padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  font-size: 14px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.tag.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.grid { columns: 2; column-gap: 12px; }
@media (min-width: 560px) { .grid { columns: 3; } }

.card {
  display: block; width: 100%;
  break-inside: avoid; margin: 0 0 12px;
  padding: 0; border: 0; border-radius: var(--r);
  background: var(--surface);
  overflow: hidden; position: relative; text-align: left;
  box-shadow: var(--shadow);
  animation: rise .35s both;
}
.card:active { transform: scale(.98); }
.card img {
  display: block; width: 100%;
  aspect-ratio: var(--ratio, 4 / 5); object-fit: cover;
  background: var(--accent-soft);
}
.card .shade {
  position: absolute; inset: auto 0 0 0;
  padding: 40px 12px 12px;
  background: linear-gradient(transparent, rgba(20, 10, 4, .78));
  color: #fff;
}
.card h3 { margin: 0; font: 600 16px/1.2 var(--serif); }
.card .sub { margin-top: 4px; font-size: 12px; font-weight: 600; opacity: .85; }
.card .noimg {
  aspect-ratio: 5 / 4; display: grid; place-items: center;
  font-size: 56px; background: var(--accent-soft);
}
.card.plain .body { padding: 12px 12px 14px; }
.card.plain .sub { color: var(--hint); opacity: 1; }

.card.pending { padding: 14px; }
.card.pending .skel {
  aspect-ratio: 4 / 5; border-radius: 14px; margin-bottom: 10px;
  background: linear-gradient(100deg, var(--line) 30%, var(--surface) 50%, var(--line) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s infinite linear;
}
.card.pending p, .card.failed p { margin: 0; font-size: 13px; font-weight: 600; color: var(--hint); }
.card.failed { padding: 16px 14px; }
.card.failed h3 { color: var(--accent); margin-bottom: 4px; }

.empty { text-align: center; padding: 18vh 24px 0; color: var(--hint); }
.empty-icon { font-size: 56px; }
.empty h2 { margin: 12px 0 6px; font: 600 22px var(--serif); color: var(--text); }
.empty p { margin: 0 auto; max-width: 280px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- detail ---------- */

.hero {
  position: relative; margin: 0 -16px;
  min-height: 280px; max-height: 62vh; overflow: hidden;
  background: #000;
}
.hero > img, .hero > video {
  display: block; width: 100%; height: 100%;
  max-height: 62vh; object-fit: cover;
}
.hero > video { object-fit: contain; }
.hero .shade {
  position: absolute; inset: 0;
  background: linear-gradient(rgba(0,0,0,.15), transparent 30%, transparent 55%, var(--bg));
  pointer-events: none;
}
.play {
  position: absolute; right: 16px; bottom: 28px;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 10px 12px; border: 0; border-radius: 999px;
  background: rgba(255,255,255,.92); color: #1a120c;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.play svg { width: 20px; height: 20px; fill: var(--accent); }

.head { position: relative; margin-top: -22px; }
.head h1 { margin: 0; font: 700 30px/1.12 var(--serif); letter-spacing: -.01em; }
.head .desc { margin: 10px 0 0; color: var(--hint); }

.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.meta span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.meta .tagpill { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 32px 0 12px;
}
.section-title h2 { margin: 0; font: 700 22px var(--serif); }
.section-title small { color: var(--hint); font-weight: 600; font-size: 13px; }

.progress { height: 4px; border-radius: 4px; background: var(--line); margin: -4px 0 12px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

.ingredients {
  list-style: none; padding: 4px 0; margin: 0;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
}
.ingredients li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  transition: opacity .2s;
}
.ingredients li + li { border-top: 1px solid var(--line); }
.ingredients .box {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.ingredients .box svg { width: 12px; height: 12px; stroke: var(--on-accent); stroke-width: 3.5; fill: none; opacity: 0; }
.ingredients li.done { opacity: .45; }
.ingredients li.done .name { text-decoration: line-through; }
.ingredients li.done .box { background: var(--accent); border-color: var(--accent); }
.ingredients li.done .box svg { opacity: 1; }
.ingredients .name { flex: 1; font-weight: 500; }
.ingredients .amount { color: var(--hint); font-weight: 600; font-size: 14px; white-space: nowrap; }

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: grid; grid-template-columns: 44px 1fr; gap: 0 12px; padding-bottom: 26px; position: relative; }
.steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 21px; top: 48px; bottom: 6px;
  width: 2px; background: var(--line);
}
.steps .num {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font: 700 20px var(--serif);
}
.steps .txt { padding-top: 9px; font-size: 16px; }
.steps .shot { grid-column: 2; position: relative; margin-top: 12px; border: 0; padding: 0; background: none; }
.steps .shot img { display: block; width: 100%; border-radius: 16px; box-shadow: var(--shadow); }
.steps .shot .ts {
  position: absolute; left: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px 4px 7px; border-radius: 999px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700;
}
.steps .shot .ts svg { width: 12px; height: 12px; fill: #fff; }

.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photos img { width: 100%; border-radius: 14px; display: block; }

.actions { display: flex; gap: 10px; margin-top: 36px; }
.btn {
  flex: 1; padding: 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 700;
}
.btn.danger { color: var(--accent); }
.error { color: var(--accent); padding-top: 24px; }

/* ---------- folders ---------- */

.title-row { display: flex; align-items: flex-start; gap: 8px; }
.title-row .page-title { flex: 1; }
.icon-btn {
  flex: none; width: 40px; height: 40px; margin-top: 2px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); font-size: 20px; line-height: 1; font-weight: 700;
}

.folders {
  display: flex; gap: 12px; overflow-x: auto;
  margin: 0 -16px; padding: 2px 16px 14px;
  scrollbar-width: none;
}
.folders::-webkit-scrollbar { display: none; }
.folder {
  flex: none; width: 84px; padding: 0; border: 0; background: none; text-align: center;
}
.folder .tile {
  width: 84px; height: 84px; border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; overflow: hidden; position: relative;
  font-size: 34px;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color .15s, transform .15s;
}
.folder:active .tile { transform: scale(.95); }
.folder.on .tile { outline-color: var(--accent); }
.folder .mosaic { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2px; width: 100%; height: 100%; }
.folder .mosaic.one { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.folder .mosaic img { width: 100%; height: 100%; min-height: 0; object-fit: cover; display: block; }
.folder .mosaic .fill { background: var(--accent-soft); }
.folder .badge-emoji {
  position: absolute; right: -4px; bottom: -4px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px;
  background: var(--surface); box-shadow: var(--shadow);
}
.folder .tile-wrap { position: relative; width: 84px; height: 84px; }
.folder .name {
  margin-top: 8px; font-size: 13px; font-weight: 700; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.folder .cnt { font-size: 12px; color: var(--hint); font-weight: 600; }
.folder.add .tile { background: transparent; box-shadow: none; border: 2px dashed var(--line); color: var(--hint); font-size: 30px; font-weight: 400; }

.meta .folderpill { background: var(--surface); }

/* ---------- bottom sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(20, 10, 4, .45);
  animation: fade .2s both;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 720px; margin: 0 auto; max-height: 85vh; overflow-y: auto;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--bg); border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: slide-up .28s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 14px; font: 700 22px var(--serif); }
.sheet .list { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.sheet .row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 16px; border: 0; background: none; text-align: left; font-weight: 600;
}
.sheet .row + .row { border-top: 1px solid var(--line); }
.sheet .row .em { font-size: 22px; width: 28px; text-align: center; }
.sheet .row .nm { flex: 1; }
.sheet .row .chk {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center;
}
.sheet .row .chk svg { width: 13px; height: 13px; stroke: var(--on-accent); stroke-width: 3.5; fill: none; opacity: 0; }
.sheet .row.on .chk { background: var(--accent); border-color: var(--accent); }
.sheet .row.on .chk svg { opacity: 1; }
.sheet .row.new { color: var(--accent); }
.sheet input[type=text] {
  width: 100%; padding: 14px 16px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: 600 17px var(--sans); outline: none;
}
.sheet input[type=text]:focus { border-color: var(--accent); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 14px 0 18px; }
.emoji-grid button {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: var(--surface);
  font-size: 22px; padding: 0;
}
.emoji-grid button.on { background: var(--accent-soft); outline: 2px solid var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sheet .btns { display: flex; gap: 10px; margin-top: 14px; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
.folder .tile > .mosaic { position: absolute; inset: 0; }
