:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #5f6b64;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: #d9ded6;
  --brand: #176c55;
  --brand-strong: #0f4f3e;
  --accent: #c94c2e;
  --gold: #d79631;
  --done: #eef6f1;
  --shadow: 0 12px 30px rgba(18, 35, 28, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(23, 108, 85, 0.08), transparent 320px),
    var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-panel p,
.page-title p,
.panel p {
  color: var(--muted);
  line-height: 1.45;
}

.version-label {
  margin: 8px 0 0;
  color: var(--brand-strong);
  font-size: 0.86rem;
  font-weight: 900;
}

.pin-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.pin-form input,
.feedback-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
}

.pin-form input {
  min-height: 48px;
}

.feedback-form {
  display: grid;
  gap: 14px;
}

.feedback-form label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.feedback-form textarea {
  min-height: 110px;
  padding: 12px 14px;
  resize: vertical;
  font-weight: 500;
}

.feedback-status {
  min-height: 22px;
  margin: 0;
  color: var(--brand-strong);
  font-weight: 800;
}

.primary-btn,
.icon-btn,
.tab,
.filter-chip {
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.primary-btn {
  color: white;
  background: var(--brand);
  padding: 0 18px;
  font-weight: 700;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.icon-btn {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  padding: 0 14px;
  font-weight: 800;
}

.compact-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.primary-btn:hover,
.icon-btn:hover,
.tab:hover,
.filter-chip:hover {
  transform: translateY(-1px);
}

.error {
  min-height: 20px;
  color: #a33a25;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 14px;
  padding: 14px 0 16px;
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(16px);
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.page-title p {
  max-width: 58ch;
  margin: 10px 0 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  padding: 0 14px;
  font-weight: 700;
}

.tab[aria-selected="true"] {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

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

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

.panel,
.card,
.shop-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

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

.panel h2,
.panel h3,
.card h3 {
  margin: 0;
  letter-spacing: 0;
}

.card h3:not(:first-child),
.panel h3:not(:first-child) {
  margin-top: 14px;
}

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

.metric {
  min-height: 90px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f7f2;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
}

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

.filter-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.filter-chip.is-active {
  border-color: var(--brand);
  background: var(--done);
  color: var(--brand-strong);
  font-weight: 800;
}

.day-list,
.recipe-list,
.putaway-list {
  display: grid;
  gap: 12px;
}

.card {
  padding: 16px;
}

.card.is-muted {
  opacity: 0.72;
  background: #f6f7f2;
}

.day-card {
  display: grid;
  gap: 12px;
}

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

.mini-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: start;
  gap: 10px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-card input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

.mini-card.is-checked {
  background: var(--done);
  opacity: 0.76;
}

.mini-card.is-checked .mini-card-copy {
  color: var(--muted);
}

.mini-card.is-checked .mini-card-title::after {
  content: " done";
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.mini-card-copy {
  display: grid;
  gap: 6px;
  color: var(--muted);
  line-height: 1.42;
}

.mini-card-title {
  color: var(--ink);
  font-weight: 900;
}

.dinner-mini-card {
  display: grid;
  grid-template-columns: 1fr;
}

.mini-card-check {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 10px;
}

.ingredient-preview {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ingredient-preview summary {
  color: var(--brand-strong);
  cursor: pointer;
  font-weight: 900;
}

.ingredient-preview ul {
  margin-top: 8px;
  padding-left: 18px;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--brand-strong);
  background: var(--done);
  font-size: 0.84rem;
  font-weight: 800;
}

.card ul,
.panel ul {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.55;
}

.meal-meta,
.shop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.shopping-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
}

.shopping-layout.one-shop {
  grid-template-columns: 1fr;
}

.shop-selector {
  align-self: start;
}

.shop-button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  padding: 0 12px;
  font-weight: 800;
}

.shop-button.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.shop-summary {
  position: sticky;
  top: 0;
  z-index: 4;
}

.shop-complete-row {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.shop-complete-row p {
  margin: 0;
  font-size: 0.86rem;
}

.shop-group {
  overflow: hidden;
}

.shop-group h3 {
  margin: 0;
  padding: 12px 14px;
  background: #eef1ea;
}

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

.ingredient-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ingredient-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

.ingredient-row.is-checked {
  background: var(--done);
}

.ingredient-row.is-checked .item-note {
  text-decoration: line-through;
}

.callout {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(201, 76, 46, 0.35);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #fff7f2;
}

.callout strong {
  color: var(--accent);
}

.callout p {
  margin: 6px 0 0;
  color: var(--ink);
}

.item-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

.item-row.is-checked {
  background: var(--done);
}

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

.item-name {
  font-weight: 800;
}

.item-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.qty {
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}

.recipe-link {
  color: var(--brand-strong);
  font-weight: 800;
}

.recipe-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.recipe-controls p {
  margin-bottom: 0;
}

.toggle-row,
.recipe-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 800;
  white-space: nowrap;
}

.toggle-row input,
.recipe-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

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

@media (max-width: 800px) {
  .app-shell {
    padding: 10px 10px calc(88px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: static;
    gap: 8px;
    padding: 6px 0 10px;
    background: transparent;
    backdrop-filter: none;
  }

  .page-title {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .page-title h1 {
    font-size: 1.55rem;
    line-height: 1.08;
  }

  .page-title p {
    max-width: none;
    margin: 4px 0 0;
    font-size: 0.92rem;
  }

  .version-label {
    font-size: 0.78rem;
  }

  #reset-checks {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .toolbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(251, 250, 246, 0.98);
    box-shadow: 0 -8px 24px rgba(18, 35, 28, 0.12);
    overflow-x: auto;
  }

  .tab {
    min-height: 48px;
    padding: 0 8px;
    font-size: 0;
    white-space: nowrap;
  }

  .tab::after {
    content: attr(data-short);
    font-size: 0.82rem;
  }

  .dashboard-grid,
  .shopping-layout {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: auto;
    padding: 10px 12px;
  }

  .metric strong {
    margin-top: 2px;
    font-size: 1.1rem;
  }

  .panel,
  .card {
    padding: 12px;
  }

  .mini-card-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mini-card {
    min-height: auto;
    padding: 10px;
  }

  .panel-header,
  .card-top {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .card p,
  .panel p,
  .card ul,
  .panel ul {
    font-size: 0.94rem;
  }

  .meal-meta,
  .shop-meta {
    gap: 6px;
    font-size: 0.84rem;
  }

  .tag {
    min-height: 26px;
    font-size: 0.78rem;
  }

  .chips {
    gap: 6px;
  }

  .filter-chip {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.88rem;
  }

  .recipe-controls {
    align-items: start;
    flex-direction: column;
  }

  .item-row {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 12px;
  }

  .qty {
    grid-column: auto;
    align-self: start;
    font-size: 0.92rem;
  }

  .item-name {
    font-size: 0.95rem;
  }

  .item-note {
    font-size: 0.82rem;
  }

  .shop-selector {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 10px;
  }

  .shop-summary {
    padding: 10px 12px;
  }

  .shop-summary .panel-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    margin-bottom: 0;
  }

  .shop-summary h2 {
    font-size: 1.15rem;
  }

  .shop-summary .shop-meta {
    margin-top: 3px;
  }

  .shop-summary .toggle-row {
    min-height: 34px;
    font-size: 0.82rem;
  }

  .shop-complete-row {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 8px;
  }

  .shop-complete-row .primary-btn {
    min-height: 42px;
  }

  .tab-shopping .topbar {
    padding: 0;
  }

  .tab-shopping .page-title {
    display: none;
  }

  .shop-button {
    min-height: 44px;
  }

  .shop-group h3 {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 10px 12px;
  }

  .ingredient-row {
    min-height: 46px;
    padding: 9px 10px;
  }

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

  .card-actions .primary-btn,
  .card-actions .icon-btn {
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  .login {
    min-height: 100dvh;
    padding: 12px;
  }

  .login-panel {
    padding: 18px;
  }

  .login-panel h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 430px) {
  .item-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .qty {
    grid-column: 2;
  }

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