/* ================================================================
   KIS – Kitchen Intelligence System
   Theme  : warm editorial / culinary lab
   Fonts  : system font stack only — no external CDN
   Icons  : inline SVG sprite (index.html)
   ================================================================ */


/* ── DESIGN TOKENS ──────────────────────────────────────────────
   Single source of truth. Everything else uses var(--*).
   ─────────────────────────────────────────────────────────────── */

:root {
  /* Brand palette */
  --c-indigo:        #4f46e5;
  --c-indigo-hover:  #4338ca;
  --c-indigo-light:  #eef2ff;
  --c-indigo-dark:   #3730a3;

  --c-green:         #16a34a;
  --c-green-hover:   #15803d;
  --c-green-light:   #ecfdf5;
  --c-green-dark:    #166534;

  --c-orange:        #f97316;
  --c-orange-hover:  #ea580c;
  --c-orange-light:  #fff7ed;
  --c-orange-dark:   #9a3412;

  --c-purple:        #9333ea;
  --c-purple-hover:  #7e22ce;
  --c-purple-light:  #fdf4ff;
  --c-purple-dark:   #6b21a8;

  --c-red:           #ef4444;
  --c-red-hover:     #dc2626;
  --c-red-light:     #fee2e2;
  --c-red-dark:      #991b1b;

  --c-amber:         #f59e0b;
  --c-amber-light:   #fef3c7;
  --c-amber-dark:    #92400e;

  --c-blue:          #3b82f6;
  --c-blue-light:    #e0e7ff;
  --c-blue-dark:     #1e40af;

  /* Semantic aliases */
  --primary:         var(--c-indigo);
  --primary-hover:   var(--c-indigo-hover);
  --primary-light:   var(--c-indigo-light);
  --success:         var(--c-green);
  --success-hover:   var(--c-green-hover);
  --success-light:   var(--c-green-light);
  --danger:          var(--c-red);
  --danger-hover:    var(--c-red-hover);
  --warning:         var(--c-orange);
  --warning-hover:   var(--c-orange-hover);
  --warning-light:   var(--c-orange-light);
  --purple:          var(--c-purple);
  --purple-hover:    var(--c-purple-hover);
  --purple-light:    var(--c-purple-light);
  --info:            var(--c-blue);

  /* Surface / background */
  --bg:              #faf8f5;   /* warm off-white canvas */
  --surface:         #ffffff;
  --surface-2:       #f5f2ee;
  --surface-hover:   #ede9e3;

  /* Text */
  --text:            #1c1917;
  --text-light:      #78716c;
  --text-inverse:    #ffffff;

  /* Borders */
  --border:          #e7e2db;
  --border-strong:   #d4cdc4;
  --border-focus:    var(--c-indigo);

  /* Layout */
  --sidebar-w:       220px;
  --content-max:     1280px;

  /* Radii */
  --r-sm:            0.4rem;
  --r-md:            0.75rem;
  --r-lg:            1rem;
  --r-pill:          999px;

  /* Shadows */
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.07);
  --shadow:          0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.14);
  --shadow-xl:       0 20px 60px rgba(0,0,0,0.22);

  /* Focus ring — consistent across all interactive elements */
  --focus-ring:      0 0 0 3px rgba(79,70,229,0.25);

  /* Transitions */
  --t-fast:          120ms ease;
  --t-base:          180ms ease;
  --t-slow:          280ms ease;

  /* Typography */
  --font-body:       system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif:      Georgia, "Times New Roman", serif;
  --font-mono:       "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Font scale */
  --fs-xs:   0.72rem;
  --fs-sm:   0.825rem;
  --fs-base: 0.925rem;
  --fs-md:   1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.35rem;
  --fs-2xl:  1.6rem;
  --fs-3xl:  2rem;
}


/* ── RESET & BASE ────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Improve default link readability */
a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover { color: var(--primary-hover); }

/* Remove list styles only when needed */
ul, ol { list-style: none; }

img, svg { display: block; }

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: 1.25;
  color: var(--text);
}

/* Inline code */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: var(--r-sm);
  color: var(--text);
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}


/* ── SVG ICON SYSTEM ─────────────────────────────────────────── */

.icon {
  display: inline-block;
  width:  1em;
  height: 1em;
  vertical-align: -0.125em; /* optical alignment with surrounding text */
  flex-shrink: 0;
  stroke: currentColor;
  fill:   none;
  pointer-events: none;
}

/* Size modifiers — combine with .icon */
.icon-sm  { width: 0.825em; height: 0.825em; }
.icon-lg  { width: 1.25em;  height: 1.25em;  }
.icon-xl  { width: 1.5em;   height: 1.5em;   }
.icon-2xl { width: 2em;     height: 2em;     }
.icon-3xl { width: 2.75em;  height: 2.75em;  }

/* Colour helpers for icon accents */
.method-icon-indigo-text { color: var(--c-indigo); }
.method-icon-green-text  { color: var(--c-green);  }
.method-icon-orange-text { color: var(--c-orange); }
.method-icon-purple-text { color: var(--c-purple); }

/* Loading spinner */
.spin { animation: spin 0.9s linear infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ── APP SHELL ───────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}


/* ── SIDEBAR ─────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 20;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1.25rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo .icon {
  color: var(--primary);
  font-size: 1.4rem;
}

.sidebar-logo span {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Navigation buttons */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
  width: 100%;
  line-height: 1.3;
}

.nav-item .icon { font-size: 1.05rem; flex-shrink: 0; }

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tagline {
  font-size: var(--fs-xs);
  color: var(--text-light);
  font-style: italic;
  line-height: 1.45;
}


/* ── MAIN CONTENT ────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 2rem 2.25rem;
  max-width: calc(100vw - var(--sidebar-w));
}


/* ── TAB PANELS ──────────────────────────────────────────────── */

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading {}

.panel-title {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.panel-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-light);
  margin-top: 0.3rem;
  line-height: 1.5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding-top: 0.25rem; /* optically align with title area */
}


/* ── SEARCH ──────────────────────────────────────────────────── */

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
  width: 260px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.search-input::placeholder { color: var(--border-strong); }


/* ── RECIPE GRID ─────────────────────────────────────────────── */

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}

.recipe-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.recipe-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.recipe-card h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
  line-height: 1.3;
}

.recipe-card .card-meta {
  font-size: var(--fs-xs);
  color: var(--text-light);
  margin-bottom: 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.recipe-card .card-desc {
  font-size: var(--fs-sm);
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.recipe-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}

.card-time {
  font-size: var(--fs-xs);
  color: var(--primary);
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
}


/* ── METHOD SELECTOR ─────────────────────────────────────────── */

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
  max-width: 920px;
}

.method-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
  width: 100%;
}

.method-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.method-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Icon badge */
.method-icon {
  width: 3rem; height: 3rem;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.method-icon-indigo { background: var(--c-indigo-light); color: var(--c-indigo); }
.method-icon-green  { background: var(--c-green-light);  color: var(--c-green);  }
.method-icon-orange { background: var(--c-orange-light); color: var(--c-orange); }
.method-icon-purple { background: var(--c-purple-light); color: var(--c-purple); }

/* Text content */
.method-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.method-title {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  display: block;
}

.method-desc {
  font-size: var(--fs-sm);
  color: var(--text-light);
  line-height: 1.45;
  display: block;
}

.method-arrow {
  color: var(--border-strong);
  flex-shrink: 0;
  transition: color var(--t-fast), transform var(--t-fast);
}

.method-card:hover .method-arrow {
  color: var(--primary);
  transform: translateX(2px);
}


/* ── WIZARD PANELS ───────────────────────────────────────────── */

.wizard-panel { max-width: 680px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0;
  margin-bottom: 1.5rem;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
  line-height: 1.3;
}

.back-btn:hover         { color: var(--text); }
.back-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.wizard-title {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Step indicators ── */
.steps-row {
  display: flex;
  align-items: center;
  margin-bottom: 2.5rem;
  padding: 0;
  list-style: none;
}

.step-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  list-style: none;
}

.step-dot span {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  transition: background var(--t-base), color var(--t-base);
}

.step-label {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  color: var(--text-light);
  white-space: nowrap;
  font-weight: 500;
}

.step-dot.active span    { background: var(--primary); color: var(--text-inverse); }
.step-dot.active .step-label { color: var(--primary); font-weight: 600; }
.step-dot.done span      { background: var(--success); color: var(--text-inverse); }
.step-dot.done .step-label   { color: var(--success); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-bottom: 1.5rem;
  transition: background var(--t-slow);
  list-style: none;
}

.step-line.done { background: var(--success); }

.wizard-step { border: none; padding: 0; }
.wizard-body { margin-bottom: 2rem; }

.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.generate-ready {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-strong);
}

.ready-icon {
  color: var(--primary);
  margin-bottom: 1rem;
}

.generate-ready > p {
  font-size: var(--fs-md);
  margin-bottom: 0.4rem;
  line-height: 1.5;
}


/* ── CHIP ROW (dietary) ──────────────────────────────────────── */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chip {
  padding: 0.3rem 0.875rem;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border);
  background: none;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  cursor: pointer;
  color: var(--text-light);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  line-height: 1.4;
}

.chip:hover         { border-color: var(--primary); color: var(--primary); }
.chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip.selected      {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}


/* ── IMPORT WIZARD ───────────────────────────────────────────── */

.import-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 0.25rem;
}

.import-tab {
  padding: 0.5rem 1.25rem;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background var(--t-fast), color var(--t-fast);
  line-height: 1.3;
}

.import-tab:hover         { background: var(--surface-2); color: var(--text); }
.import-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.import-tab.active        { background: var(--primary); color: var(--text-inverse); }

.import-pane {}

.url-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.url-input-row .form-control { flex: 1; }

.help-text {
  font-size: var(--fs-xs);
  color: var(--text-light);
  margin-top: 0.45rem;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  line-height: 1.5;
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--text-light);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* Notice / alert banners */
.notice {
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.55;
}

.notice-warning {
  background: var(--c-amber-light);
  border: 1px solid #fde68a;
  color: var(--c-amber-dark);
}

.notice-info {
  background: var(--c-blue-light);
  border: 1px solid #bfdbfe;
  color: var(--c-blue-dark);
}

.notice-success {
  background: var(--c-green-light);
  border: 1px solid #bbf7d0;
  color: var(--c-green-dark);
}

.notice-danger {
  background: var(--c-red-light);
  border: 1px solid #fecaca;
  color: var(--c-red-dark);
}

.import-progress {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

.import-progress p {
  margin-top: 1rem;
  font-size: var(--fs-base);
}


/* ── FINDER ──────────────────────────────────────────────────── */

.finder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 820px;
}


/* ── PANTRY ──────────────────────────────────────────────────── */

.pantry-layout { max-width: 540px; }


/* ── TAG INPUTS ──────────────────────────────────────────────── */

.tag-input-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.tag-input-row .form-control { flex: 1; }

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
  min-height: 1.75rem;
}

.tag-pill {
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  background: var(--primary-light);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  line-height: 1.4;
}

.tag-pill button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  opacity: 0.6;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: opacity var(--t-fast);
}

.tag-pill button:hover         { opacity: 1; }
.tag-pill button:focus-visible { outline: 2px solid var(--primary); border-radius: 2px; }


/* ── SCIENCE LAB ─────────────────────────────────────────────── */

.lab-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2rem;
}

.lab-tab {
  padding: 0.6rem 1.25rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: -2px;
  transition: color var(--t-base), border-color var(--t-base);
  line-height: 1.3;
}

.lab-tab:hover          { color: var(--text); }
.lab-tab:focus-visible  { outline: 2px solid var(--primary); outline-offset: -2px; }
.lab-tab.active         { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.lab-pane        { display: none; }
.lab-pane.active { display: block; }

.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

.lab-inputs {} /* intentional no-op; scoped via .lab-grid */

.result-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 320px;
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 72vh;
}

.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 260px;
  gap: 1rem;
  color: var(--border-strong);
  text-align: center;
}

.result-empty p {
  font-size: var(--fs-sm);
  color: var(--text-light);
}


/* ── FORMS ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 1.15rem; }

label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.label-opt {
  font-weight: 400;
  color: var(--text-light);
  font-style: italic;
}

abbr[title] { text-decoration: underline dotted; cursor: help; }

.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.form-control::placeholder { color: var(--border-strong); }

.form-control:disabled {
  background: var(--surface-2);
  color: var(--text-light);
  cursor: not-allowed;
}

textarea.form-control {
  line-height: 1.6;
  resize: vertical;
  min-height: 4rem;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.code-input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}


/* ── BUTTONS ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.25;
  transition:
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast),
    box-shadow var(--t-fast),
    transform var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Variants */
.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: var(--text-inverse);
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  border-color: var(--success-hover);
}

.btn-warning {
  background: var(--warning);
  color: var(--text-inverse);
  border-color: var(--warning);
}
.btn-warning:hover:not(:disabled) {
  background: var(--warning-hover);
  border-color: var(--warning-hover);
}

.btn-purple {
  background: var(--purple);
  color: var(--text-inverse);
  border-color: var(--purple);
}
.btn-purple:hover:not(:disabled) {
  background: var(--purple-hover);
  border-color: var(--purple-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-ghost {
  background: none;
  color: var(--text-light);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Size modifiers */
.btn-sm       { padding: 0.3rem 0.75rem;  font-size: var(--fs-xs); }
.btn-lg       { padding: 0.7rem 1.75rem;  font-size: 0.975rem; }
.btn-icon     { padding: 0.5rem;           aspect-ratio: 1; border-radius: var(--r-sm); }
.btn-icon-sm  { padding: 0.35rem 0.5rem;  font-size: var(--fs-sm); }
.w-full       { width: 100%; }


/* ── TOAST NOTIFICATIONS ─────────────────────────────────────── */

#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 500;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.1rem;
  border-radius: var(--r-sm);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
  max-width: 360px;
  pointer-events: auto;
  line-height: 1.4;
}

.toast-info    { background: var(--info);    }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger);  }
.toast-warning { background: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}


/* ── MODAL ───────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 1rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none !important; }

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 840px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--r-lg);
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

.modal-close {
  position: absolute;
  top: 1.15rem;
  right: 1.15rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2rem; height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.85rem;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  z-index: 1;
}

.modal-close:hover {
  background: var(--c-red-light);
  color: var(--danger);
  border-color: #fca5a5;
}

.modal-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}


/* ── INTERACTIVE RECIPE LISTS ────────────────────────────────── */

.interactive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.interactive-list li {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg);
  transition: border-color var(--t-fast);
  line-height: 1.5;
}

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

.interactive-list .content { flex: 1; }
.interactive-list .actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Inline simulation result inside a step */
.sim-result-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--c-amber-light);
  border: 1px solid #fde68a;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--c-amber-dark);
}


/* ── TAG BADGES ──────────────────────────────────────────────── */

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.tag-blue   { background: var(--c-blue-light);   color: var(--c-blue-dark);   }
.tag-green  { background: var(--c-green-light);  color: var(--c-green-dark);  }
.tag-amber  { background: var(--c-amber-light);  color: var(--c-amber-dark);  }
.tag-red    { background: var(--c-red-light);    color: var(--c-red-dark);    }
.tag-purple { background: var(--c-purple-light); color: var(--c-purple-dark); }


/* ── SUBSTITUTION MENU ───────────────────────────────────────── */

.substitution-menu {
  position: absolute;
  background: var(--surface);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 300;
  min-width: 200px;
  animation: menuReveal 0.15s ease-out;
}

.substitution-menu ul {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
}

.substitution-menu li {
  margin: 0;
}

.substitution-menu button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  line-height: 1.4;
}

.substitution-menu button:hover         { background: var(--primary-light); color: var(--primary); }
.substitution-menu button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

@keyframes menuReveal {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}


/* ── SIM SUMMARY BAR ─────────────────────────────────────────── */

.sim-summary-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--c-amber-light);
  border: 1px solid #fde68a;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--c-amber-dark);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  line-height: 1.45;
}


/* ── RESULT BOX (shared inline) ──────────────────────────────── */

.result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1rem 1.15rem;
  font-size: var(--fs-sm);
  line-height: 1.65;
}


/* ── LOOKUP / REVERSE RECIPE CARDS ──────────────────────────── */

.lookup-card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 0.75rem;
  display: flex;
  gap: 0.75rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.lookup-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.lookup-card h4 {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--text);
  line-height: 1.3;
}

.lookup-card p {
  font-size: var(--fs-sm);
  color: var(--text-light);
  margin: 0;
  line-height: 1.5;
}


/* ── UTILITIES ───────────────────────────────────────────────── */

.hidden         { display: none !important; }
.text-muted     { color: var(--text-light); }
.text-primary   { color: var(--primary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }
.text-sm        { font-size: var(--fs-sm); }
.text-xs        { font-size: var(--fs-xs); }


/* ── RESPONSIVE ──────────────────────────────────────────────── */

@media (max-width: 980px) {
  .lab-grid      { grid-template-columns: 1fr; }
  .finder-grid   { grid-template-columns: 1fr; }
  .finder-right  { border-top: 1px solid var(--border); padding-top: 1.25rem; }
  .result-pane   { max-height: 50vh; }
}

@media (max-width: 768px) {
  :root {
    --sidebar-w: 58px;
  }

  .sidebar-logo span,
  .nav-item span,
  .sidebar-tagline {
    display: none;
  }

  .sidebar-logo { justify-content: center; padding: 1.25rem 0; }
  .nav-item     { justify-content: center; padding: 0.75rem; }

  .main-content  { padding: 1.25rem; }
  .form-row      { grid-template-columns: 1fr; }
  .method-grid   { grid-template-columns: 1fr; }
  .search-input  { width: 200px; }
  .panel-title   { font-size: var(--fs-2xl); }
}

@media (max-width: 480px) {
  .main-content { padding: 1rem; }
  .search-input { width: 160px; }

  .panel-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .wizard-title { font-size: var(--fs-xl); }

  .modal-content {
    padding: 1.25rem;
    border-radius: var(--r-md);
  }
}


/* ── PRINT ───────────────────────────────────────────────────── */

@media print {
  .sidebar,
  #toastContainer,
  .modal-overlay,
  .btn,
  .nav-item { display: none !important; }

  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 0;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  h1, h2, h3 { page-break-after: avoid; }

  .recipe-card,
  .interactive-list li { break-inside: avoid; }
}
