* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --panel-soft: #fbfbfd;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --line: rgba(0, 0, 0, 0.11);
  --line-strong: rgba(0, 0, 0, 0.18);
  --accent: #0071e3;
  --accent-dark: #005bb7;
  --green: #2f7d56;
  --rose: #a33d54;
  --amber: #946014;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.96), rgba(245, 245, 247, 0) 420px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  word-break: break-word;
}

.menu-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 64px;
  padding: 12px max(22px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 247, 0.78);
  backdrop-filter: blur(22px) saturate(1.3);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  font-weight: 720;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: #1d1d1f;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
}

.menu-links {
  display: inline-flex;
  justify-content: center;
  gap: 6px;
}

.nav-link,
.nav-pill,
.primary-action,
.secondary-action,
.quiet-button,
.icon-button,
.tag-button,
.recipe-card,
.chip,
.comment-submit,
.mini-action {
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

.nav-link,
.nav-pill {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: transparent;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(0, 0, 0, 0.06);
}

.nav-pill {
  color: white;
  background: var(--accent);
  font-weight: 650;
}

.nav-pill:hover,
.primary-action:hover {
  background: var(--accent-dark);
}

.identity-panel {
  justify-self: end;
  display: grid;
  grid-template-columns: auto minmax(120px, 160px) minmax(100px, 160px);
  gap: 8px;
  align-items: center;
}

.identity-panel label,
.sheet label,
.tag-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.identity-panel label {
  display: block;
  white-space: nowrap;
}

.identity-panel input {
  grid-column: auto;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
}

select,
input {
  height: 38px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.45;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(0, 113, 227, 0.72);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.single-pane {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 62px 0 54px;
}

.hero-search {
  min-height: 320px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.eyebrow {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.hero-search h1 {
  max-width: 840px;
  font-size: 56px;
  line-height: 1.02;
  font-weight: 760;
  letter-spacing: 0;
}

.search-row {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
}

.search-field {
  position: relative;
  display: block;
}

.search-field span {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--subtle);
  font-size: 20px;
}

.search-field input {
  height: 52px;
  border-radius: 8px;
  padding-left: 52px;
  padding-right: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.quiet-button,
.secondary-action,
.icon-button,
.mini-action {
  min-height: 36px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line);
}

.quiet-button {
  width: 44px;
  height: 52px;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.quiet-button:hover,
.secondary-action:hover,
.icon-button:hover,
.mini-action:hover {
  background: #fff;
  border-color: var(--line-strong);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 24px;
  line-height: 1.1;
}

.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.tag-browser,
.featured-section,
.results-section {
  margin: 28px 0;
}

.tag-browser {
  padding: 18px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tag-browser[hidden],
.featured-section[hidden],
.recipe-detail[hidden] {
  display: none;
}

#clearTagsButton {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 650;
}

#clearTagsButton:disabled {
  color: var(--subtle);
  cursor: default;
}

.tag-list,
.active-tags,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-button,
.chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
}

.tag-button:hover {
  background: #fff;
}

.tag-button.active {
  color: #fff;
  background: #1d1d1f;
  border-color: #1d1d1f;
}

.tag-count {
  color: var(--subtle);
  font-size: 12px;
}

.tag-button.active .tag-count {
  color: rgba(255, 255, 255, 0.72);
}

.active-tags {
  margin: 12px 0 20px;
}

.active-tags:empty {
  display: none;
}

.chip {
  border-color: transparent;
  background: rgba(0, 0, 0, 0.06);
  font-size: 13px;
}

.chip button {
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
}

.featured-grid,
.recipe-list {
  display: grid;
  gap: 14px;
}

.featured-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.recipe-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.recipe-card {
  width: 100%;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  min-height: 108px;
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.66);
  border-color: var(--line);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
  text-align: left;
}

.recipe-card > span {
  min-width: 0;
  align-self: center;
}

.recipe-card:hover {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.recipe-card.active {
  background: var(--panel-solid);
  border-color: rgba(0, 113, 227, 0.42);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14), var(--shadow-soft);
}

.recipe-card.no-thumb {
  grid-template-columns: minmax(0, 1fr);
}

.thumb {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  object-fit: cover;
  background: #e5e5ea;
}

.featured-card {
  display: block;
  min-height: 0;
  padding: 10px;
}

.featured-card .thumb {
  width: 100%;
  height: 190px;
  display: block;
  margin-bottom: 12px;
}

.featured-card.no-thumb {
  min-height: 160px;
  display: grid;
  align-content: end;
}

.card-title {
  display: block;
  margin: 2px 0 7px;
  font-weight: 720;
  line-height: 1.2;
}

.meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.origin-line {
  color: var(--green);
}

.rating {
  margin-top: 7px;
  color: var(--amber);
  font-weight: 700;
}

.recipe-detail {
  margin-top: 34px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.detail-inner {
  max-width: 900px;
  margin: 0 auto;
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 18px;
}

.detail-title {
  max-width: 780px;
  font-size: 42px;
  line-height: 1;
  font-weight: 760;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.mini-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  white-space: nowrap;
}

.chips {
  margin: 12px 0 18px;
}

.chips .chip:nth-child(3n + 1) { background: rgba(0, 113, 227, 0.12); color: #075ca8; }
.chips .chip:nth-child(3n + 2) { background: rgba(47, 125, 86, 0.12); color: var(--green); }
.chips .chip:nth-child(3n + 3) { background: rgba(163, 61, 84, 0.12); color: var(--rose); }

.primary-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  font-weight: 650;
}

.tag-editor {
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.tag-editor-actions,
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.hero {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 6px 0 20px;
}

.section {
  margin: 18px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.section h2,
.comments h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.recipe-text {
  font-size: 17px;
  line-height: 1.62;
}

.recipe-text a {
  color: var(--accent);
}

.inline-img,
.gallery img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.inline-img {
  margin-top: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.comments {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.comment {
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.comment-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.comment-form {
  display: grid;
  gap: 8px;
}

.comment-submit {
  justify-self: end;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 13px;
  color: #fff;
  background: var(--accent);
  font-weight: 650;
}

.empty {
  padding: 20px 0;
  color: var(--muted);
}

.sheet {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(26px);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.24);
}

.sheet-inner {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.92);
  color: white;
  box-shadow: var(--shadow);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101012;
    --panel: rgba(36, 36, 39, 0.78);
    --panel-solid: #1f1f22;
    --panel-soft: #2a2a2d;
    --ink: #f5f5f7;
    --muted: #a1a1a6;
    --subtle: #8e8e93;
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.24);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.22);
  }

  body,
  .menu-bar {
    background-color: #101012;
  }

  .menu-bar {
    background: rgba(24, 24, 27, 0.82);
  }

  select,
  input,
  textarea,
  .recipe-card,
  .tag-button,
  .quiet-button,
  .secondary-action,
  .icon-button,
  .mini-action,
  #clearTagsButton {
    background: rgba(44, 44, 46, 0.9);
  }

  .nav-link:hover,
  .nav-link.active {
    background: rgba(255, 255, 255, 0.08);
  }

  .recipe-card:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 980px) {
  .menu-bar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .menu-links,
  .identity-panel {
    justify-self: start;
  }

  .hero-search h1 {
    font-size: 44px;
  }

  .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .single-pane {
    width: min(100vw - 24px, 1180px);
    padding-top: 34px;
  }

  .menu-bar {
    gap: 10px;
    padding: 10px 12px;
  }

  .menu-links {
    width: 100%;
    overflow-x: auto;
    justify-content: start;
    padding-bottom: 2px;
  }

  .identity-panel {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .identity-panel input {
    grid-column: 1;
  }

  .hero-search {
    min-height: 260px;
  }

  .hero-search h1 {
    font-size: 36px;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .featured-grid,
  .recipe-list {
    grid-template-columns: 1fr;
  }

  .featured-card .thumb {
    height: 210px;
  }

  .detail-head {
    grid-template-columns: 1fr;
  }

  .detail-title {
    font-size: 32px;
  }
}
