/* ========================================
   DESIGN TOKENS (Stitch-derived)
   ======================================== */
:root {
  --primary: #a47e56;
  --primary-hover: #8d6b48;
  --secondary: #718355;
  --secondary-hover: #5f7046;
  --accent: #e6ccb2;
  --bg: #fdfaf7;
  --card: #ffffff;
  --border: #d6d3d1;
  /* Higher contrast stone grey */
  --border-focus: #a47e56;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-light: #a8a29e;
  --input-bg: #f5f5f4;
  --error: #dc2626;
  --error-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;

  --radius: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --transition: all 0.2s ease;
  --font-display: 'Playfair Display', serif;
  --font-sans: 'Outfit', sans-serif;
}

/* Dark Mode */
[data-theme="dark"] {
  --bg: #1a1614;
  --card: #25201d;
  --border: #44403c;
  /* Dark mode: lighter border for visibility */
  --text: #f5f5f4;
  --text-muted: #a8a29e;
  --text-light: #78716c;
  --input-bg: #1c1917;
  --error: #ef4444;
  --accent: #e6ccb2;
}

/* ========================================
   RESET & BASE
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   HEADER (Sticky Glassmorphism)
   ======================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(253, 250, 247, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

[data-theme="dark"] .app-header {
  background: rgba(26, 22, 20, 0.85);
}

.header-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1rem;
}

.btn-icon:hover {
  background: var(--input-bg);
  color: var(--text);
}

.btn-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-pill:hover {
  background: var(--border);
}

.btn-pill-sm {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-pill-sm:hover {
  background: var(--input-bg);
  border-color: var(--primary);
  color: var(--primary);
}

/* ========================================
   MAIN LAYOUT
   ======================================== */
.app-main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 32px 24px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  .main-grid {
    grid-template-columns: 2fr 1fr;
    gap: 32px;
  }
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .right-col {
    position: sticky;
    top: 90px;
    align-self: start;
  }
}

/* ========================================
   PLUS & LICENSE STYLES
   ======================================== */
.plus-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.3);
  margin-left: 8px;
}

.plus-badge[data-status="classic"] {
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: none;
  cursor: pointer;
}

.plus-badge[data-status="classic"]:hover {
  border-color: #fbbf24;
  color: #fbbf24;
}

.plus-icon-locked {
  font-size: 1rem;
  color: #f59e0b;
  margin-right: 4px;
  vertical-align: middle;
}

/* Modal Backdrop */
.license-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.license-backdrop.visible {
  display: block;
  opacity: 1;
}

/* Modal Content */
.license-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 95%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 24px;
  z-index: 1001;
  box-shadow: var(--shadow-lg);
  display: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border);
}

.license-modal.visible {
  display: block;
  transform: translate(-50%, -50%) scale(1);
}

.license-modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.license-modal-icon {
  font-size: 2.5rem;
  color: #fbbf24;
  margin-bottom: 8px;
}

.license-modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 4px;
}

.license-modal-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.license-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(164, 126, 86, 0.1);
}

.license-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.license-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.license-error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  text-align: center;
  display: none;
}

.license-error.visible {
  display: block;
}

/* Lock Overlay for Content */
.locked-feature-overlay {
  position: relative;
  overflow: hidden;
}

.locked-feature-overlay::after {
  content: '⭐ PLUS';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.4);
  /* Much more transparent */
  backdrop-filter: blur(1px);
  /* Reduced blur for better visibility */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  color: #d97706;
  /* Darker orange for better contrast on glass */
  font-weight: 800;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s ease;
  pointer-events: auto;
}

[data-theme="dark"] .locked-feature-overlay::after {
  background: rgba(37, 32, 29, 0.4);
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.locked-feature-overlay:hover::after {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .locked-feature-overlay:hover::after {
  background: rgba(37, 32, 29, 0.2);
}

/* Style for gated options in select */
select option[disabled] {
  color: var(--text-light);
  font-style: italic;
}

/* ========================================
   CARDS
   ======================================== */
.card {
  background: var(--card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.card-header .material-symbols-rounded {
  color: var(--primary);
  font-size: 1.3rem;
}

.card-header.secondary .material-symbols-rounded {
  color: var(--secondary);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ========================================
   COLLAPSIBLE SECTIONS
   ======================================== */
.collapsible {
  background: var(--card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

.collapsible-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  text-align: left;
}

.collapsible-trigger:hover {
  background: var(--input-bg);
}

.collapsible-trigger-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapsible-trigger .material-symbols-rounded.icon-section {
  color: var(--secondary);
  font-size: 1.2rem;
}

.collapsible-trigger .trigger-label {
  font-weight: 500;
  font-size: 0.95rem;
}

.collapsible-trigger .arrow {
  color: var(--text-light);
  transition: transform 0.3s ease;
  font-size: 1.2rem;
}

.collapsible.open .collapsible-trigger .arrow {
  transform: rotate(180deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.collapsible.open .collapsible-body {
  max-height: 3000px;
}

.collapsible-content {
  padding: 0 20px 20px;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-select,
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  /* Slightly thicker border */
  border-radius: var(--radius);
  background: var(--card);
  /* Brighter background for inputs */
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition);
  appearance: auto;
}

.form-select:hover,
.form-input:hover {
  border-color: var(--text-light);
  background: var(--input-bg);
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(164, 126, 86, 0.1);
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 36px;
}

.input-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 500;
  pointer-events: none;
}

/* ========================================
   ITEM ROWS (Mehl, Sauerteig, Extras)
   ======================================== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.item-inputs {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 480px) {
  .item-inputs {
    grid-template-columns: 2fr 1fr;
  }
}

.btn-remove {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-top: 4px;
}

.btn-remove:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

/* Edit Status Display */
.editing-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(230, 144, 25, 0.1);
  border: 1px solid rgba(230, 144, 25, 0.2);
  border-radius: var(--radius);
  margin-bottom: 12px;
  width: 100%;
}

.editing-status .material-symbols-rounded {
  color: var(--primary);
  font-size: 1.2rem;
}

#currentRecipeName {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  line-height: 1.4;
}

.btn-add {
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  margin-top: 8px;
}

.btn-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-primary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(113, 131, 85, 0.25);
}

.btn-primary:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(113, 131, 85, 0.35);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--input-bg);
}

.btn-danger-text {
  background: transparent;
  color: var(--text-muted);
  padding: 10px;
}

.btn-danger-text:hover {
  color: var(--error);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ========================================
   RESULT CARD
   ======================================== */
.result-card {
  background: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: 0 10px 25px rgba(164, 126, 86, 0.25);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  /* Precision transitions instead of 'all' */
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.5s ease;
}

.result-card::before {
  content: 'water_drop';
  font-family: 'Material Symbols Rounded';
  position: absolute;
  right: -5%;
  bottom: -5%;
  font-size: 160px;
  opacity: 0.1;
  font-variation-settings: 'FILL' 1;
  pointer-events: none;
  transition: transform 0.6s ease;
}

.result-card:hover::before {
  transform: scale(1.1) rotate(-5deg);
}

.result-card .result-data {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.result-label {
  font-weight: 600;
  opacity: 0.9;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.result-label-sm {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
}

.result-value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  will-change: transform, opacity;
  display: inline-block;
  /* GPU layer isolation */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.result-value-sm {
  font-size: 1.05rem;
  font-weight: 700;
  opacity: 0.9;
}

.result-divider {
  height: 2px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1px;
}

@keyframes popIn {
  0% {
    transform: scale(0.97);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   INFO BOX
   ======================================== */
.info-box {
  padding: 16px;
  background: rgba(230, 204, 178, 0.2);
  border: 1px solid rgba(230, 204, 178, 0.3);
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
}

[data-theme="dark"] .info-box {
  background: rgba(230, 204, 178, 0.05);
  border-color: rgba(230, 204, 178, 0.1);
}

.info-box .material-symbols-rounded {
  color: var(--primary);
  flex-shrink: 0;
  font-size: 1.2rem;
}

.info-box p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ========================================
   HYDRATION INPUTS GRID
   ======================================== */
.hydration-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 480px) {
  .hydration-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.empf-hyd-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--warning), #f59e0b);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  min-height: 44px;
}

.empf-hyd-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(217, 119, 6, 0.4);
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.5);
  }

  50% {
    box-shadow: 0 0 12px 4px rgba(217, 119, 6, 0.3);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
  }
}

.empf-hyd-btn.pulse-glow {
  animation: pulseGlow 1s ease-out;
}

/* ========================================
   INLINE SECTION (Salt + Scaling)
   ======================================== */
.inline-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.inline-input {
  width: 110px;
}

.salt-result {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 70px;
  justify-content: center;
  transition: var(--transition);
}

/* ========================================
   CUSTOM INGREDIENTS
   ======================================== */
.custom-add-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px dashed var(--border);
}

.form-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
}

.custom-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 480px) {
  .custom-form-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .custom-form-grid-2col {
    grid-template-columns: 2fr 1fr;
  }
}

.custom-form-grid-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.custom-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 10px;
}

.custom-item-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-item-name {
  font-weight: 600;
}

.custom-item-values {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.custom-item-delete {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.custom-item-delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

/* ========================================
   TOOLTIP
   ======================================== */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip-btn {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border: none;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tooltip-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  width: max-content;
  max-width: 220px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  pointer-events: none;
}

.tooltip-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--card);
}

.tooltip-wrap:hover .tooltip-popup,
.tooltip-wrap:focus-within .tooltip-popup {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* ========================================
   RECIPES SECTION
   ======================================== */
.recipes-section {
  display: none;
}

.recipes-section.visible {
  display: block;
}

.recipe-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.recipe-controls select {
  flex: 1;
}

.recipe-notes {
  display: block;
  margin-top: 12px;
}

.recipe-notes-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.recipe-notes-row textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 50px;
  max-height: 120px;
  background: var(--input-bg);
  color: var(--text);
  transition: var(--transition);
}

.recipe-notes-row textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.mic-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.mic-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mic-btn.recording {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
  animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
  }
}

.mic-hint {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
}

/* ========================================
   WARNING OVERLAY (Flohsamen)
   ======================================== */
.warning-overlay {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
  display: none;
  font-size: 0.85rem;
  color: var(--text);
}

.warning-overlay.visible {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========================================
   PANIK MODAL
   ======================================== */
.panik-link {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.panik-link:hover {
  background: rgba(255, 255, 255, 0.1);
  border-style: solid;
  color: #fff;
}

.panik-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  backdrop-filter: blur(4px);
}

.panik-backdrop.visible {
  display: block;
}

.panik-modal {
  display: none;
  position: fixed;
  z-index: 999;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 24px;
  overflow-y: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: var(--radius-xl);
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  box-shadow: var(--shadow-lg);
}

.panik-modal.visible {
  display: block;
}

@media (max-width: 479px) {
  .panik-modal {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slideUp 0.3s ease-out;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
    }

    to {
      transform: translateY(0);
    }
  }
}

.panik-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panik-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panik-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  font-size: 1.3rem;
  transition: var(--transition);
}

.panik-close:hover {
  color: var(--error);
}

.panik-input-row {
  margin-bottom: 16px;
}

.panik-input-row label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.panik-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panik-input-group input {
  flex: 1;
}

.panik-input-group span {
  font-weight: 600;
  color: var(--text-muted);
}

.btn-panik {
  width: 100%;
  padding: 12px;
  background: var(--error);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}

.btn-panik:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.panik-result {
  display: none;
  padding: 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
}

.panik-result.visible {
  display: block;
}

.panik-result.panik-danger {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid var(--error);
}

.panik-result.panik-ok {
  background: rgba(22, 163, 74, 0.08);
  border: 1px solid var(--success);
  color: var(--success);
}

.panik-result strong {
  display: block;
  margin-bottom: 4px;
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
  max-width: 1024px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

.app-footer p {
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 500;
}

.app-footer .brand-link {
  color: var(--primary);
  font-weight: 600;
}

.footer-links {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 24px;
}

.footer-links a {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary);
}

/* ========================================
   SPINNER
   ======================================== */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   UTILITIES
   ======================================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-sm {
  margin-top: 8px;
}

.mt-md {
  margin-top: 16px;
}

.gap-sm {
  gap: 8px;
}

/* Material Symbols config */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  font-size: 1.2rem;
}



/* ========================================
   WIZARD & STEPS
   ======================================== */
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 700;
  margin-right: 12px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

#step2.card {
  border: 1px solid var(--border);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#step2.highlight-error {
  border-color: #fbbf24 !important;
  /* Golden/Amber border */
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2);
  animation: pulse-error-gold 1.5s ease-in-out infinite;
}

@keyframes pulse-error-gold {
  0% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(251, 191, 36, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
  }
}


/* ========================================
   COLLAPSIBLE SECTIONS
   ======================================== */
.collapsible {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0px;
  /* Gap handled by flex */
}

.collapsible-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-sans);
  transition: var(--transition);
}

.collapsible-trigger:hover {
  background: var(--input-bg);
}

.collapsible-trigger-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trigger-label {
  font-weight: 600;
  font-size: 1rem;
}

.collapsible .arrow {
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.collapsible.open .arrow {
  transform: rotate(180deg);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.collapsible.open .collapsible-body {
  max-height: 1000px;
  /* High enough for content */
}

.collapsible-content {
  padding: 0 20px 20px 20px;
}

/* ========================================
   MOBILE ADJUSTMENTS
   ======================================== */
@media (max-width: 767px) {
  .header-inner {
    padding: 10px 12px;
    gap: 8px;
  }

  .header-brand {
    gap: 8px;
  }

  .header-logo {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .header-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    /* Safety for very small screens */
  }

  .header-subtitle {
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }

  .header-actions {
    gap: 4px;
    flex-shrink: 0;
    /* Header actions should never shrink or wrap */
  }

  .plus-badge {
    padding: 6px;
    /* Symmetric padding for square-ish look */
    margin-left: 0;
    min-width: 32px;
    justify-content: center;
  }

  .plus-badge span:not(.material-symbols-rounded),
  .btn-pill span:not(.material-symbols-rounded) {
    display: none !important;
  }

  .app-main {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .result-card {
    padding: 20px 16px;
  }

  .result-value {
    font-size: 1.8rem;
  }

  .btn-pill span:not(.material-symbols-rounded) {
    display: none;
  }
}

/* Specific optimization for very small screens (iPhone SE, 320px) */
@media (max-width: 350px) {
  .header-inner {
    padding: 8px 10px;
    gap: 4px;
  }

  .header-brand {
    gap: 6px;
  }

  .header-logo {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .header-title {
    font-size: 0.95rem;
  }
}