:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-muted: #f1f3f0;
  --ink: #20231f;
  --muted: #6f766d;
  --line: #dde2da;
  --line-strong: #cdd5c9;
  --primary: #246b5b;
  --primary-soft: #e4f0ec;
  --primary-ink: #ffffff;
  --danger: #b94b3e;
  --warning-soft: #faebe8;
  --radius: 8px;
  --shadow: 0 14px 36px rgba(32, 35, 31, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100svh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 12px calc(88px + env(safe-area-inset-bottom));
  overflow-x: clip;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
  background: rgba(246, 247, 245, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
}

.brand-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.05;
}

.toolbar,
.toolbar-actions,
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.storage-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid rgba(185, 75, 62, 0.22);
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--danger);
  padding: 5px 9px;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.storage-pill.good {
  border-color: rgba(36, 107, 91, 0.24);
  background: var(--primary-soft);
  color: var(--primary);
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon-btn,
.nav-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.icon-btn:active,
.btn:active,
.chip:active,
.nav-btn:active {
  transform: translateY(1px);
}

.view {
  display: grid;
  gap: 14px;
}

.overview-header,
.form-panel,
.card,
.empty {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.overview-header {
  display: grid;
  gap: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.overview-header h2,
.section-title h2,
.sheet h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.18;
}

.overview-header p,
.section-title p,
.empty p,
.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-title p {
  margin-top: 3px;
  font-size: 0.9rem;
}

.section-title.compact {
  margin: 0;
}

.section-title h3,
.result-block h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.grid {
  display: grid;
  gap: 10px;
}

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

.stat {
  min-height: 76px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 1.48rem;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.card {
  overflow: hidden;
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
}

.card-row > * {
  min-width: 0;
}

.card h3,
.card h4 {
  margin: 0;
  line-height: 1.2;
}

.card h3 {
  font-size: 1rem;
}

.card h4 {
  font-size: 0.94rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.card-meta a {
  color: var(--primary);
  font-weight: 800;
}

.dish-thumb {
  width: 70px;
  height: 70px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.dish-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.course-line {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.course-line:first-child {
  border-top: 0;
}

.course-label,
.pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.course-label {
  color: var(--primary);
}

.pill {
  padding: 4px 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.pill.warn {
  background: var(--warning-soft);
  color: var(--danger);
}

.pill.gold {
  background: #f5ecd2;
  color: #76530e;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}

.btn.danger {
  border-color: rgba(185, 75, 62, 0.34);
  color: var(--danger);
}

.btn.ghost {
  background: transparent;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

.textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(36, 107, 91, 0.72);
  box-shadow: 0 0 0 3px rgba(36, 107, 91, 0.12);
}

.searchbox {
  position: relative;
}

.searchbox .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  transform: translateY(-50%);
}

.searchbox .input {
  padding-left: 43px;
}

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

.chip-row.compact {
  gap: 6px;
}

.chip-row.compact .chip {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.chip {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 11px;
  font-weight: 760;
  cursor: pointer;
}

.chip.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(32, 35, 31, 0.07);
}

.form-panel {
  display: grid;
  gap: 13px;
  padding: 14px;
}

.lookup-grid {
  display: grid;
  gap: 12px;
}

.lookup-search {
  display: grid;
  gap: 12px;
}

.lookup-choice-grid {
  display: grid;
  gap: 8px;
}

.lookup-choice {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.lookup-choice .icon {
  color: var(--primary);
}

.lookup-choice strong,
.lookup-choice small {
  display: block;
  min-width: 0;
}

.lookup-choice strong {
  font-size: 0.98rem;
  line-height: 1.18;
}

.lookup-choice small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.lookup-choice.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(36, 107, 91, 0.08);
}

.lookup-choice-select {
  margin-top: -4px;
  padding: 0 0 8px 44px;
}

.lookup-detail {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.lookup-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.result-block {
  display: grid;
  gap: 9px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.coverage-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.coverage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.coverage-row:first-child {
  border-top: 0;
}

.lookup-panel .empty {
  min-height: 108px;
}

.linked-summary {
  display: grid;
  gap: 12px;
}

.summary-row {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.summary-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.summary-row > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.link-list,
.linked-list {
  display: grid;
  gap: 7px;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
}

.text-link {
  border: 0;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 10px;
  font-weight: 800;
  cursor: pointer;
}

.linked-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}

.linked-item > span:first-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.linked-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.recipe-detail {
  display: grid;
  gap: 12px;
}

.recipe-detail-photo {
  width: 100%;
  max-height: 210px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.recipe-detail-photo-wrap {
  overflow: hidden;
  border-radius: var(--radius);
}

.recipe-detail-section {
  display: grid;
  gap: 8px;
}

.recipe-detail-section h3 {
  margin: 0;
  font-size: 0.98rem;
}

.recipe-detail-header {
  display: grid;
  gap: 7px;
}

.recipe-detail-header h4 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.recipe-detail-header a {
  color: var(--primary);
  font-weight: 800;
}

.plain-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.42;
}

.plain-list.numbered {
  padding-left: 21px;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.course-picker {
  display: grid;
  gap: 10px;
}

.course-picker-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: center;
}

.meal-calendar,
.selected-date-events,
.workflow-step {
  display: grid;
  gap: 10px;
}

.meal-calendar-header {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.meal-calendar-header strong {
  font-size: 1rem;
}

.meal-calendar-weekdays,
.meal-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.meal-calendar-weekdays span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-align: center;
}

.calendar-day {
  display: grid;
  min-width: 0;
  height: 42px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  line-height: 1;
  position: relative;
}

.calendar-day.has-event {
  border-color: rgba(36, 107, 91, 0.22);
  background: var(--primary-soft);
  font-weight: 950;
}

.calendar-day.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
}

.calendar-day.today:not(.selected) {
  border-color: var(--danger);
}

.calendar-day small {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  min-width: 15px;
  height: 15px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.62rem;
  font-weight: 900;
}

.calendar-day.selected small {
  color: var(--primary);
}

.empty-day {
  pointer-events: none;
}

.section-title.compact {
  margin-top: 0;
}

.section-title.compact h2 {
  font-size: 1rem;
}

.event-manage-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

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

.dish-dropdown {
  position: relative;
  min-width: 0;
}

.dish-select-button,
.dish-option {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.dish-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}

.dish-select-button:focus,
.dish-option:focus {
  border-color: rgba(36, 107, 91, 0.7);
  box-shadow: 0 0 0 3px rgba(36, 107, 91, 0.12);
  outline: none;
}

.select-caret {
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.dish-select-label {
  min-width: 0;
}

.dish-menu {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dish-option {
  display: block;
  padding: 9px 10px;
}

.dish-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dish-option-title,
.dish-option-indicator {
  display: inline;
  line-height: 1.35;
}

.dish-option-indicator {
  margin-left: 5px;
  color: var(--muted);
  white-space: normal;
}

.dish-option-indicator strong {
  color: var(--ink);
}

.notice {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(185, 75, 62, 0.18);
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: #793020;
  line-height: 1.4;
}

.notice.good {
  border-color: rgba(36, 107, 91, 0.2);
  background: var(--primary-soft);
  color: #1d584b;
}

.empty {
  display: grid;
  min-height: 132px;
  place-items: center;
  padding: 22px 18px;
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 4px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.bottom-nav-inner {
  display: grid;
  width: min(100%, 1040px);
  margin: 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.nav-btn {
  min-width: 0;
  min-height: 58px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.1;
}

.nav-btn .icon {
  margin-bottom: 4px;
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  background: rgba(32, 35, 31, 0.36);
  padding-top: env(safe-area-inset-top);
}

.sheet {
  display: grid;
  max-height: min(88svh, 760px);
  gap: 14px;
  overflow: auto;
  border-radius: 18px 18px 0 0;
  background: var(--bg);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 55px rgba(32, 35, 31, 0.2);
}

.compact-sheet {
  max-height: none;
}

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

.image-picker {
  display: grid;
  gap: 10px;
}

.image-preview {
  display: grid;
  min-height: 170px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(36, 107, 91, 0.42);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.image-preview img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}

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

.timeline-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-muted);
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 107, 91, 0.14);
}

.progress span {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.18s ease;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 60;
  width: min(520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 13px 14px;
  border: 1px solid rgba(36, 107, 91, 0.16);
  border-radius: var(--radius);
  background: #1f3f37;
  color: #fff;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 430px) {
  .app-shell {
    padding-inline: 10px;
  }

  .topbar {
    gap: 8px;
  }

  .brand-title {
    font-size: 1.28rem;
  }

  .overview-header,
  .form-panel,
  .card-body {
    padding: 12px;
  }

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

  .stat {
    min-height: 68px;
    padding: 11px 10px;
  }

  .stat strong {
    font-size: 1.28rem;
  }

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

  .section-title,
  .card-row {
    flex-wrap: wrap;
  }

  .storage-pill {
    max-width: 86px;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bottom-nav {
    padding-inline: 8px;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding-inline: 22px;
  }

  .topbar {
    padding-top: 22px;
  }

  .view {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.52fr);
    align-items: start;
  }

  .overview-header,
  .span-all {
    grid-column: 1 / -1;
  }

  .overview-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

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

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

  .lookup-choice {
    grid-template-columns: 1fr;
    align-content: start;
    min-height: 112px;
  }

  .lookup-choice-select {
    grid-column: 1 / -1;
    margin-top: 0;
    padding: 0;
  }

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

  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    width: min(680px, 100%);
    margin: 0 auto;
    border-radius: 18px;
    padding: 20px;
  }
}
