/* ============================================================
   Mise — Meal Planner Design System
   ============================================================ */

:root {
  /* Type */
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Color — warm near-white, single warm-gray border, muted terracotta accent */
  --bg: oklch(98.5% 0.005 60);
  --surface: oklch(99.5% 0.003 60);
  --surface-sunken: oklch(96.5% 0.006 60);
  --border: oklch(89% 0.008 60);
  --border-strong: oklch(82% 0.01 60);

  --text-primary: oklch(22% 0.01 50);
  --text-secondary: oklch(48% 0.012 50);
  --text-tertiary: oklch(64% 0.012 50);
  --text-quaternary: oklch(75% 0.01 50);

  --accent: oklch(58% 0.105 38);          /* muted terracotta */
  --accent-hover: oklch(52% 0.115 38);
  --accent-soft: oklch(95% 0.022 38);
  --accent-on: #ffffff;

  /* Functional store colors (used as small pills + send button bg) */
  --store-instacart-kroger: oklch(52% 0.12 250);
  --store-instacart-publix: oklch(50% 0.11 145);
  --store-instacart-sprouts: oklch(50% 0.09 80);
  --store-amazon-fresh: oklch(50% 0.09 200);
  --store-amazon-wholefoods: oklch(42% 0.08 155);
  --store-amazon-standard: oklch(62% 0.13 60);

  /* Status */
  --status-draft-fg: oklch(45% 0.01 50);
  --status-draft-bg: oklch(94% 0.005 60);
  --status-pending-fg: oklch(48% 0.11 75);
  --status-pending-bg: oklch(95% 0.04 85);
  --status-confirmed-fg: oklch(42% 0.09 150);
  --status-confirmed-bg: oklch(95% 0.04 150);
  --status-danger-fg: oklch(50% 0.16 27);

  /* Spacing (8px grid) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Radii */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;

  --transition: 120ms ease-out;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
  font-size: inherit;
}

input::placeholder, textarea::placeholder {
  color: var(--text-quaternary);
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--text-primary);
}

/* ============================================================
   App shell
   ============================================================ */

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

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: var(--s-6) var(--s-5);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-8);
  font-variation-settings: "opsz" 24, "wdth" 105;
}

.sidebar__wordmark em {
  font-style: normal;
  color: var(--accent);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__navitem {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 12px;
  border-radius: var(--r-2);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  transition: var(--transition);
  font-weight: 500;
}

.sidebar__navitem:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.sidebar__navitem--active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar__navitem--active:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar__navitem .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
}

.sidebar__navitem--active .dot {
  opacity: 1;
}

.sidebar__footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__settings-btn {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 10px;
  border-radius: var(--r-2);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.sidebar__settings-btn:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.main {
  padding: var(--s-10) var(--s-12);
  max-width: 1280px;
  width: 100%;
}

/* ============================================================
   Loading
   ============================================================ */

.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-screen__inner,
.loading-block__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
  text-align: center;
}

.loading-screen__wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variation-settings: "opsz" 24, "wdth" 105;
}

.loading-screen__wordmark em {
  font-style: normal;
  color: var(--accent);
}

.loading-dots {
  display: flex;
  align-items: center;
  gap: 7px;
}

.loading-dots__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.28;
  animation: loading-dot 1.1s ease-in-out infinite;
}

.loading-dots__dot:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-dots__dot:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes loading-dot {
  0%, 70%, 100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.loading-screen__message {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-12) var(--s-6);
  min-height: 160px;
}

@media (prefers-reduced-motion: reduce) {
  .loading-dots__dot {
    animation: none;
    opacity: 0.55;
  }
}

/* ============================================================
   Typography
   ============================================================ */

.h-display {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 0;
  font-variation-settings: "opsz" 36, "wdth" 100;
}

.h-section {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0;
  font-variation-settings: "opsz" 24, "wdth" 100;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-tertiary);
}

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-quaternary { color: var(--text-quaternary); }
.mono { font-family: var(--font-mono); }

/* ============================================================
   Inputs
   ============================================================ */

.input,
.select,
.textarea {
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-2);
  padding: 7px 10px;
  color: var(--text-primary);
  width: 100%;
  transition: var(--transition);
  outline: none;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input--ghost {
  border-color: transparent;
  background: transparent;
  padding-left: 4px;
  padding-right: 4px;
}

.input--ghost:hover {
  background: var(--surface-sunken);
  border-color: transparent;
}

.input--ghost:focus {
  background: var(--surface);
  border-color: var(--accent);
}

.input--num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 26px;
  cursor: pointer;
}

.textarea {
  resize: none;
  line-height: 1.5;
}

/* Search input */
.search {
  position: relative;
  flex: 1;
}

.search input {
  padding-left: 34px;
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-2);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

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

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

.btn--primary:not(:disabled):hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  border-color: var(--border-strong);
  background: var(--surface);
}

.btn--secondary:not(:disabled):hover {
  background: var(--surface-sunken);
  border-color: var(--text-tertiary);
}

.btn--ghost {
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn--ghost:not(:disabled):hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.btn--danger {
  color: var(--status-danger-fg);
  border-color: transparent;
}

.btn--danger:hover {
  background: oklch(96% 0.02 27);
}

.btn--icon {
  padding: 6px;
  width: 28px;
  height: 28px;
  color: var(--text-tertiary);
  border-radius: var(--r-2);
}

.btn--icon:not(:disabled):hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.btn--block { width: 100%; }
.btn--lg { padding: 10px 18px; font-size: 14px; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

/* Store-colored send button */
.btn--store {
  width: 100%;
  color: var(--accent-on);
  font-weight: 600;
  background: var(--store);
  border-color: var(--store);
}
.btn--store:not(:disabled):hover { filter: brightness(0.92); }

/* ============================================================
   Badges & tags
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--status-draft-bg);
  color: var(--status-draft-fg);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.badge--confirmed {
  background: var(--status-confirmed-bg);
  color: var(--status-confirmed-fg);
}

.badge--plain {
  background: var(--surface-sunken);
  color: var(--text-secondary);
  padding: 2px 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 12px;
}

.badge--plain::before { display: none; }

.store-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--store);
}

.store-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--store);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.tag:hover {
  background: var(--bg);
  border-color: var(--border);
}

.tag--active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.tag--remove {
  cursor: default;
  padding-right: 4px;
}

.tag--remove .x {
  margin-left: 2px;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1;
}

.tag--remove .x:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ============================================================
   Checkboxes
   ============================================================ */

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: var(--transition);
  margin: 0;
}

.checkbox:hover {
  border-color: var(--text-tertiary);
}

.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}

/* ============================================================
   This Week — page layout
   ============================================================ */

.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-bottom: var(--s-10);
}

.page-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.week-nav {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-secondary);
  font-size: 14px;
}

.week-nav button {
  width: 26px;
  height: 26px;
  border-radius: var(--r-2);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}

.week-nav button:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.week-nav button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.week-nav__label {
  min-width: 140px;
  text-align: center;
  font-weight: 500;
  color: var(--text-primary);
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.week-nav__date {
  line-height: 1.2;
}

.week-nav__relative {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 0;
  white-space: nowrap;
}

.week-nav__relative::before {
  content: "·";
  margin-right: 8px;
  color: var(--text-tertiary);
}

.this-week {
  display: grid;
  grid-template-columns: minmax(360px, 38%) 1fr;
  gap: var(--s-10);
  align-items: start;
}

/* Left column sections */
.section {
  margin-bottom: var(--s-8);
}

.section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}

.meal-row,
.list-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  margin-bottom: var(--s-2);
  transition: var(--transition);
}

.meal-row:hover,
.list-row:hover {
  border-color: var(--border-strong);
}

.meal-row__top,
.list-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.meal-row__title,
.list-row__title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: -0.005em;
}

.meal-row__title:hover,
.list-row__title:hover {
  color: var(--accent);
}

.meal-row__bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: 12px;
  color: var(--text-tertiary);
}

.meal-row__servings {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.meal-row__servings input {
  width: 38px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  outline: none;
}

.meal-row__servings input:hover { background: var(--surface-sunken); }
.meal-row__servings input:focus {
  background: var(--surface);
  border-color: var(--accent);
}

.meal-row__store {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.meal-row__store select {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 4px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
}

.meal-row__store select:hover { color: var(--text-primary); }

.meal-row__remove,
.list-row__remove {
  background: transparent;
  border: none;
  color: var(--text-quaternary);
  cursor: pointer;
  font-size: 18px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0;
  transition: var(--transition);
}

.meal-row:hover .meal-row__remove,
.list-row:hover .list-row__remove {
  opacity: 1;
}

.meal-row__remove:hover,
.list-row__remove:hover {
  background: var(--surface-sunken);
  color: var(--status-danger-fg);
}

/* Add link/picker */
.add-link {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-tertiary);
  padding: 10px 14px;
  border-radius: var(--r-3);
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  text-align: left;
  transition: var(--transition);
  font-weight: 500;
}

.add-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.picker {
  position: relative;
}

.picker__pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.12), 0 2px 6px -2px rgba(0,0,0,0.04);
  z-index: 50;
  padding: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.picker__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 8px 10px;
  border-radius: var(--r-2);
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.picker__option:hover { background: var(--surface-sunken); }

.picker__option--active { background: var(--accent-soft); }

.picker__option .meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.picker__empty {
  padding: 12px;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}

/* Quick-add row */
.quick-add {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  padding: 10px;
  margin-top: var(--s-2);
}

.quick-add__row {
  display: grid;
  grid-template-columns: 48px 76px 1fr 132px auto;
  gap: 6px;
  align-items: center;
}

.quick-add__row .input,
.quick-add__row .select {
  padding: 6px 8px;
  font-size: 13px;
}

/* ============================================================
   Store cards (right column)
   ============================================================ */

.stores-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-4);
  align-items: start;
}

.stores-grid--single { grid-template-columns: 1fr; }

.store-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

.store-card--pending {
  background: oklch(99% 0.014 85);
}

.store-card--confirmed {
  background: var(--surface);
}

.store-card--drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.store-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  gap: var(--s-3);
}

.store-card__body {
  padding: 4px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.store-card__empty {
  padding: var(--s-6);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

.store-card__footer {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.store-card__footer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.store-card__footer-row .timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.store-card__undo-btn {
  margin-left: auto;
  flex: 0 0 auto;
}

.store-card__send-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
}

.store-card__log-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  flex: 0 0 auto;
}

/* Item row */
.item-row {
  display: grid;
  grid-template-columns: 14px 22px 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 9px 16px;
  cursor: grab;
  position: relative;
  transition: background var(--transition);
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
}

.item-row + .item-row {
  border-top-color: var(--border);
  margin-top: -1px;
}

.item-row:hover {
  background: var(--surface-sunken);
}

.item-row--dragging {
  opacity: 0.35;
}

.item-row__drag-handle {
  color: var(--text-quaternary);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  margin-top: 1px;
  opacity: 0.65;
  transition: var(--transition);
}

.item-row:hover .item-row__drag-handle {
  color: var(--text-tertiary);
  opacity: 1;
}

.store-card--confirmed .item-row__drag-handle {
  cursor: default;
  opacity: 0.25;
}

.item-row--checked .item-row__name,
.item-row--checked .item-row__qty {
  color: var(--text-tertiary);
  text-decoration: line-through;
  text-decoration-color: var(--text-quaternary);
  text-decoration-thickness: 1px;
}

.item-row__check {
  margin-top: 2px;
}

.item-row__main {
  min-width: 0;
}

.item-row__name {
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 500;
  cursor: text;
  display: inline-block;
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
}

.item-row__name:hover {
  background: var(--bg);
}

.item-row__name-input {
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--accent);
  background: var(--surface);
  border-radius: 3px;
  padding: 1px 3px;
  margin-left: -3px;
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
  font-family: inherit;
  width: 100%;
}

.item-row__source {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.item-row__source .src-recipe { color: var(--text-tertiary); }
.item-row__source .src-list { color: var(--text-tertiary); font-style: italic; }
.item-row__source .src-quick { color: var(--accent); }

.item-row__qty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-top: 2px;
}

/* Unassigned items section */
.unassigned-card {
  border: 1px dashed var(--border-strong);
  background: oklch(98% 0.005 60);
  border-radius: var(--r-3);
  padding: 12px 0;
  margin-bottom: var(--s-4);
  grid-column: 1 / -1;
}

.unassigned-card__header {
  padding: 0 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.unassigned-card__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ============================================================
   Recipe library
   ============================================================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--s-8);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-4);
}

@media (min-width: 1500px) {
  .recipe-grid { grid-template-columns: repeat(4, 1fr); }
}

.recipe-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  cursor: pointer;
  transition: var(--transition);
  min-height: 180px;
}

.recipe-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

.recipe-card__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.recipe-card__meta {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.recipe-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.recipe-card__tags .tag {
  font-size: 11px;
  padding: 2px 7px;
  cursor: default;
}

.recipe-card__bot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recipe-card__added {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   Recipe / List editor
   ============================================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-bottom: var(--s-5);
  transition: var(--transition);
  background: transparent;
  border: none;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: var(--r-2);
}

.back-link:hover {
  color: var(--text-primary);
  background: var(--surface-sunken);
}

.editor-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
}

.editor-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
  border: 1px solid transparent;
  background: transparent;
  outline: none;
  width: 100%;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: var(--r-2);
  font-variation-settings: "opsz" 36, "wdth" 100;
}

.editor-title:hover { background: var(--surface-sunken); }
.editor-title:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.editor-meta {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  margin-bottom: var(--s-8);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-meta__row {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 13px;
  color: var(--text-secondary);
}

.editor-meta__row label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.editor-meta input[type="number"] {
  width: 56px;
  padding: 4px 8px;
  text-align: center;
  font-family: var(--font-mono);
}

.editor-section {
  margin-bottom: var(--s-10);
}

.editor-section__header {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.ingredient-row {
  display: grid;
  grid-template-columns: 16px 56px 86px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  position: relative;
  border-top: 1px solid transparent;
}

.ingredient-row:hover {
  background: var(--surface);
}

.ingredient-row__grip {
  cursor: grab;
  color: var(--text-quaternary);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  opacity: 0;
  transition: var(--transition);
}

.ingredient-row:hover .ingredient-row__grip { opacity: 1; }

.ingredient-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ingredient-row__main .input--ghost {
  font-size: 14px;
  font-weight: 500;
  padding: 6px 8px;
}

.ingredient-row__brand {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 8px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  outline: none;
  width: 100%;
}

.ingredient-row__brand:hover { background: var(--surface); border-color: var(--border); }
.ingredient-row__brand:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.ingredient-row__qty {
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
  padding: 6px 8px;
}

.ingredient-row__del {
  width: 28px;
  height: 28px;
  margin-top: 4px;
  opacity: 0;
  transition: var(--transition);
}

.ingredient-row:hover .ingredient-row__del { opacity: 1; }

/* Instruction step */
.step-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  position: relative;
}

.step-row__num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tertiary);
  padding-top: 10px;
  text-align: right;
}

.step-row__text {
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-2);
  resize: none;
  outline: none;
  width: 100%;
  font-family: var(--font-body);
  min-height: 36px;
  overflow: hidden;
}

.step-row__text:hover { background: var(--surface); border-color: var(--border); }
.step-row__text:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.step-row__del {
  opacity: 0;
  transition: var(--transition);
}

.step-row:hover .step-row__del { opacity: 1; }

/* Danger zone */
.danger-zone {
  margin-top: var(--s-12);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.danger-zone__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-quaternary);
}

/* ============================================================
   Lists library
   ============================================================ */

.list-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 720px;
}

.list-stack__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  padding: 14px 18px;
  cursor: pointer;
  transition: var(--transition);
}

.list-stack__item:hover {
  border-color: var(--border-strong);
}

.list-stack__name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.list-stack__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================================================
   History
   ============================================================ */

.history-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-width: 820px;
}

.history-week {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-3);
  overflow: hidden;
  transition: var(--transition);
}

.history-week:hover {
  border-color: var(--border-strong);
}

.history-week__head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: var(--s-4);
}

.history-week__date {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.history-week__summary {
  font-size: 13px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.history-week__toggle {
  width: 24px;
  height: 24px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.history-week--open .history-week__toggle {
  transform: rotate(180deg);
}

.history-week__body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-6);
}

.history-week__col h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: 0 0 var(--s-3);
}

.history-week__planned {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.history-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-section__empty {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

.history-week__col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.history-week__col li {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
}

.history-week__col li .label { color: var(--text-primary); }
.history-week__col li .meta { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 12px; }

.order-line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.order-line__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-line__store {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.order-line__meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ============================================================
   Settings modal
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border-radius: var(--r-4);
  width: 460px;
  max-width: 92vw;
  padding: var(--s-8);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px -16px rgba(0,0,0,0.25);
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-6);
}

.modal__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin: 0;
}

.modal__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
  gap: var(--s-4);
}

.modal__row label {
  font-size: 13px;
  color: var(--text-secondary);
}

.modal__divider {
  margin: var(--s-3) 0;
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-tertiary);
}

/* ============================================================
   Preview cart modal
   ============================================================ */

.modal--wide {
  width: 640px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}

.preview-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-sunken);
  border-radius: var(--r-2);
  margin-bottom: var(--s-4);
}

.preview-stores {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  overflow-y: auto;
  margin: 0 calc(-1 * var(--s-2));
  padding: 0 var(--s-2);
}

.preview-store {
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.preview-store--unassigned {
  border-style: dashed;
  background: oklch(98% 0.005 60);
}

.preview-store__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-store__items {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.preview-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.preview-item:last-child { border-bottom: none; }

.preview-item__name {
  flex: 1;
  min-width: 0;
}

.preview-item__qty {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ============================================================
   Collapsible store card
   ============================================================ */

.store-card__collapse {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--r-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.store-card__collapse:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.store-card__collapse svg {
  transition: transform var(--transition);
}

.store-card--collapsed .store-card__collapse svg {
  transform: rotate(-90deg);
}

.store-card__header-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.store-card__count {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.store-card--collapsed .store-card__body,
.store-card--collapsed .store-card__footer {
  display: none;
}

.store-card--collapsed .store-card__header {
  padding-bottom: 14px;
}

/* ============================================================
   Editable item qty
   ============================================================ */

.item-row__qty-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.item-row__qty-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: text;
  padding: 1px 4px;
  margin-right: -4px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.item-row__qty-display:hover {
  background: var(--bg);
  border-color: var(--border);
}

.item-row__qty-display--edited {
  color: var(--accent);
  font-weight: 500;
}

.item-row__qty-input {
  font-family: var(--font-mono);
  font-size: 12px;
  width: 70px;
  text-align: right;
  border: 1px solid var(--accent);
  background: var(--surface);
  border-radius: 3px;
  padding: 1px 4px;
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.item-row__qty-original {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-quaternary);
  text-decoration: line-through;
  text-decoration-color: var(--text-quaternary);
  white-space: nowrap;
  padding-right: 4px;
}

.item-row__unit-select {
  width: 72px;
  min-width: 72px;
  padding: 3px 20px 3px 7px;
  background-position: right 7px center;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Preview cart icon button — compact, square */
.preview-cart-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--r-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.preview-cart-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.preview-cart-btn--inline {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

/* ============================================================
   Currency input
   ============================================================ */

.currency-input {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-2);
  padding: 3px 8px 3px 8px;
  box-shadow: 0 0 0 2px var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 13px;
}

.currency-input__prefix {
  color: var(--text-tertiary);
  margin-right: 1px;
}

.currency-input__field {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  width: 70px;
  padding: 0;
}

.currency-input--compact .currency-input__field { width: 60px; font-size: 12px; }
.currency-input--compact { padding: 2px 6px; font-size: 12px; }

.currency-display {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-2);
  padding: 3px 8px;
  cursor: text;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  transition: var(--transition);
}

.currency-display:hover {
  background: var(--surface-sunken);
  border-color: var(--border);
}

.currency-display--empty {
  color: var(--text-quaternary);
  font-weight: 400;
  font-style: italic;
  font-family: var(--font-body);
}

.currency-display--compact {
  font-size: 12px;
  padding: 2px 6px;
}

.currency-display__prefix {
  color: var(--text-tertiary);
  font-weight: 400;
  margin-right: 1px;
}

.currency-display__placeholder {
  font-family: var(--font-body);
  font-style: italic;
}

/* Week header cost summary */
.week-cost-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-left: 1px solid var(--border);
}

.week-cost-summary__total {
  color: var(--text-primary);
  font-weight: 500;
}

.week-cost-summary__count {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* History costs */
.history-week__cost {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
}

.history-week__cost-partial {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-left: 6px;
  font-weight: 400;
}

.history-week__head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.order-line__cost {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  margin-left: auto;
}

/* ============================================================
   Save indicator
   ============================================================ */

.save-indicator {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 200ms ease-out;
}

.save-indicator__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-quaternary);
}

.save-indicator--saving .save-indicator__dot {
  background: var(--status-pending-fg);
  animation: pulse 1.2s ease-in-out infinite;
}

.save-indicator--saved .save-indicator__dot {
  background: var(--status-confirmed-fg);
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-2);
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,0.18);
  font-weight: 500;
  opacity: 0.95;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-4) 0;
}

.spacer-1 { height: var(--s-1); }
.spacer-2 { height: var(--s-2); }
.spacer-3 { height: var(--s-3); }
.spacer-4 { height: var(--s-4); }
.spacer-6 { height: var(--s-6); }
.spacer-8 { height: var(--s-8); }

/* Hide scrollbar visual chrome on tight panels but keep functionality */
.scroll-soft::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-soft::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.scroll-soft::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
.scroll-soft::-webkit-scrollbar-track { background: transparent; }
