/* ============================================================
   KnowIngre — Fresh Green Kitchen Journal
   Verdant · Crisp · Alive
   ============================================================ */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Color — verdant greens */
  --ink:        #1a2e1f;
  --ink-soft:   #3d5a42;
  --ink-muted:  #7d9a7e;
  --paper:      #f2f7f2;
  --paper-warm: #fafdf8;
  --paper-card: #f8fdf6;
  --stone:      #dce8db;
  --stone-dark: #c0d4be;

  /* Accent — fresh herb & moss */
  --clay:           #4a8c5c;
  --clay-deep:      #3a7048;
  --clay-ghost:     #edf7f0;
  --indigo:         #2d5a3d;
  --indigo-ghost:   #e8f2ea;

  /* Feedback */
  --herb:       #5b8b67;
  --herb-ghost: #ecf5ee;
  --gold:       #c48a2e;
  --gold-ghost: #fef8ee;
  --chili:      #c94a3a;
  --chili-ghost:#fef0ee;
  --bloom:      #e07b4c;
  --bloom-ghost:#fef4ee;

  /* Tokens */
  --bg:            var(--paper);
  --surface:       var(--paper-warm);
  --surface-card:  var(--paper-card);
  --border:        var(--stone);
  --border-strong: var(--stone-dark);
  --text:          var(--ink);
  --text-secondary:var(--ink-soft);
  --text-muted:    var(--ink-muted);
  --primary:       var(--clay);
  --primary-hover: var(--clay-deep);
  --primary-ghost: var(--clay-ghost);
  --danger:        var(--chili);
  --danger-ghost:  var(--chili-ghost);
  --success:       var(--herb);
  --success-ghost: var(--herb-ghost);
  --warning:       var(--gold);
  --warning-ghost: var(--gold-ghost);
  --highlight:     var(--bloom);
  --highlight-ghost: var(--bloom-ghost);

  /* Shape */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Shadow — layered for depth, now using green-black ink */
  --shadow-xs: 0 1px 2px rgba(26,46,31,0.04);
  --shadow-sm: 0 2px 8px rgba(26,46,31,0.06);
  --shadow:    0 4px 16px rgba(26,46,31,0.07);
  --shadow-lg: 0 12px 32px rgba(26,46,31,0.10);
  --shadow-xl: 0 20px 48px rgba(26,46,31,0.13);

  /* Type */
  --font-display: 'Songti SC', 'Noto Serif SC', 'Palatino', 'Georgia', serif;
  --font-body:    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono:    'SF Mono', 'Cascadia Code', monospace;

  /* Motion */
  --ease-out:   cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in:    cubic-bezier(0.55, 0.06, 0.68, 0.19);
  --ease-smooth:cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce:cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* ===== Grain Texture Overlay ===== */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== Header ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  font-size: 1.4rem;
  color: var(--clay);
  line-height: 1;
}
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}
.brand-en {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-left: 2px;
}
.brand-text .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Settings button */
.app-header .btn-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: all 0.2s var(--ease-out);
}
.app-header .btn-icon:hover {
  color: var(--ink);
  background: var(--primary-ghost);
  border-color: var(--clay);
}

/* ===== Tab Bar ===== */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 99;
}
.tab-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 2px;
  position: relative;
}

/* Default indicator — positioned by JS */
.tab-indicator {
  left: 0;
  width: 0;
}
.tab {
  padding: 14px 24px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: color 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-icon {
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.25s var(--ease-out);
}
.tab-icon svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab:hover { color: var(--text-secondary); }
.tab:hover .tab-icon { opacity: 0.4; transform: scale(0.85); }
.tab.active {
  color: var(--clay);
  font-weight: 600;
}
.tab.active .tab-icon {
  opacity: 1;
  transform: scale(1);
  color: var(--clay);
}
/* Sliding indicator */
.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background: var(--clay);
  border-radius: 3px 3px 0 0;
  transition: left 0.3s var(--ease-out), width 0.3s var(--ease-out);
}

/* ===== Content Area ===== */
.content {
  flex: 1;
  padding: 32px 24px 48px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Shared Page Header ===== */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-heading {
  min-width: 0;
}
.page-heading h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
}
.page-heading p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.page-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.recipe-controls .search-wrapper {
  max-width: 520px;
}
.inventory-list-head {
  margin-bottom: 14px;
}
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeSlideIn 0.35s var(--ease-out);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

/* Search */
.search-wrapper {
  flex: 1;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s var(--ease-out);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
  transition: all 0.2s var(--ease-out);
  line-height: 1;
}
.btn:hover {
  background: var(--primary-ghost);
  border-color: var(--clay);
  color: var(--clay);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--clay);
  color: #fff;
  border-color: var(--clay);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--clay-deep);
  border-color: var(--clay-deep);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: transparent;
  color: var(--chili);
  border-color: transparent;
  font-weight: 500;
}
.btn-danger:hover {
  background: var(--danger-ghost);
  border-color: var(--chili);
  color: var(--chili);
}

.btn-sm {
  padding: 5px 14px;
  height: 34px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn-xs {
  padding: 3px 10px;
  height: 28px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
}
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 0.82rem;
}
.btn-ghost:hover { border-color: var(--clay); color: var(--clay); background: var(--primary-ghost); }

.btn-plus, .btn-spark {
  font-size: 1.1rem;
  line-height: 1;
}

/* ===== Icon SVG ===== */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }
.icon svg {
  width: 100%; height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Tag Filters ===== */
.tag-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.tag-filter {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
  font-family: var(--font-body);
}
.tag-filter:hover { border-color: var(--clay); color: var(--clay); background: var(--primary-ghost); }
.tag-filter.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

/* ===== Recipe Grid ===== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.recipe-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}
/* Subtle top accent stripe on hover */
.recipe-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20px; right: 20px;
  height: 3px;
  background: var(--clay);
  border-radius: 0 0 3px 3px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s var(--ease-out);
}
.recipe-card:hover {
  border-color: var(--clay);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(74,140,92,0.15);
  transform: translateY(-5px);
}
.recipe-card:hover::before { transform: scaleX(1); }

.recipe-card .card-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: var(--ink);
}
.recipe-card .card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.recipe-card .tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 10px;
  background: var(--indigo-ghost);
  color: var(--indigo);
  border-radius: 20px;
}
.recipe-card .card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.8;
}
.card-meta__missing {
  color: #c2410c;
  background: #fff7ed;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.card-meta__ready {
  color: var(--herb);
  font-size: 0.75rem;
  font-weight: 500;
}
.recipe-sentinel {
  grid-column: 1 / -1;
  height: 1px;
  margin: -1px 0 0;
  visibility: hidden;
}

.recipe-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.recipe-card .card-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.25s var(--ease-out);
}
.recipe-card:hover .card-hint {
  opacity: 1;
  transform: translateX(0);
}
.recipe-card .btn-cook {
  font-size: 0.9rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  opacity: 0.7;
  transition: all 0.2s var(--ease-out);
}
.recipe-card .btn-cook:hover {
  opacity: 1;
  background: var(--primary-ghost);
  border-color: var(--clay);
}

.star { color: var(--gold); display: inline-flex; }
.star-empty { color: var(--stone-dark); display: inline-flex; }

/* Card entrance animation */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.recipe-card {
  animation: cardIn 0.45s var(--ease-out) backwards;
}
.recipe-card:nth-child(1) { animation-delay: 0.00s; }
.recipe-card:nth-child(2) { animation-delay: 0.06s; }
.recipe-card:nth-child(3) { animation-delay: 0.12s; }
.recipe-card:nth-child(4) { animation-delay: 0.18s; }
.recipe-card:nth-child(5) { animation-delay: 0.24s; }
.recipe-card:nth-child(6) { animation-delay: 0.30s; }
.recipe-card:nth-child(7) { animation-delay: 0.36s; }
.recipe-card:nth-child(8) { animation-delay: 0.42s; }
.recipe-card:nth-child(9) { animation-delay: 0.48s; }
.recipe-card:nth-child(n+10) { animation-delay: 0.54s; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-illustration {
  font-size: 3.5rem;
  margin-bottom: 16px;
  filter: grayscale(0.2);
}
.empty-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.empty-hint {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ===== AI Generate ===== */
.generate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow);
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}
/* Subtle warm glow */
.generate-box::after {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--clay-ghost) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.generate-hero {
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}
.generate-spark {
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
  color: var(--clay);
  animation: sparkPulse 2s ease-in-out infinite;
}
@keyframes sparkPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.1); }
}
.generate-hero h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.generate-hero p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.generate-box .search-input {
  flex: 1;
  font-size: 1rem;
  padding: 14px 20px;
}

.generate-result { margin-top: 28px; position: relative; z-index: 1; }
.generate-result .result-card {
  background: linear-gradient(135deg, var(--primary-ghost) 0%, #fdf8f2 100%);
  border: 1px solid var(--stone);
  border-radius: var(--radius-lg);
  padding: 28px;
  animation: fadeSlideIn 0.4s var(--ease-out);
}
.generate-result h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 6px;
  color: var(--ink);
}
.generate-result .ingredient-list { margin: 16px 0; }
.generate-result .ingredient-item {
  display: inline-block;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 6px 8px 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.generate-result .step-list { list-style: none; counter-reset: step; margin: 16px 0; }
.generate-result .step-list li {
  counter-increment: step;
  padding: 10px 0 10px 40px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  font-size: 0.9rem;
  line-height: 1.7;
  position: relative;
}
.generate-result .step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 10px;
  width: 26px;
  height: 26px;
  line-height: 26px;
  background: var(--clay);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
}
.result-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Gen edit rows */
.gen-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.gen-edit-row input[type="text"] {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
}
.gen-edit-row input:focus { outline: none; border-color: var(--clay); }

.gen-suggest {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.gen-suggest label {
  font-weight: 600;
  font-size: 0.82rem;
  display: block;
  margin-bottom: 10px;
  color: var(--ink-soft);
}
.suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggest-chip {
  padding: 6px 16px;
  border: 1.5px solid var(--clay);
  border-radius: 20px;
  background: transparent;
  color: var(--clay);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.suggest-chip:hover {
  background: var(--clay);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.suggest-chip:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ===== Inventory Layout ===== */
.inventory-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 18px;
}
.section-head h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.section-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--stone);
  padding: 2px 8px;
  border-radius: 20px;
}

/* Inventory Form */
.w-40 { flex: 1; }

/* Inventory List */
.inv-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.inv-controls .search-wrapper { max-width: 360px; }
.inv-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.inv-chip {
  font-size: 0.76rem;
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s var(--ease-out);
  white-space: nowrap;
}
.inv-chip:hover {
  border-color: var(--clay);
  color: var(--clay);
}
.inv-chip--active {
  background: var(--clay);
  border-color: var(--clay);
  color: #fff;
}
.inv-chip--toggle {
  border-style: dashed;
}
.inv-chip--toggle.inv-chip--active {
  border-style: solid;
}
.inv-chip--danger {
  border-color: #fdba74;
  color: #9a3412;
  background: #fff7ed;
}
.inv-chip--danger.inv-chip--active {
  background: #ea580c;
  border-color: #ea580c;
  color: #fff;
}
.inv-chip--danger:hover {
  border-color: #ea580c;
  color: #ea580c;
}
.inventory-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.inv-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s var(--ease-out);
}
.inv-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.inv-item .inv-info { display: flex; gap: 8px; align-items: baseline; }
.inv-item .inv-name { font-weight: 600; color: var(--ink); font-size: 0.95rem; }
.inv-item .inv-amount { color: var(--text-muted); font-size: 0.82rem; }
.inv-item .inv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.inv-item .inv-category {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--indigo-ghost);
  color: var(--indigo);
  padding: 2px 10px;
  border-radius: 20px;
}
.inv-item .inv-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.inv-item .inv-actions button {
  font-size: 0.72rem;
  padding: 2px 8px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.inv-item .inv-actions .inv-edit-btn { color: var(--clay); }
.inv-item .inv-actions .inv-edit-btn:hover { background: var(--primary-ghost); }
.inv-item .inv-actions .inv-del-btn { color: var(--danger); }
.inv-item .inv-actions .inv-del-btn:hover { background: var(--danger-ghost); }

/* Low stock */
.inv-item--low {
  border-color: #e89547;
  background: linear-gradient(0deg, #fff7ed, var(--surface) 40%);
}
.inv-item .low-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  background: #e89547;
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  letter-spacing: 0.5px;
}
.low-stock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #7c2d12;
}
.low-stock-banner__label { font-weight: 600; }
.low-stock-banner [data-lowstock-name] {
  background: #fff;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.low-stock-banner [data-lowstock-name]:hover {
  background: #fed7aa;
  border-color: #fb923c;
}
.low-stock-banner__close {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #7c2d12;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}
.low-stock-banner__close:hover { background: rgba(124, 45, 18, 0.1); }

/* Matchable Recipes */
.matchable-recipes { display: flex; flex-direction: column; gap: 10px; }
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  border-left: 4px solid var(--herb);
  transition: all 0.2s var(--ease-out);
}
.match-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.match-card.partial { border-left-color: var(--gold); }
.match-card .match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.match-card .match-name {
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 1rem;
}
.match-card .match-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
}
.match-badge.ready { background: var(--herb-ghost); color: var(--herb); }
.match-badge.partial { background: var(--gold-ghost); color: var(--gold); }
.match-card .btn-cook-done {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
}
.match-in-menu {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--bloom);
  font-weight: 500;
}
.btn-cook-done:hover { background: var(--herb-ghost); border-color: var(--herb); color: var(--herb); }

.done-list { display: flex; flex-direction: column; gap: 10px; }
.done-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.done-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.done-item-name { font-weight: 600; color: var(--ink); }
.done-item-need { font-size: 0.78rem; color: var(--text-muted); }
.done-item-edit {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.done-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 100px;
}
.done-field > span { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.done-stock-val { font-size: 0.88rem; color: var(--ink); padding: 6px 0; }
.done-conversion-note {
  margin: -2px 0 10px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--stone);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}
.done-conversion-note--ok { background: var(--herb-ghost); color: var(--herb); }
.done-conversion-note--warn { background: var(--gold-ghost); color: var(--ink); }
.done-conversion-setup {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -3px 0 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.done-conversion-factor {
  width: 88px;
  padding: 5px 7px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}
.done-conversion-factor:focus { border-color: var(--herb); outline: none; }
.done-remove-cb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--chili);
  white-space: nowrap;
  cursor: pointer;
}
.done-remove-cb input { accent-color: var(--chili); }
.done-keep-cb { color: var(--text-secondary); }
.done-keep-cb input { accent-color: var(--herb); }

.match-card .match-missing {
  font-size: 0.8rem;
  color: var(--chili);
  margin-top: 6px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 18, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s var(--ease-out);
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 92%;
  max-width: 640px;
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s var(--ease-out);
}
.modal-sm { max-width: 440px; }

/* ===== Custom confirm dialog ===== */
.confirm-dialog {
  overflow: hidden;
  position: relative;
  display: flex !important;
  flex-direction: column;
  max-height: min(90dvh, 720px) !important;
}
.confirm-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s, color 0.15s;
}
.confirm-close:hover { background: var(--stone); color: var(--ink); }
.confirm-body {
  padding: 32px 28px 20px;
  text-align: center;
  overflow-y: auto;
  flex: 1 1 auto;
}
.confirm-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-ghost);
  color: var(--clay);
  position: relative;
}
.confirm-icon::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.08;
  z-index: -1;
}
.confirm-dialog[data-type="danger"] .confirm-icon { background: #fee2e2; color: #dc2626; }
.confirm-dialog[data-type="warning"] .confirm-icon { background: #fef3c7; color: #d97706; }
.confirm-dialog[data-type="info"] .confirm-icon { background: #dbeafe; color: #2563eb; }

.confirm-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-align: center;
}
.confirm-message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted);
  text-align: center;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}
.confirm-details {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
}
.confirm-chip {
  display: inline-block;
  font-size: 0.82rem;
  padding: 4px 12px;
  background: var(--primary-ghost);
  color: var(--clay);
  border-radius: 14px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.confirm-dialog[data-type="danger"] .confirm-chip { background: #fef2f2; color: #b91c1c; }
.confirm-dialog[data-type="warning"] .confirm-chip { background: #fffbeb; color: #92400e; }

.confirm-warning {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 16px auto 0;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 8px;
}
.confirm-dialog[data-type="warning"] .confirm-warning { color: #92400e; background: #fffbeb; }

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  background: var(--stone);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.confirm-actions .btn {
  min-width: 96px;
  height: 38px;
  font-weight: 500;
  font-size: 0.88rem;
}
.confirm-actions .btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.confirm-actions .btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
  border-color: transparent;
}
@media (max-width: 480px) {
  .confirm-body { padding: 26px 20px 14px; }
  .confirm-icon { width: 48px; height: 48px; }
  .confirm-title { font-size: 1.05rem; }
  .confirm-message { font-size: 0.85rem; }
  .confirm-actions { padding: 12px 16px; justify-content: stretch; }
  .confirm-actions .btn { flex: 1; min-width: 0; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scopeFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tab-panel.scope-fade-in {
  animation: scopeFadeIn 0.28s var(--ease-out);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  flex-shrink: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.modal-close:hover { background: var(--primary-ghost); color: var(--clay); }

.modal-body {
  padding: 28px;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ===== Form Groups ===== */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.form-group label:first-child { margin-top: 0; }
.form-row { display: flex; gap: 16px; }

.form-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-body input[type="text"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s var(--ease-out);
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}
.modal-body textarea { resize: vertical; min-height: 80px; }

/* Recipe viewer (read-only mode) */
.recipe-viewer { display: flex; flex-direction: column; gap: 22px; }
.viewer-head { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.viewer-title { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--ink); letter-spacing: 0.02em; }
.viewer-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.viewer-tag {
  font-size: 0.72rem;
  background: var(--primary-ghost);
  color: var(--clay);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}
.viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  align-items: center;
}
.viewer-rating { color: #e8a547; letter-spacing: 2px; font-size: 0.95rem; }
.viewer-stat { display: inline-flex; align-items: center; gap: 4px; }
.viewer-section { display: flex; flex-direction: column; gap: 10px; }
.viewer-section__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.viewer-ings { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.viewer-ing {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dotted var(--border);
}
.viewer-ing:last-child { border-bottom: none; }
.viewer-ing__name { font-weight: 500; color: var(--ink); font-size: 0.95rem; flex: 1; }
.viewer-ing__amt { color: var(--text-muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.viewer-ing__opt {
  font-size: 0.68rem;
  background: var(--stone);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
}
.viewer-ing--opt .viewer-ing__name { color: var(--text-muted); }
.viewer-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.viewer-step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  align-items: start;
  line-height: 1.7;
  font-size: 0.95rem;
  color: var(--ink);
}
.viewer-step::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--clay);
  color: #fff;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.viewer-notes {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-alt, var(--stone));
  border-left: 3px solid var(--clay);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
}
.viewer-cooking-notes { gap: 9px; }
.viewer-cooking-note {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
}
.viewer-cooking-note div {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.7rem;
}
.viewer-cooking-note p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.viewer-notes-toggle {
  align-self: flex-start;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font: 500 0.76rem var(--font-body);
}
.viewer-notes-toggle:hover { color: var(--primary-hover); }
.viewer-cooking-notes-all {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.viewer-cooking-notes-all[hidden] { display: none; }
@media (max-width: 480px) {
  .viewer-title { font-size: 1.2rem; }
  .viewer-step { grid-template-columns: 26px 1fr; gap: 10px; font-size: 0.88rem; }
  .viewer-step::before { width: 24px; height: 24px; font-size: 0.72rem; }
  .viewer-ing { padding: 8px 0; }
}

/* Ingredient & step rows in modal */
.ingredient-row, .step-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.ingredient-row input { flex: 1; }
.ingredient-row input[type="checkbox"] {
  width: auto;
  accent-color: var(--clay);
}
.step-row textarea {
  flex: 1;
  min-height: 38px;
  resize: vertical;
  overflow: hidden;
  field-sizing: content;
}
.step-row .step-num {
  width: 28px;
  height: 28px;
  line-height: 28px;
  background: var(--clay);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.row-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}
.row-remove:hover { color: var(--chili); }

/* Star rating */
.star-rating { display: flex; gap: 2px; padding-top: 4px; }
.star-rating span {
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--stone-dark);
  transition: all 0.15s;
}
.star-rating span:hover { transform: scale(1.15); }
.star-rating span.on { color: var(--gold); }

/* Form actions */
.form-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Settings form */
.settings-form .form-group { margin-bottom: 18px; }

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--stone);
  border-top-color: var(--clay);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Status Bar — styles moved to end of file ===== */

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--stone-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Selection ===== */
::selection {
  background: var(--clay-ghost);
  color: var(--clay-deep);
}

/* ===== Utility Classes (extracted from inline styles) ===== */
.gen-step-text { flex:1; min-height:36px; border:1.5px solid var(--border); border-radius:8px; padding:8px; font-size:0.9rem; font-family:var(--font-body); resize:vertical; }
.gen-li-step { display:flex; align-items:flex-start; gap:8px; margin-bottom:6px; }
.gen-notes-area { width:100%; min-height:60px; border:1.5px solid var(--border); border-radius:8px; padding:8px; font-size:0.9rem; font-family:var(--font-body); resize:vertical; }
.inv-row { display:flex; align-items:center; gap:4px; }

/* ===== In-Menu Card Badge ===== */
.recipe-card.in-menu { border-color: var(--bloom); background: linear-gradient(135deg, var(--bloom-ghost) 0%, var(--paper-card) 80%); }
.recipe-card.in-menu:hover { border-color: var(--bloom); }
.card-menu-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--bloom);
  color: #fff;
  border: none;
  border-radius: 20px;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.2s var(--ease-out);
  z-index: 2;
  line-height: 1;
}
.card-menu-badge .icon svg { display: block; }
.card-menu-badge:hover {
  background: var(--chili);
  transform: scale(1.05);
}

/* ===== Today Menu ===== */
.menu-recipe-list { display:grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap:14px; margin-bottom:24px; }

.shopping-section { margin-top:12px; }
.shopping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.shopping-header h3 { margin: 0; }
.shopping-actions { display: flex; gap: 6px; }
.shopping-actions .btn { color: var(--text-muted); }
.shopping-actions .btn:hover { color: var(--clay); border-color: var(--clay); }
.shopping-section h3 {
  font-family:var(--font-display);
  font-size:1.05rem;
  font-weight:700;
  margin-bottom:12px;
}
.shopping-summary {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.shopping-summary b { color: var(--text); }
.shopping-list { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:8px; }
.shopping-item {
  display:flex;
  flex-direction:column;
  gap:3px;
  padding:8px 12px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
}
.shopping-item.missing { border-left:3px solid var(--chili); background:var(--chili-ghost); }
.shopping-item.have { border-left:3px solid var(--herb); background:var(--herb-ghost); }
.shopping-item-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
}
.shopping-item-name { font-weight:600; font-size:0.88rem; }
.stock-tag {
  font-size:0.68rem;
  font-weight:500;
  padding:1px 10px;
  border-radius:20px;
  white-space:nowrap;
  flex-shrink:0;
}
.stock-tag--have { background:var(--indigo-ghost); color:var(--indigo); }
.stock-tag--need { background:var(--gold-ghost); color:var(--gold); cursor:pointer; }
.stock-tag--need:hover { background:var(--gold); color:#fff; }
.shopping-item-detail { font-size:0.72rem; color:var(--text-muted); line-height:1.5; }
.shopping-item-stock-hint { color:var(--indigo); font-weight:500; flex-shrink:0; }
.shopping-empty { font-size:0.88rem; color:var(--herb); font-weight:500; padding:16px 0; }

/* ===== New Keyframe Animations ===== */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.95); }
}
@keyframes popIn {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 var(--primary-ghost); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes floatEmoji {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@keyframes pageLoadFade {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Page Load Animation ===== */
.app-header { animation: pageLoadFade 0.5s var(--ease-out) backwards; }
.tab-bar     { animation: pageLoadFade 0.5s var(--ease-out) 0.1s backwards; }
.content     { animation: pageLoadFade 0.5s var(--ease-out) 0.2s backwards; }
.status-bar  { animation: pageLoadFade 0.5s var(--ease-out) 0.3s backwards; }

/* ===== Button Ripple ===== */
.btn, .btn-primary, .btn-sm {
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}
.btn:active::after {
  opacity: 0.08;
}

/* ===== Focus Glow Animation ===== */
.search-input:focus,
.modal-body input[type="text"]:focus,
.modal-body input[type="password"]:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  animation: pulseRing 1.5s var(--ease-out);
}

/* ===== Star Pop Animation ===== */
.star-rating span.pop { animation: popIn 0.3s var(--ease-bounce); }

/* ===== Empty State Float ===== */
.empty-illustration { animation: floatEmoji 3s ease-in-out infinite; }

/* ===== AI Generation Animations ===== */
@keyframes shimmerBg {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes revealIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes aiSpin {
  to { transform: rotate(360deg); }
}
@keyframes checkPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.ai-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--stone-dark);
  border-top-color: var(--clay);
  border-radius: 50%;
  animation: aiSpin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* Button loading state — small spinner overlay */
.btn.is-loading, .btn-icon.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after, .btn-icon.is-loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  color: var(--clay);
  animation: aiSpin 0.7s linear infinite;
}
.btn.is-loading svg, .btn-icon.is-loading svg { visibility: hidden; }
.ai-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  background: var(--herb);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  animation: checkPop 0.35s var(--ease-bounce);
  vertical-align: middle;
  margin-right: 4px;
}

/* Shimmer skeleton rows */
.shimmer-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.shimmer-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--stone) 25%, var(--primary-ghost) 50%, var(--stone) 75%);
  background-size: 200% 100%;
  animation: shimmerBg 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.shimmer-bar {
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--stone) 25%, var(--primary-ghost) 50%, var(--stone) 75%);
  background-size: 200% 100%;
  animation: shimmerBg 1.2s ease-in-out infinite;
  flex: 1;
}
.shimmer-bar--tall { height: 42px; }
.shimmer-bar.w-60 { max-width: 60%; }
.shimmer-bar.w-30 { max-width: 30%; }
.shimmer-bar:nth-child(1) { animation-delay: 0s; }
.shimmer-bar:nth-child(2) { animation-delay: 0.15s; }
.shimmer-row:nth-child(2) .shimmer-bar { animation-delay: 0.1s; }
.shimmer-row:nth-child(3) .shimmer-bar { animation-delay: 0.2s; }
.shimmer-row:nth-child(4) .shimmer-bar { animation-delay: 0.3s; }

/* Staggered reveal when content arrives */
.reveal-row {
  animation: revealIn 0.3s var(--ease-out) backwards;
}

/* ===== Tab Panel Slide ===== */
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: slideUp 0.35s var(--ease-out);
}

/* ===== Cooking History ===== */
.history-range {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  flex-shrink: 0;
}
.history-range-btn {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  cursor: pointer;
  font: 500 0.76rem var(--font-body);
  transition: background 0.18s ease, color 0.18s ease;
}
.history-range-btn:hover { color: var(--text); }
.history-range-btn.active {
  color: var(--primary-hover);
  background: var(--primary-ghost);
}
.history-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.history-metric {
  min-width: 0;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.history-metric-label,
.history-metric-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.history-metric strong {
  display: block;
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  line-height: 1.25;
  color: var(--primary-hover);
  font-variant-numeric: tabular-nums;
}
.history-section {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.history-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.history-section-head h3 {
  font-family: var(--font-display);
  font-size: 1rem;
}
.history-section-head p {
  color: var(--text-muted);
  font-size: 0.72rem;
}
.history-year-select {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.history-year-select select {
  min-height: 32px;
  padding: 4px 28px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-card);
  color: var(--text);
  font-family: var(--font-body);
}
.history-calendar-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 0 7px;
  scrollbar-width: thin;
  scrollbar-color: var(--stone-dark) transparent;
}
.history-months {
  display: grid;
  grid-template-columns: repeat(var(--history-weeks), 11px);
  column-gap: 3px;
  width: max-content;
  min-width: calc(var(--history-weeks) * 14px);
  margin-left: 28px;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.66rem;
}
.history-months span { white-space: nowrap; }
.history-calendar-row {
  display: flex;
  gap: 8px;
  width: max-content;
}
.history-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  row-gap: 3px;
  width: 20px;
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 11px;
}
.history-heatmap {
  display: grid;
  grid-template-columns: repeat(var(--history-weeks), 11px);
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
}
.history-heat-cell {
  width: 11px;
  height: 11px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  cursor: default;
  background: var(--stone);
}
button.history-heat-cell { cursor: pointer; }
.history-heat-cell span { display: none; }
button.history-heat-cell:hover,
button.history-heat-cell:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.history-heat-cell.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--highlight); }
.history-heat-cell.level-1,
.history-legend .level-1 { background: #bdddbd; }
.history-heat-cell.level-2,
.history-legend .level-2 { background: #83bd8b; }
.history-heat-cell.level-3,
.history-legend .level-3 { background: #4a8c5c; }
.history-heat-cell.level-4,
.history-legend .level-4 { background: #2d5a3d; }
.history-legend {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.65rem;
}
.history-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--stone);
}
.history-calendar-hint {
  display: none;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.66rem;
}
.history-monthly-section { margin-top: 16px; }
.history-monthly-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: 4px 0 2px;
  scrollbar-width: thin;
}
.history-monthly-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(20px, 1fr));
  gap: 8px;
  min-width: 330px;
  height: 145px;
}
.history-month-column {
  display: grid;
  grid-template-rows: 20px minmax(70px, 1fr) 18px;
  align-items: end;
  justify-items: center;
  min-width: 0;
}
.history-month-column strong {
  color: var(--text-secondary);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}
.history-month-track {
  display: flex;
  width: min(18px, 72%);
  height: 100%;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 5px 5px 2px 2px;
  background: var(--stone);
}
.history-month-track span {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--primary), var(--herb));
  transition: height 0.25s var(--ease-out);
}
.history-month-column small {
  color: var(--text-muted);
  font-size: 0.62rem;
  white-space: nowrap;
}
.history-selected-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-ghost);
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.history-selected-date button {
  border: 0;
  background: transparent;
  color: var(--primary-hover);
  cursor: pointer;
  font: 500 0.74rem var(--font-body);
}
.history-day-detail {
  margin-top: 16px;
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: linear-gradient(180deg, var(--primary-ghost), var(--surface) 72px);
}
.history-day-timeline .history-timeline-item {
  background: transparent;
}
.history-analysis-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
}
.history-analysis-toolbar strong,
.history-analysis-toolbar span { display: block; }
.history-analysis-toolbar strong {
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.history-analysis-toolbar > div:first-child span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.66rem;
}
.history-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.history-rank-row {
  display: grid;
  grid-template-columns: 20px minmax(80px, 130px) minmax(50px, 1fr) 38px;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  font-size: 0.76rem;
}
.history-rank-index {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.history-rank-name,
.history-timeline-main button {
  min-width: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  font: 500 0.78rem var(--font-body);
}
.history-rank-name:hover:not(:disabled),
.history-timeline-main button:hover:not(:disabled) { color: var(--primary); }
.history-rank-name:disabled,
.history-timeline-main button:disabled { cursor: default; }
.history-rank-track,
.history-tag-track {
  height: 7px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--stone);
}
.history-rank-track span,
.history-tag-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}
.history-rank-row > strong {
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.history-tag-row + .history-tag-row { margin-top: 11px; }
.history-tag-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 0.74rem;
}
.history-tag-label strong { font-variant-numeric: tabular-nums; }
.history-tag-track span { background: var(--highlight); }
.history-recent { margin-top: 16px; }
.history-timeline { min-width: 0; }
.history-timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 8px 84px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border-top: 1px solid var(--border);
}
.history-timeline-item:first-child { border-top: 0; }
.history-timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}
.history-timeline-date strong,
.history-timeline-date span,
.history-timeline-main span { display: block; }
.history-timeline-date strong { font-size: 0.74rem; }
.history-timeline-date span,
.history-timeline-main span {
  color: var(--text-muted);
  font-size: 0.66rem;
}
.history-timeline-main .history-timeline-note {
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-undo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.history-undo:hover { color: var(--danger); background: var(--danger-ghost); }
.history-undo svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

@media (min-width: 900px) {
  .history-timeline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }
  .history-timeline-item:nth-child(2) { border-top: 0; }
}
.history-chart-empty {
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}
.history-empty {
  margin-top: 16px;
  padding: 72px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}
.history-empty-mark { color: var(--primary); font-size: 2rem; }
.history-empty h3 { margin: 8px 0 3px; color: var(--text-secondary); font-family: var(--font-display); }
.history-empty p { font-size: 0.8rem; }

/* ===== Full cooking records ===== */
.history-records-modal {
  width: min(94vw, 920px);
  max-width: 920px;
  max-height: min(90dvh, 860px);
}
.history-records-header p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.74rem;
}
.history-records-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-records-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding-top: 20px;
  overflow: hidden;
}
.history-filter-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  font: 600 0.78rem var(--font-body);
}
.history-filter-toggle > span:last-child { transition: transform 0.18s ease; }
.history-filter-toggle.active > span:last-child { transform: rotate(180deg); }
.history-records-filters {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(140px, 0.65fr) minmax(140px, 0.65fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
}
.history-records-filters label > span,
.history-record-edit label > span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
}
.history-records-filters input,
.history-record-edit input,
.history-record-edit textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 0.8rem var(--font-body);
}
.history-records-filters input:focus,
.history-record-edit input:focus,
.history-record-edit textarea:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}
.history-records-filter-actions {
  display: flex;
  gap: 7px;
}
.history-records-view-options {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: -2px 0 8px;
}
.history-records-view-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.7rem;
}
.history-records-view-options label > span {
  flex-shrink: 0;
  white-space: nowrap;
}
.history-records-view-options select {
  min-height: 32px;
  padding: 4px 27px 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-secondary);
  font: 0.74rem var(--font-body);
}
.history-records-view-options select:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}
.history-records-list {
  flex: 1 1 auto;
  min-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.history-record-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 1.4fr) auto;
  align-items: center;
  gap: 16px;
  padding: 15px 4px;
  border-top: 1px solid var(--border);
}
.history-record-row:first-child { border-top: 0; }
.history-record-date strong,
.history-record-date span,
.history-record-main span {
  display: block;
}
.history-record-date strong {
  color: var(--text-secondary);
  font-size: 0.76rem;
}
.history-record-date span,
.history-record-main span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
}
.history-record-name {
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: 600 0.88rem var(--font-body);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-record-name:hover:not(:disabled) { color: var(--primary); }
.history-record-name:disabled { cursor: default; }
.history-record-note {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.history-record-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}
.history-record-edit-button,
.history-record-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
}
.history-record-edit-button:hover {
  color: var(--primary);
  background: var(--primary-ghost);
}
.history-record-delete {
  color: var(--text-muted);
}
.history-record-delete:hover {
  color: var(--danger);
  background: var(--danger-ghost);
}
.history-record-edit-button svg,
.history-record-delete svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.history-record-edit {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-ghost);
}
.history-record-edit[hidden] { display: none; }
.history-record-edit label {
  min-width: 210px;
}
.history-record-edit-note {
  flex: 1;
  min-width: 240px !important;
}
.history-record-edit textarea {
  min-height: 64px;
  resize: vertical;
}
.history-records-loading,
.history-records-empty {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}
.history-records-empty strong {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.history-records-pagination {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px -28px -28px;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
}
.history-records-pagination[hidden] { display: none; }
.history-records-pagination span {
  min-width: 90px;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-align: center;
}

.history-entry-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.history-entry-recipe-picker { position: relative; }
.history-recipe-suggestions {
  position: absolute;
  z-index: 6;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.history-recipe-suggestions[hidden] { display: none; }
.history-recipe-suggestion {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
}
.history-recipe-suggestion:hover,
.history-recipe-suggestion:focus-visible {
  outline: none;
  background: var(--primary-ghost);
}
.history-recipe-suggestion strong { font-size: 0.84rem; }
.history-recipe-suggestion span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-recipe-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--primary-ghost);
  color: var(--text-secondary);
  font-size: 0.74rem;
}
.history-recipe-selected[hidden] { display: none; }
.history-recipe-selected strong { color: var(--primary-hover); }
.history-entry-modal input[type="datetime-local"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 0.9rem var(--font-body);
}
.history-entry-modal input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--primary-ghost);
}
.history-entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.done-cook-notes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}
.done-cook-notes > span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.done-cook-notes textarea { min-height: 72px; }

@media (max-width: 720px) {
  #modalHistoryRecords {
    align-items: stretch;
    padding: 0;
  }
  #modalHistoryRecords .history-records-modal {
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .history-records-modal .modal-header { border-radius: 0; }
  .history-records-body { padding-top: 12px; }
  .history-filter-toggle { display: flex; }
  .history-records-filters.is-collapsed { display: none; }
  .history-records-view-options {
    justify-content: space-between;
    margin-top: 0;
  }
  .history-records-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .history-records-search,
  .history-records-filter-actions {
    grid-column: 1 / -1;
  }
  .history-records-filter-actions .btn { flex: 1; }
  .history-records-pagination {
    margin: 8px -18px -18px;
    padding: 12px 18px;
  }
  .history-record-row {
    grid-template-columns: minmax(105px, 0.8fr) minmax(120px, 1.2fr) auto;
    gap: 9px;
  }
  .history-record-edit { flex-wrap: wrap; }
  .history-record-edit-note { width: 100%; min-width: 0 !important; }
}

@media (max-width: 480px) {
  .history-records-filters { grid-template-columns: 1fr 1fr; padding: 10px; }
  .history-record-row {
    grid-template-columns: 1fr auto;
    align-items: start;
    padding: 13px 2px;
  }
  .history-record-date { grid-column: 1; grid-row: 2; }
  .history-record-main { grid-column: 1; grid-row: 1; }
  .history-record-actions { grid-column: 2; grid-row: 1 / span 2; }
  .history-record-edit { grid-column: 1 / -1; flex-wrap: wrap; }
  .history-record-edit label { width: 100%; min-width: 0; }
  .history-records-pagination { margin: 8px -12px -12px; padding: 12px; }
  .history-day-detail .history-section-head { align-items: flex-start; }
  .history-analysis-toolbar { align-items: stretch; flex-direction: column; }
  .history-analysis-toolbar .history-range { align-self: flex-start; }
  .history-calendar-hint { display: block; }
  .history-monthly-chart { gap: 5px; min-width: 326px; }
  .history-entry-actions .btn { flex: 1; }
}

/* ===== Kitchen Assistant ===== */
.kitchen-fab {
  position: fixed;
  right: 24px;
  bottom: max(68px, calc(env(safe-area-inset-bottom) + 56px));
  z-index: 240;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--clay-deep);
  border-radius: 24px;
  background: var(--clay);
  color: #fff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font: 600 0.82rem var(--font-body);
  transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
.kitchen-fab:hover { background: var(--clay-deep); transform: translateY(-2px); }
.kitchen-fab:focus-visible { outline: 2px solid var(--bloom); outline-offset: 3px; }
.kitchen-fab.is-compact {
  width: 44px;
  padding: 0;
  justify-content: center;
}
.kitchen-fab.is-compact > span:last-child { display: none; }
.history-modal-open .kitchen-fab { display: none; }
.kitchen-fab-icon { display: inline-flex; }
.kitchen-fab-icon svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.kitchen-assistant[hidden] { display: none; }
.kitchen-assistant { position: fixed; inset: 0; z-index: 500; }
.kitchen-assistant-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(26, 46, 31, 0.18);
  cursor: pointer;
  animation: kitchenBackdropIn 0.2s ease-out;
}
@keyframes kitchenBackdropIn { from { opacity: 0; } to { opacity: 1; } }
.kitchen-drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(430px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  animation: kitchenDrawerIn 0.28s var(--ease-out);
}
@keyframes kitchenDrawerIn { from { transform: translateX(24px); opacity: 0.7; } to { transform: translateX(0); opacity: 1; } }
.kitchen-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 15px;
  border-bottom: 1px solid var(--border);
}
.kitchen-drawer-header h2 { font-family: var(--font-display); font-size: 1.2rem; }
.kitchen-drawer-header p { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--text-muted); font-size: 0.7rem; }
.kitchen-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--herb); }
.kitchen-drawer-actions { display: flex; gap: 4px; }
.kitchen-drawer-actions .btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; }
.kitchen-drawer-actions .btn-icon:hover { color: var(--text); background: var(--primary-ghost); }
.kitchen-drawer-actions svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.kitchen-context-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 20px; background: var(--primary-ghost); color: var(--text-secondary); font-size: 0.72rem; }
.kitchen-context-bar label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.kitchen-context-bar input { accent-color: var(--primary); }
.kitchen-context-bar span { color: var(--text-muted); text-align: right; }
.kitchen-messages { flex: 1; overflow-y: auto; padding: 20px; overscroll-behavior: contain; }
.kitchen-welcome { padding: 38px 10px 24px; color: var(--text-secondary); text-align: center; }
.kitchen-welcome-mark { margin-bottom: 8px; color: var(--clay); font-size: 1.8rem; }
.kitchen-welcome strong { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.kitchen-welcome p { max-width: 250px; margin: 6px auto 0; color: var(--text-muted); font-size: 0.78rem; }
.kitchen-message { display: flex; flex-direction: column; max-width: 91%; margin-bottom: 16px; }
.kitchen-message--user { align-items: flex-end; margin-left: auto; }
.kitchen-message--assistant { align-items: flex-start; }
.kitchen-message-label { margin: 0 6px 4px; color: var(--text-muted); font-size: 0.66rem; }
.kitchen-message-bubble { padding: 10px 13px; border: 1px solid var(--border); border-radius: 13px; color: var(--text); font-size: 0.82rem; line-height: 1.65; overflow-wrap: anywhere; }
.kitchen-message--assistant .kitchen-message-bubble { border-top-left-radius: 4px; background: var(--surface-card); }
.kitchen-message--user .kitchen-message-bubble { border-top-right-radius: 4px; border-color: var(--clay); background: var(--primary-ghost); }
.kitchen-message-blank { height: 0.55em; }
.kitchen-message--typing .kitchen-message-bubble { display: flex; align-items: center; gap: 4px; min-height: 38px; }
.kitchen-typing-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: kitchenTyping 1s infinite ease-in-out; }
.kitchen-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.kitchen-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes kitchenTyping { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
.kitchen-composer-area { padding: 12px 16px 15px; border-top: 1px solid var(--border); background: var(--surface); }
.kitchen-quick-prompts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 9px; scrollbar-width: none; }
.kitchen-quick-prompts::-webkit-scrollbar { display: none; }
.kitchen-quick-prompts button { flex-shrink: 0; padding: 5px 9px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-card); color: var(--text-secondary); cursor: pointer; font: 400 0.7rem var(--font-body); white-space: nowrap; }
.kitchen-quick-prompts button:hover { border-color: var(--primary); color: var(--primary-hover); background: var(--primary-ghost); }
.kitchen-composer { display: flex; align-items: flex-end; gap: 8px; }
.kitchen-composer textarea { flex: 1; min-height: 38px; max-height: 110px; padding: 9px 11px; resize: none; border: 1px solid var(--border-strong); border-radius: 10px; outline: none; background: var(--surface-card); color: var(--text); font: 400 0.82rem/1.45 var(--font-body); }
.kitchen-composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ghost); }
.kitchen-composer .btn { min-height: 38px; padding: 0 14px; }
.kitchen-composer-hint { margin-top: 5px; color: var(--text-muted); font-size: 0.65rem; text-align: right; }
.kitchen-assistant.is-busy .kitchen-quick-prompts button { pointer-events: none; opacity: 0.55; }

/* ===== Inventory Item Entrance ===== */
.inv-item {
  animation: slideUp 0.3s var(--ease-out) backwards;
}
.inv-item:nth-child(1) { animation-delay: 0.00s; }
.inv-item:nth-child(2) { animation-delay: 0.04s; }
.inv-item:nth-child(3) { animation-delay: 0.08s; }
.inv-item:nth-child(4) { animation-delay: 0.12s; }
.inv-item:nth-child(5) { animation-delay: 0.16s; }
.inv-item:nth-child(n+6) { animation-delay: 0.20s; }

/* ===== Toast Notifications ===== */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-body);
  font-weight: 500;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-bounce);
  cursor: default;
  max-width: 420px;
  background: var(--surface);
  color: var(--text);
  border-left: 4px solid var(--stone-dark);
}
.toast.removing { animation: toastOut 0.25s var(--ease-in) forwards; }
.toast--success { border-left-color: #3cb878; }
.toast--error   { border-left-color: var(--chili); }
.toast--info    { border-left-color: var(--clay); }

/* ===== Status Bar Breathe ===== */
.status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.status-bar .icon svg {
  stroke: var(--text-muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  background: var(--herb);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(91,139,103,0.4);
  animation: dotBreathe 2s ease-in-out infinite;
}
@keyframes dotBreathe {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.2); }
}

/* ===== Utility Classes (replacing inline styles) ===== */
.flex-row     { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.text-sm    { font-size: 0.85rem; }
.text-xs    { font-size: 0.78rem; }
.text-muted { color: var(--text-muted); }
.font-display { font-family: var(--font-display); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.min-w-50 { min-width: 50px; }
.flex-1   { flex: 1; }
.ml-auto  { margin-left: auto; }

/* ===== AI Panel Component ===== */
.ai-panel {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stone);
  margin-bottom: 18px;
}
.ai-panel--gen {
  background: var(--primary-ghost);
}
.ai-panel--modify {
  background: var(--indigo-ghost);
}
.ai-panel__spark {
  font-size: 1.2rem;
  color: var(--clay);
}
.ai-panel__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.ai-panel__input {
  flex: 1;
  padding: 8px 12px;
}
.ai-panel__status {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 50px;
}

/* ===== Modal HR ===== */
.modal-hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ===== Cook Done Modal Close ===== */
.done-close-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.2rem;
}

/* ===== Responsive — Tablet & Mobile ===== */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .header-inner { padding: 12px 16px; }
  .brand-text h1 { font-size: 1.15rem; }
  .brand-text .subtitle { font-size: 0.7rem; }
  .content { padding: 20px 12px 40px; }
  .tab { padding: 12px 16px; font-size: 0.82rem; }
  .tab-bar-inner { padding: 0 12px; }
  .toolbar { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .search-input { font-size: 0.85rem; }
  .recipe-grid { grid-template-columns: 1fr; }
  .recipe-card { padding: 18px; }
  .inventory-layout { grid-template-columns: 1fr; gap: 20px; }
  .input-row { flex-direction: column; }
  .generate-box { padding: 32px 20px; }
  .generate-hero h2 { font-size: 1.25rem; }
  .form-row { flex-direction: column; gap: 0; }
  .modal { width: 96%; max-height: 90dvh; border-radius: var(--radius-lg); }
  .modal-header { padding: 18px; }
  .modal-body { padding: 18px; }
  .modal-header h2 { font-size: 1.1rem; }
  .menu-recipe-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .shopping-item-name { font-size: 0.82rem; }
  .shopping-item-detail { font-size: 0.7rem; }
  .shopping-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .login-card { padding: 28px 20px; }
  .ai-panel { flex-wrap: wrap; }
  .ai-panel__input { min-width: 100%; flex-basis: 100%; }
  .card-menu-badge { font-size: 0.62rem; padding: 2px 8px; top: 8px; right: 8px; }
  .history-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-charts { grid-template-columns: 1fr; }
  /* Touch-friendly tap targets */
  .btn, .btn-sm { min-height: 40px; }
  .tab { min-height: 44px; }
  .row-remove { font-size: 1.5rem; padding: 4px 8px; }
}

/* ===== Responsive — Small Phone ===== */
@media (max-width: 480px) {
  html { font-size: 14px; }
  .header-inner { padding: 8px 10px; gap: 4px; }
  .brand-text h1 { font-size: 1rem; }
  .brand-en { display: none; }
  .brand-mark { display: none; }
  #headerUsername { display: none; }
  #btnLogout { font-size: 0.7rem; padding: 4px 8px; }
  .app-header .btn-icon { padding: 5px 8px; }
  .tab { flex: 1; justify-content: center; padding: 10px 5px; font-size: 0.74rem; gap: 3px; white-space: nowrap; }
  .tab-icon { display: none; }
  .tab-bar-inner { padding: 0 6px; gap: 0; }
  .content { padding: 12px 6px 32px; }
  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0 4px;
  }
  .page-heading h2 { font-size: 1.3rem; }
  .page-actions {
    justify-content: flex-start;
    flex-shrink: 1;
  }
  .page-controls { margin-bottom: 12px; }
  .recipe-controls .search-wrapper { max-width: none; }
  .recipe-card { padding: 12px; border-radius: var(--radius); }
  .recipe-card .card-name { font-size: 1rem; }
  .recipe-card .card-meta { font-size: 0.72rem; }
  .recipe-card .card-tags .tag { font-size: 0.65rem; padding: 2px 8px; }
  .modal-overlay { align-items: flex-start; padding-top: 10px; }
  .modal { width: 100%; max-height: calc(100dvh - 10px); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-header { padding: 12px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-body { padding: 12px; }
  .done-item-edit { flex-direction: column; }
  .btn-full { width: 100%; }
  .inventory-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
  .inv-item { padding: 10px 12px; }
  .inv-item .inv-name { font-size: 0.88rem; }
  .shopping-item { padding: 6px 10px; }
  .shopping-item-name { font-size: 0.78rem; }
  .stock-tag { font-size:0.62rem; padding:1px 8px; }
  .shopping-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  .settings-tabs { gap: 2px; flex-wrap: wrap; border-bottom: none; }
  .settings-tab { font-size: 0.75rem; padding: 6px 10px; margin-bottom: 0; }
  .toolbar { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .toolbar .btn { padding: 7px 12px; font-size: 0.78rem; height: 34px; }
  #btnSyncAll { font-size: 0; gap: 0; padding: 7px 10px; }
  #btnSyncAll .icon { margin: 0; }
  .match-card .match-name { font-size: 0.9rem; }
  /* Recipe form on mobile */
  .ingredient-row { flex-wrap: wrap; gap: 4px; }
  .ingredient-row input[type="text"] { min-width: 100px; flex: 1; }
  .ingredient-row input[data-ing-amount] { max-width: 80px !important; flex: none; }
  .step-row textarea { font-size: 0.85rem; }
  .step-num { width: 24px; height: 24px; line-height: 24px; font-size: 0.7rem; }
  .tag-suggestions { gap: 4px; }
  .tag-chip { font-size: 0.65rem; padding: 2px 8px; }
  .form-row { flex-direction: column; gap: 0; }
  .ai-panel { padding: 8px; gap: 4px; }
  .ai-panel__input { font-size: 0.82rem; }
  .modal-header-actions { gap: 4px; }
  .modal-header-actions .btn { padding: 5px 10px; font-size: 0.78rem; height: 32px; }
  .modal-header h2 { font-size: 1rem; }
  .scope-toggle { padding: 1px; }
  .scope-btn { padding: 3px 6px; gap: 3px; font-size: 0.68rem; }
  .match-card { padding: 10px 14px; }
  .match-card .match-badge { font-size: 0.65rem; padding: 2px 8px; }
  .match-card .match-header { gap: 6px; }
  .done-item { padding: 10px; }
  .done-item-name { font-size: 0.88rem; }
  .card-menu-badge { font-size: 0.6rem; padding: 2px 7px; top: 6px; right: 6px; }
  .recipe-card .card-footer { flex-wrap: wrap; gap: 6px; }
  .recipe-card .card-footer .btn { font-size: 0.72rem; padding: 4px 10px; height: 30px; }
  .inventory-left .toolbar { flex-wrap: wrap; }
  .status-bar { padding: 8px 12px; font-size: 0.72rem; }
  .match-in-menu { font-size: 0.72rem; margin-top: 6px; }
  .shopping-section h3 { font-size: 0.95rem; }
  .menu-recipe-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
  .section-head h3 { font-size: 1rem; }
  .search-input { font-size: 0.85rem; padding: 9px 12px 9px 36px; }
  .tag-filter { font-size: 0.72rem; padding: 4px 10px; }
  .btn-cook-done { font-size: 0.7rem; padding: 4px 8px; }
  .done-item-need { font-size: 0.7rem; }
  .done-remove-cb { font-size: 0.72rem; }
  .modal-header-actions .btn-sm { padding: 4px 10px; font-size: 0.75rem; height: 30px; }
  .modal-close { width: 28px; height: 28px; }
  .ai-panel__label { font-size: 0.78rem; }
  .btn-full { font-size: 0.82rem; }
  .form-hint { font-size: 0.68rem; }
  .history-range { align-self: flex-start; }
  .history-metric { padding: 12px; }
  .history-metric strong { font-size: 1.4rem; }
  .history-section { padding: 14px 12px; }
  .history-timeline-item { grid-template-columns: 7px 72px minmax(0, 1fr) 30px; gap: 7px; }
  .history-rank-row { grid-template-columns: 17px minmax(75px, 110px) minmax(40px, 1fr) 34px; gap: 5px; }
  .kitchen-fab {
    right: 12px;
    bottom: max(56px, calc(env(safe-area-inset-bottom) + 46px));
    min-height: 42px;
    padding: 0 13px;
  }
  .kitchen-drawer { width: 100%; border-left: 0; }
  .kitchen-drawer-header { padding: 14px 14px 11px; }
  .kitchen-context-bar { align-items: flex-start; flex-direction: column; gap: 3px; padding: 9px 14px; }
  .kitchen-context-bar span { text-align: left; }
  .kitchen-messages { padding: 14px; }
  .kitchen-composer-area { padding: 10px 10px 12px; }
}

/* ===== Responsive — Extra Small Phone ===== */
@media (max-width: 380px) {
  html { font-size: 13px; }
  .header-inner { padding: 6px 8px; gap: 2px; }
  .brand-text h1 { font-size: 0.9rem; }
  .brand-text .subtitle { display: none; }
  .scope-btn { font-size: 0; gap: 0; padding: 4px 8px; }
  .scope-btn .icon { margin: 0; }
  #btnLogout { font-size: 0; padding: 5px 8px; gap: 0; }
  #btnLogout .icon { margin: 0; }
  .tab { padding: 10px 8px; font-size: 0.74rem; gap: 2px; }
  .content { padding: 10px 4px 28px; }
  .recipe-card { padding: 10px; }
  .recipe-card .card-name { font-size: 0.95rem; }
  .toolbar { gap: 4px; }
  .toolbar .btn { padding: 5px 10px; font-size: 0.74rem; height: 32px; }
  .toolbar .btn .icon-sm { width: 12px; height: 12px; }
  .match-card { padding: 8px 10px; }
  .match-card .match-name { font-size: 0.82rem; }
  .match-card .match-badge { font-size: 0.6rem; padding: 2px 6px; }
  .modal-header { padding: 10px; }
  .modal-body { padding: 10px; }
  .modal-header h2 { font-size: 0.92rem; }
  .modal-header-actions { gap: 3px; }
  .modal-header-actions .btn { padding: 4px 8px; font-size: 0.72rem; height: 28px; }
  .settings-tab { font-size: 0.7rem; padding: 5px 8px; }
  .inventory-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
  .inv-item { padding: 8px 10px; }
  .inv-item .inv-name { font-size: 0.82rem; }
  .inv-item .inv-category { font-size: 0.6rem; padding: 2px 6px; }
  .shopping-item { padding: 5px 8px; }
  .shopping-item-name { font-size: 0.74rem; }
  .stock-tag { font-size:0.6rem; padding:1px 6px; }
  .shopping-item-detail { font-size: 0.65rem; }
  .shopping-list { grid-template-columns: 1fr; gap: 4px; }
  .recipe-card .card-footer .btn { font-size: 0.68rem; padding: 3px 8px; height: 28px; }
  .menu-recipe-list { grid-template-columns: 1fr; gap: 6px; }
  .tag-filter { font-size: 0.68rem; padding: 3px 8px; }
  .tag-filters { gap: 4px; }
  .card-menu-badge { font-size: 0.56rem; padding: 1px 6px; top: 4px; right: 4px; }
  .status-bar { padding: 6px 10px; font-size: 0.68rem; }
  .form-group { margin-bottom: 14px; }
  .form-group label { font-size: 0.72rem; }
  .modal-body input[type="text"],
  .modal-body input[type="password"],
  .modal-body textarea,
  .modal-body select { font-size: 0.82rem; padding: 8px 10px; }
}

/* ===== Tag Suggestions ===== */
.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag-chip {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s var(--ease-out);
}
.tag-chip:hover {
  border-color: var(--clay);
  color: var(--clay);
  background: var(--primary-ghost);
}
.tag-chip.used {
  background: var(--indigo-ghost);
  color: var(--indigo);
  border-color: var(--indigo);
  opacity: 0.5;
  cursor: default;
}

/* ===== Family Members ===== */
#familyMemberList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: border-color 0.15s;
}
.member-item:hover { border-color: var(--border-strong); }
.member-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0;
}
.member-name {
  color: var(--ink);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.05em;
}
.member-tag--me {
  background: var(--clay);
  color: #fff;
}

/* ===== Scope Toggle ===== */
.scope-toggle {
  display: flex;
  background: var(--stone);
  border-radius: 20px;
  padding: 2px;
  transition: opacity 0.15s;
}
.scope-toggle.is-loading { opacity: 0.6; pointer-events: none; }
.scope-toggle.is-loading .scope-btn.active {
  position: relative;
}
.scope-toggle.is-loading .scope-btn.active::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -6px;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: aiSpin 0.7s linear infinite;
}
.scope-btn {
  padding: 4px 12px;
  border: none;
  background: none;
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: 18px;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
}
.scope-btn.active {
  background: var(--surface);
  color: var(--clay);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ===== Settings Sub-Tabs ===== */
.settings-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.settings-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s var(--ease-out);
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  color: var(--clay);
  font-weight: 600;
  border-bottom-color: var(--clay);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: slideUp 0.25s var(--ease-out); }
