:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #dde3ea;
  --surface: #ffffff;
  --panel: #f6f8fb;
  --green: #26734d;
  --green-soft: #e5f4eb;
  --red: #b8402b;
  --red-soft: #fbe8e2;
  --yellow: #b68421;
  --yellow-soft: #fff3cf;
  --blue: #2e5eaa;
  --blue-soft: #e7eefb;
  --shadow: 0 18px 50px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(38, 115, 77, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(184, 64, 43, 0.08), transparent 30%),
    var(--panel);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1560px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  padding: 18px;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
}

.pantry-panel,
.recipe-panel,
.detail-drawer {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(221, 227, 234, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.pantry-panel,
.detail-drawer {
  border-radius: 8px;
  padding: 18px;
}

.recipe-panel {
  border-radius: 8px;
  padding: 20px;
  min-width: 0;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-photo {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.25;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.ingredient-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.ingredient-input input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  outline: none;
}

.ingredient-input input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(38, 115, 77, 0.12);
}

.sync-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.sync-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(38, 115, 77, 0.12);
}

.ingredient-input button,
.text-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.ingredient-input button {
  background: var(--green);
  color: #fff;
}

.hint {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.compact-hint {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
  font-size: 14px;
  font-weight: 900;
}

.title-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  min-height: 30px;
  padding: 0 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
}

.save-button {
  background: var(--green-soft);
  color: var(--green);
}

.count {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: var(--green-soft);
  color: var(--green);
}

.chip-grid,
.selected-chips,
.tag-row,
.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.selected-chip,
.tag,
.status-pill {
  border-radius: 99px;
  white-space: nowrap;
}

.chip,
.selected-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  font-size: 13px;
}

.chip.active,
.selected-chip {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.chip.seasoning {
  border-color: rgba(184, 132, 33, 0.28);
}

.chip.seasoning.active {
  border-color: var(--yellow);
  background: var(--yellow-soft);
  color: var(--yellow);
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.selected-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(38, 115, 77, 0.14);
  color: var(--green);
  line-height: 1;
}

.shopping-list {
  display: grid;
  gap: 8px;
}

.shopping-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.shopping-item.checked {
  background: var(--panel);
  border-style: dashed;
}

.shopping-item.checked .shopping-name {
  color: var(--muted);
  text-decoration: line-through;
}

.shopping-main {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.shopping-main input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

.shopping-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.shopping-name {
  font-size: 14px;
  font-weight: 800;
}

.shopping-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.icon-button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(184, 64, 43, 0.12);
  color: var(--red);
  font-size: 18px;
  line-height: 1;
}

.filter-section {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

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

.sync-section .input-label {
  margin-bottom: 6px;
  font-size: 12px;
}

.sync-toggle {
  margin: 2px 0 12px;
}

.sync-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sync-actions .text-button {
  min-width: 0;
  padding: 0 6px;
}

.sync-badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.sync-badge.dirty {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.sync-badge.synced {
  background: var(--green-soft);
  color: var(--green);
}

.sync-badge.error {
  background: var(--red-soft);
  color: var(--red);
}

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

.score-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.ready {
  background: var(--green);
}

.close {
  background: var(--yellow);
}

.shop {
  background: var(--red);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.recipe-card {
  min-height: 268px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  text-align: left;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.recipe-card:hover,
.recipe-card.active {
  transform: translateY(-2px);
  border-color: rgba(38, 115, 77, 0.55);
  box-shadow: 0 16px 32px rgba(30, 41, 59, 0.12);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.status-ready {
  background: var(--green-soft);
  color: var(--green);
}

.status-close {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.status-shop {
  background: var(--red-soft);
  color: var(--red);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #edf1f5;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.tag {
  padding: 5px 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.mini-list {
  min-height: 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-drawer {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  overflow: auto;
}

.empty-detail {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-detail img {
  width: 132px;
  height: 132px;
  border-radius: 8px;
  object-fit: cover;
}

.recipe-detail.hidden,
.hidden {
  display: none;
}

.detail-hero {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-hero img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

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

.detail-section h3 {
  font-size: 15px;
}

.detail-hint {
  margin: 0 0 10px;
}

.action-button {
  min-height: 40px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

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

.ingredient-list,
.sub-list,
.step-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li,
.sub-list li,
.step-list li {
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.ingredient-list strong {
  color: var(--green);
}

.ingredient-list .missing {
  color: var(--red);
}

.step-list {
  counter-reset: step;
}

.step-list li {
  position: relative;
  padding-left: 42px;
}

.step-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .detail-drawer {
    position: static;
    height: auto;
  }
}

@media (max-width: 820px) {
  .app-shell,
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 10px;
  }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .score-legend {
    justify-content: flex-start;
  }

  h1 {
    font-size: 30px;
  }
}

@media (max-width: 460px) {
  .ingredient-input {
    grid-template-columns: 1fr;
  }

  .ingredient-input button {
    height: 40px;
  }

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