:root {
  color-scheme: light;
  --ink: #1f2a24;
  --muted: #66736d;
  --line: #dfe7df;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --sage: #7c9b76;
  --sage-dark: #426447;
  --tomato: #d9634f;
  --gold: #e8b84b;
  --blue: #5a8fa8;
  --shadow: 0 18px 50px rgba(31, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(124, 155, 118, 0.2), rgba(232, 184, 75, 0.16)),
    var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--sage-dark);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

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

h1 {
  font-size: 22px;
}

.brand p,
.eyebrow,
.stat-row span,
.detected-meta,
.empty-state span,
.pantry-meta,
.recipe-meta,
.missing,
small {
  color: var(--muted);
}

.nav-tabs {
  display: grid;
  gap: 10px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-tab span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: #eef4ec;
}

.nav-tab.active {
  border-color: #cbdccb;
  background: #eef4ec;
  font-weight: 700;
}

.side-panel,
.panel,
.account-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.account-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.account-heading,
.account-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-heading h2 {
  margin-top: 2px;
  font-size: 18px;
}

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

.account-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.account-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.expiring-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.expiring-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid #ead6d0;
  border-radius: 8px;
  background: #fff7f5;
  color: #7e3328;
}

.expiring-card strong {
  color: #7e3328;
}

.side-panel {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding: 18px;
}

.stat-row,
.panel-heading,
.toolbar,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stat-row strong {
  font-size: 24px;
  color: var(--sage-dark);
}

main {
  min-width: 0;
  padding: 30px;
}

.top-band {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 30px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 84% 20%, rgba(217, 99, 79, 0.28), transparent 26%),
    linear-gradient(135deg, #ffffff, #edf5ef);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.top-band h2 {
  max-width: 780px;
  margin-top: 8px;
  font-size: clamp(28px, 5vw, 54px);
  line-height: 1.05;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.produce-strip {
  display: grid;
  grid-template-columns: repeat(5, 46px);
  gap: 10px;
  min-width: 270px;
}

.produce {
  position: relative;
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 24px rgba(31, 42, 36, 0.14);
}

.tomato { background: var(--tomato); }
.egg { background: #f8f0ce; }
.leaf { background: var(--sage); border-radius: 50% 10px 50% 10px; }
.fish { background: var(--blue); border-radius: 50% 35% 35% 50%; }
.carrot { background: var(--gold); border-radius: 60% 15% 60% 15%; }

.view {
  display: none;
  margin-top: 24px;
}

.view.active {
  display: block;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 22px;
}

.panel {
  padding: 22px;
  box-shadow: 0 12px 34px rgba(31, 42, 36, 0.08);
}

.panel h3,
.toolbar h3 {
  margin-top: 4px;
  font-size: 24px;
}

.upload-box {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  margin-top: 20px;
  padding: 22px;
  border: 1px dashed #acc0a7;
  border-radius: 8px;
  background: #f5faf3;
  text-align: center;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--sage-dark);
  font-size: 24px;
}

.receipt-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocr-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.ocr-status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid #cdd9cd;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea:focus,
input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(124, 155, 118, 0.18);
}

.primary-button,
.secondary-button,
.icon-button,
.filter-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  background: var(--sage-dark);
  color: #fff;
}

.primary-button:hover {
  background: #36533a;
}

.secondary-button,
.filter-button,
.icon-button {
  border-color: #cdd9cd;
  background: #fff;
  color: var(--ink);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.compact {
  min-height: 38px;
  padding-inline: 13px;
}

.action-row {
  margin-top: 16px;
  justify-content: flex-start;
}

.detected-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.empty-state {
  min-height: 250px;
  place-content: center;
  justify-items: center;
  border: 1px dashed #d7e0d6;
  border-radius: 8px;
  background: #fbfdf9;
  text-align: center;
}

.detected-item,
.pantry-card,
.recipe-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.detected-item {
  display: grid;
  grid-template-columns: 1fr 110px;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.detected-name {
  display: block;
  margin-bottom: 4px;
}

.detected-item label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  margin-bottom: 18px;
}

.manual-form {
  display: grid;
  grid-template-columns: 150px 150px auto;
  gap: 10px;
  align-items: center;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button.active {
  background: #eef4ec;
  border-color: #aec5ad;
  color: var(--sage-dark);
}

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

.pantry-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.pantry-top strong {
  font-size: 20px;
}

.category-pill,
.recipe-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef4ec;
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 700;
}

.delete-button {
  width: 34px;
  height: 34px;
  border: 1px solid #ead6d0;
  border-radius: 8px;
  background: #fff7f5;
  color: #a74131;
}

.freshness {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf0ea;
}

.freshness span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
}

.recipe-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.recipe-card {
  cursor: pointer;
}

.recipe-card:focus-visible {
  outline: 3px solid rgba(66, 100, 71, 0.35);
  outline-offset: 2px;
}

.recipe-art {
  display: grid;
  height: 116px;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 38%, rgba(255, 255, 255, 0.88) 0 15%, transparent 16%),
    linear-gradient(135deg, var(--recipe-a), var(--recipe-b));
  color: rgba(255, 255, 255, 0.92);
  font-size: 46px;
  font-weight: 900;
}

.recipe-card h4 {
  margin: 0;
  font-size: 21px;
}

.match-bar {
  height: 9px;
  border-radius: 999px;
  background: #edf0ea;
  overflow: hidden;
}

.match-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--gold));
}

.ingredient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ingredient-chips span {
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5ef;
  color: var(--ink);
  font-size: 12px;
}

.steps {
  margin: 0;
  padding-left: 19px;
  color: #344038;
  line-height: 1.5;
}

.recipe-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.recipe-modal[hidden] {
  display: none;
}

.recipe-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 42, 36, 0.42);
}

.recipe-modal-card {
  position: relative;
  display: grid;
  width: min(720px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  gap: 14px;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.recipe-modal-card h3 {
  margin: 0;
  font-size: 28px;
}

.recipe-modal-card h4 {
  margin: 6px 0 0;
  font-size: 16px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.detailed-steps {
  display: grid;
  gap: 8px;
}

.missing {
  font-size: 13px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    gap: 16px;
    padding: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-tab {
    justify-content: center;
    padding: 10px 8px;
    font-size: 14px;
  }

  .nav-tab span,
  .side-panel {
    display: none;
  }

  main {
    padding: 16px;
  }

  .top-band,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .produce-strip {
    min-width: 0;
  }

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

  .manual-form {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .ocr-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .top-band {
    padding: 20px;
  }

  .top-band h2 {
    font-size: 31px;
  }

  .produce-strip {
    grid-template-columns: repeat(5, 38px);
  }

  .produce {
    width: 38px;
    height: 38px;
  }

  .detected-item {
    grid-template-columns: 1fr;
  }
}
