:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #fbfcfb;
  --surface-strong: #ffffff;
  --text: #24302b;
  --muted: #68736d;
  --line: #d8dfd9;
  --green: #2f7d57;
  --green-dark: #215b40;
  --red: #b5483c;
  --gold: #b8791a;
  --blue: #366b8c;
  --shadow: 0 10px 26px rgba(35, 48, 43, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 16px clamp(14px, 4vw, 24px) 112px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.daily-brief {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 8px;
  margin-bottom: 12px;
}

.date-brief,
.weather-brief {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.date-brief {
  padding: 12px 14px;
}

.date-brief strong {
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
  line-height: 1.1;
  color: var(--green-dark);
}

.date-brief p,
.weather-summary p {
  margin-bottom: 0;
}

.weather-brief {
  display: grid;
  min-height: 104px;
  align-items: center;
  padding: 12px 14px;
}

.weather-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-weight: 800;
}

.weather-summary strong {
  display: block;
  margin-bottom: 6px;
  font-size: 21px;
  line-height: 1.15;
}

.weather-summary p,
.date-brief p {
  font-size: 14px;
  line-height: 1.45;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 3vw, 24px) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.96);
  box-shadow: 0 -12px 28px rgba(35, 48, 43, 0.12);
  backdrop-filter: blur(16px);
}

.module-tab {
  display: grid;
  min-height: 58px;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.module-tab.active {
  background: #e9f2ec;
  color: var(--green-dark);
}

.nav-icon {
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid currentColor;
}

.home-icon {
  border-radius: 6px 6px 4px 4px;
  transform: translateY(2px) rotate(45deg) scale(0.72);
}

.kitchen-icon {
  width: 20px;
  border-radius: 3px 3px 10px 10px;
}

.todo-icon {
  border-radius: 6px;
  position: relative;
}

.todo-icon::after {
  position: absolute;
  top: 3px;
  left: 5px;
  width: 9px;
  height: 5px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: rotate(-45deg);
}

.storage-icon {
  border-radius: 5px;
  position: relative;
}

.storage-icon::after {
  position: absolute;
  top: 6px;
  left: -2px;
  width: 22px;
  border-top: 2px solid currentColor;
  content: "";
}

.module-panel {
  display: none;
}

.module-panel.active {
  display: block;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 26px;
}

h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

p {
  color: var(--muted);
}

.alert-panel {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

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

.section-title-row h2 {
  margin-bottom: 0;
  font-size: 22px;
}

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

.alert-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 4px 10px;
  align-items: center;
  min-height: 58px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f9fbf8;
  color: var(--text);
  text-align: left;
}

.alert-item span {
  grid-row: span 2;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
}

.alert-item strong {
  font-size: 15px;
  line-height: 1.25;
}

.alert-item small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.alert-item.danger span {
  background: var(--red);
}

.alert-item.food span,
.alert-item.shopping span {
  background: var(--gold);
}

.alert-item.weather span {
  background: var(--blue);
}

.compact-empty {
  padding: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.today-card {
  display: flex;
  min-height: 178px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.recipe-overview-card {
  background: #eff7f1;
}

.todo-overview-card {
  background: #fff8e8;
}

.expiring-overview-card {
  background: #fff3ee;
}

.storage-overview-card {
  background: #f4f8fb;
}

.today-card h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.today-card p {
  margin-bottom: 0;
}

.today-card .secondary-button {
  width: 100%;
}

.module-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--green);
  font-weight: 800;
}

.metric {
  min-height: 92px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.metric strong {
  font-size: 30px;
  color: var(--green-dark);
}

.metric.warn strong {
  color: var(--gold);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.category-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.category-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.filter-tab {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.filter-tab.active {
  background: var(--green);
  color: #fff;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 700;
}

.panel {
  display: none;
  padding: clamp(16px, 4vw, 22px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

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

.section-head select {
  min-width: 150px;
}

.picker {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

.picked-card {
  min-height: 210px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fbf8;
}

.placeholder {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.recipe-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.recipe-title-row h3 {
  margin: 0;
  font-size: 28px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9f2ec;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.tag.missing {
  background: #f8e3df;
  color: var(--red);
}

.action-row,
.inline-form,
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-bar {
  margin-bottom: 12px;
}

.module-form {
  margin-bottom: 16px;
}

.search-results {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

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

.install-button[hidden] {
  display: none;
}

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

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button,
.ghost-button {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--text);
}

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

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.compact-list,
.card-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.item-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.compact-item {
  padding: 12px 14px;
}

.placeholder-panel {
  min-height: 420px;
}

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compact-item strong {
  display: block;
}

.compact-item span,
.meta {
  color: var(--muted);
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.inline-form input,
.inline-form select,
.search-bar input,
.edit-form input,
.edit-form select,
.edit-form textarea,
.section-head select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.search-bar input {
  flex: 1 1 280px;
}

.form-grid textarea {
  grid-column: span 5;
  min-height: 84px;
  padding-top: 10px;
  resize: vertical;
}

.recipe-form input[name="ingredients"] {
  grid-column: span 3;
}

.form-grid button {
  grid-column: span 1;
}

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

.item-card h3 {
  margin: 0 0 8px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.todo-card {
  align-items: start;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.status-pill {
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef1ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.today {
  background: #e9f2ec;
  color: var(--green-dark);
}

.status-pill.future {
  background: #edf4f8;
  color: var(--blue);
}

.status-pill.overdue {
  background: #f8e3df;
  color: var(--red);
}

.status-pill.done {
  background: #eef1ef;
  color: var(--muted);
}

.edit-card {
  display: block;
}

.edit-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.edit-form input[name="ingredients"],
.edit-form textarea,
.edit-form .meta,
.edit-form .item-actions {
  grid-column: 1 / -1;
}

.edit-form textarea {
  min-height: 96px;
  padding-top: 10px;
  resize: vertical;
}

.small-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.danger {
  color: var(--red);
}

.status-expired {
  color: var(--red);
  font-weight: 700;
}

.status-soon {
  color: var(--gold);
  font-weight: 700;
}

.status-good {
  color: var(--green);
  font-weight: 700;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.shopping-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shopping-row input {
  width: 18px;
  height: 18px;
}

.shopping-row.done span {
  color: var(--muted);
  text-decoration: line-through;
}

@media (max-width: 820px) {
  .topbar,
  .section-head {
    display: grid;
  }

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

  .daily-brief {
    grid-template-columns: 1fr;
  }

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

  .two-column {
    grid-template-columns: 1fr;
  }

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

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

  .edit-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid textarea,
  .recipe-form input[name="ingredients"],
  .form-grid button,
  .edit-form input[name="ingredients"],
  .edit-form textarea,
  .edit-form .meta,
  .edit-form .item-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-top: 18px;
  }

  .summary-grid,
  .today-grid,
  .form-grid,
  .edit-form {
    grid-template-columns: 1fr;
  }

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

  .item-actions {
    justify-content: flex-start;
  }

  .recipe-title-row {
    display: grid;
  }
}
