:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #20201d;
  --muted: #6d6a61;
  --line: #ded7ca;
  --citrus: #f2bd43;
  --mint: #6fb89a;
  --bitters: #c95d4f;
  --blue: #5d7f9d;
  --shadow: 0 18px 45px rgba(38, 34, 28, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(242, 189, 67, 0.16), transparent 24rem),
    linear-gradient(135deg, #f6f4ee 0%, #eef4ef 52%, #f8f2eb 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.site-header {
  /* keep vertical spacing but let inner container handle horizontal centering */
  padding: 22px 0 16px;
  position: relative;
}

.site-header-inner {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  /* allow wider content and reduce side padding on large screens */
  max-width: 2500px;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 32px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(32px, 4.5vw, 56px);
  line-height: 1.1;
}

.lead {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.formula {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 0 10px 24px rgba(68, 58, 45, 0.08);
  white-space: nowrap;
  flex-shrink: 1;
}

.formula span {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface-strong);
  font-size: 13px;
  font-weight: 800;
}

/* make formula items use the same highlight colors as selected pills */
.formula .formula-item.base {
  background: #dcebf4;
  color: #183f5c;
}
.formula .formula-item.supporting {
  background: #fff0c8;
  color: #6c4810;
}
.formula .formula-item.mixer {
  background: #dceee5;
  color: #1f5944;
}
.formula .formula-item.garnish {
  background: #f8dfda;
  color: #743329;
}

.formula b {
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(390px, 0.92fr) minmax(520px, 1.08fr);
  gap: 18px;
  /* match header width and reduce side padding */
  max-width: 2500px;
  margin: 0 auto;
  height: calc(100vh - 178px);
  min-height: 520px;
  padding: 0 clamp(12px, 3vw, 32px) 22px;
}

.pantry-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.pantry-panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.selected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.selected-bar strong {
  font-size: 28px;
  line-height: 1;
}

.ghost-button,
.chip,
.tab-button,
.recipe-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
}

.ghost-button {
  padding: 0 16px;
  font-weight: 800;
}

.language-toggle {
  position: absolute;
  top: clamp(12px, 3vw, 22px);
  right: clamp(12px, 3vw, 32px);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.language-toggle:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  max-height: 88px;
  overflow-y: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.selected-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.selected-pill[data-category="base"],
.chip[data-selected="true"][data-category="base"] {
  border-color: #446d8a;
  background: #dcebf4;
  color: #183f5c;
}

.selected-pill[data-category="supporting"],
.chip[data-selected="true"][data-category="supporting"] {
  border-color: #b28125;
  background: #fff0c8;
  color: #6c4810;
}

.selected-pill[data-category="mixer"],
.chip[data-selected="true"][data-category="mixer"] {
  border-color: #41886d;
  background: #dceee5;
  color: #1f5944;
}

.selected-pill[data-category="garnish"],
.chip[data-selected="true"][data-category="garnish"] {
  border-color: #b95f55;
  background: #f8dfda;
  color: #743329;
}

.ingredient-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.category-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.category-section {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.category-section[data-category="base"] {
  border-top: 4px solid var(--blue);
}

.category-section[data-category="supporting"] {
  border-top: 4px solid var(--citrus);
}

.category-section[data-category="mixer"] {
  border-top: 4px solid var(--mint);
}

.category-section[data-category="garnish"] {
  border-top: 4px solid var(--bitters);
}

.category-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.category-title h2 {
  margin: 0;
  font-size: 18px;
}

.category-title span {
  color: var(--muted);
  font-size: 12px;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 7px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  text-align: left;
  font-size: 14px;
  font-weight: 800;
}

.chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.notice {
  margin: 0;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.results-panel {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.18;
}

.match-summary {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  margin: 14px 0 8px;
  color: var(--ink);
  font-size: 24px;
}

.empty-state p {
  max-width: 520px;
  margin-bottom: 0;
  line-height: 1.7;
}

.glass-mark {
  position: relative;
  width: 84px;
  height: 92px;
}

.glass-mark::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 6px;
  width: 48px;
  height: 62px;
  border: 4px solid var(--blue);
  border-top-width: 7px;
  transform: perspective(80px) rotateX(-12deg);
}

.glass-mark::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: 7px;
  width: 40px;
  height: 4px;
  background: var(--ink);
}

.glass-mark span {
  position: absolute;
  left: 26px;
  top: 42px;
  width: 32px;
  height: 14px;
  background: var(--citrus);
}

.result-groups {
  display: grid;
  gap: 18px;
}

.group {
  display: grid;
  gap: 12px;
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.group-heading h3 {
  margin: 0;
  font-size: 20px;
}

.group-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.recipe-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.recipe-card h4 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.2;
}

.recipe-card .en {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.difficulty {
  align-self: start;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1eee6;
  color: #4c463b;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.tag-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f4f0e6;
  color: #554d40;
  font-size: 12px;
  font-weight: 800;
}

.meta-row span {
  color: var(--muted);
  font-size: 13px;
}

.ingredient-status {
  display: grid;
  gap: 8px;
}

.status-line {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
}

/* Language-specific column widths: Chinese use 56px, English use 80px.
   Ensure the page root has a proper lang attribute (e.g. <html lang="zh">). */
:lang(zh) .status-line {
  grid-template-columns: 56px 1fr;
}
:lang(en) .status-line {
  grid-template-columns: 80px 1fr;
}

.status-line b {
  color: var(--muted);
}

.owned {
  color: #1f684f;
  font-weight: 800;
}

.missing {
  color: #ad3e32;
  font-weight: 800;
}

.substitute {
  color: #8a6414;
  font-weight: 800;
}

.recipe-details {
  display: none;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.recipe-card[data-open="true"] .recipe-details {
  display: grid;
}

.detail-block h5 {
  margin: 0 0 8px;
  font-size: 14px;
}

.detail-block p,
.detail-block li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.detail-block p {
  margin-bottom: 0;
}

.detail-block ol {
  margin: 0;
  padding-left: 20px;
}

.recipe-toggle {
  width: 100%;
  font-weight: 900;
}

@media (max-width: 980px) {
  .site-header {
    align-items: start;
    flex-direction: column;
  }

  .formula {
    min-width: 0;
    width: 100%;
    overflow-x: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .pantry-panel,
  .results-panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .ingredient-panel {
    overflow: visible;
  }

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

@media (max-width: 560px) {
  .site-header {
    padding-top: 24px;
  }

  .app-shell {
    padding-inline: 12px;
  }

  .category-stack {
    grid-template-columns: 1fr;
  }

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

  .results-header,
  .recipe-top {
    align-items: start;
    flex-direction: column;
  }

  .match-summary {
    width: 100%;
    text-align: center;
  }
}


@media (max-width: 980px) {
  /* 关键：让标题区和右侧操作区上下排，不再横向抢宽度 */
  .site-header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  /* 左侧标题容器占满整行 */
  .site-header-inner > div:first-child {
    width: 100%;
    min-width: 0;
  }

  /* 右侧操作区也占满整行，并允许换行 */
  .header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  /* formula 在小屏允许横向滚动（你原本就有这段，这里确保它仍然生效） */
  .formula {
    width: 100%;
    overflow-x: auto;
  }
}