/* Nutrition Planner */

/* Bridge app-specific var names to shared design tokens */
:root {
  --bg-elev: var(--surface);
  --bg-elev-2: var(--surface);
  --text-strong: var(--text);
  --accent-strong: var(--accentEmph);
  --good: var(--success);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.16);
  --danger-soft-text: var(--color-danger-fg);
  --danger-soft-bg: rgba(248, 81, 73, 0.15);
  --danger-soft-bg-strong: rgba(248, 81, 73, 0.18);
  --danger-soft-bg-hover: rgba(248, 81, 73, 0.28);
  --danger-soft-border: rgba(248, 81, 73, 0.55);
  --warn-soft-text: var(--color-attention-fg);
  --warn-soft-bg: rgba(210, 153, 34, 0.12);
  --warn-soft-border: rgba(210, 153, 34, 0.55);
}

:root[data-theme="light"] {
  --danger-soft-text: var(--color-danger-fg);
  --danger-soft-bg: rgba(209, 36, 47, 0.11);
  --danger-soft-bg-strong: rgba(209, 36, 47, 0.15);
  --danger-soft-bg-hover: rgba(209, 36, 47, 0.2);
  --danger-soft-border: rgba(209, 36, 47, 0.42);
  --warn-soft-text: var(--color-attention-fg);
  --warn-soft-bg: rgba(154, 103, 0, 0.14);
  --warn-soft-border: rgba(154, 103, 0, 0.38);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --danger-soft-text: var(--color-danger-fg);
    --danger-soft-bg: rgba(209, 36, 47, 0.11);
    --danger-soft-bg-strong: rgba(209, 36, 47, 0.15);
    --danger-soft-bg-hover: rgba(209, 36, 47, 0.2);
    --danger-soft-border: rgba(209, 36, 47, 0.42);
    --warn-soft-text: var(--color-attention-fg);
    --warn-soft-bg: rgba(154, 103, 0, 0.14);
    --warn-soft-border: rgba(154, 103, 0, 0.38);
  }
}

html { scroll-behavior: smooth; }

body { background: var(--bg); }

button, input, textarea { font-family: inherit; }

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 6px;
  margin: 0 -16px 12px;
}

.topRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tabMainRow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.tabMainRow .tabs#mixTabs {
  flex: 1 1 auto;
  min-width: 0;
}

.tabRowControls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.segmentedToggleWrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.segmentedToggleLabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.screen.hidden { display: none; }

.pageHeader { margin: 0 0 16px; }

.headerMeta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.lockScreenControl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  white-space: nowrap;
  cursor: pointer;
}

.lockScreenControl input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accentEmph);
}

.plannerStepper {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.plannerStepTop {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.plannerStepPills {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.plannerStepPills.step-pills {
  margin: 0;
}

.plannerStepTop .plannerStepPills {
  flex: 1 1 auto;
  min-width: 0;
}

.plannerStepTop #statusPill {
  margin-left: auto;
  flex: 0 0 auto;
}

/* Step pills — unified with shared .step-pill style from components.css */

.plannerDataStatus { font-size: 12px; color: var(--muted); }

.recipeLockControl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  user-select: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.recipeLockLabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
}

.recipeLockSwitch {
  width: 40px;
  height: 22px;
}

.recipeLockSwitch .switch-slider {
  background: var(--surface2);
}

.recipeLockControl.is-on {
  border-color: rgba(88, 166, 255, 0.55);
  background: rgba(88, 166, 255, 0.14);
  box-shadow:
    0 0 0 1px rgba(88, 166, 255, 0.2),
    0 0 14px rgba(88, 166, 255, 0.24);
}

.recipeLockControl.is-disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.plannerStepFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--borderMuted);
}

.plannerStepFooter .btn {
  min-height: 0;
  min-width: 108px;
  border-radius: var(--radius);
  padding: 8px 14px;
}

.plannerStepFooter .btn.plannerStepNextBtn,
.plannerStepFooter .btn.quickLogStepNextBtn {
  background: var(--successEmph);
  border-color: rgba(240, 246, 252, 0.1);
  color: #fff;
}

.plannerStepFooter .btn.plannerStepNextBtn:hover:not(:disabled),
.plannerStepFooter .btn.quickLogStepNextBtn:hover:not(:disabled) {
  background: #2ea043;
  border-color: rgba(240, 246, 252, 0.1);
}

.plannerStepFooter .btn.plannerStepNextBtn:active:not(:disabled),
.plannerStepFooter .btn.quickLogStepNextBtn:active:not(:disabled) {
  background: #238636;
}

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

.plannerStep { display: none; }
.plannerStep.active { display: block; }
.quickLogStep { display: none; }
.quickLogStep.active { display: block; }
.quickLogStepper { margin-bottom: 12px; }
.quickLogOutputGrid {
  grid-template-columns: minmax(220px, 420px);
}

.sweatCalcPanel {
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  padding: 12px 12px 8px;
  background: var(--surface2);
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.sweatCalcPanel[hidden] { display: none !important; }

#sodiumCalcModal .modalFooterActions {
  margin-top: 6px;
}

#durationCalcModal .modalFooterActions {
  margin-top: 6px;
}

.targetsCalcButtons #sodiumCalcBtn,
.targetsCalcButtons #durationCalcBtn,
.targetsCalcButtons #carbCalcBtn {
  width: 100%;
}

.durationCalcComputed input {
  font-variant-numeric: tabular-nums;
}

#durationCalcModal .segmented,
#durationCalcModal .durationCalcSportToggle {
  width: 100%;
}

.durationCalcModeToggle {
  margin-bottom: 2px;
}

#durationCalcManualSection,
#durationCalcFetchSection {
  display: grid;
  gap: 10px;
}

#durationCalcManualSection[hidden],
#durationCalcFetchSection[hidden] {
  display: none !important;
}

.durationCalcCredentialsRow {
  margin-top: 2px;
}

.durationCalcFetchActions {
  display: grid;
  gap: 8px;
  align-content: end;
}

.durationCalcFetchActions .btn {
  width: auto;
  white-space: nowrap;
  min-height: 44px;
}

#durationFetchNotice {
  min-height: 16px;
}

#durationFetchNotice.error {
  color: var(--danger);
}

.durationFetchTableWrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--bg);
}

.durationFetchTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 520px;
}

.durationFetchTable th,
.durationFetchTable td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--borderMuted);
  text-align: left;
  vertical-align: middle;
}

.durationFetchTable th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--surface2);
}

.durationFetchTable tbody tr {
  cursor: pointer;
}

.durationFetchTable tbody tr:hover {
  background: rgba(88, 166, 255, 0.12);
}

.durationFetchTable tbody tr:focus {
  outline: 2px solid rgba(88, 166, 255, 0.45);
  outline-offset: -2px;
}

.durationFetchTable tbody tr.active {
  background: rgba(88, 166, 255, 0.18);
}

.durationFetchTable tbody tr:last-child td {
  border-bottom: none;
}

.durationFetchTable td.is-empty {
  color: var(--muted);
  cursor: default;
}

.durationCalcSegmentPanel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.durationCalcSegmentPanel[hidden] {
  display: none !important;
}

.durationCalcSegmentHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.durationCalcSegmentHeader strong {
  font-size: 11px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.durationCalcSegmentSlider {
  position: relative;
  height: 28px;
}

.durationCalcSegmentTrack {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.durationCalcSegmentTrackSlice {
  position: absolute;
  top: 0;
  bottom: 0;
}

.durationCalcSegmentRanges {
  position: absolute;
  inset: 0;
}

.durationCalcSegmentThumb {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--accent-strong);
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  cursor: ew-resize;
  touch-action: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.durationCalcSegmentThumb:hover,
.durationCalcSegmentThumb.is-active,
.durationCalcSegmentThumb:focus-visible {
  transform: translate(-50%, -50%) scale(1.07);
  border-color: #fff;
}

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

.durationCalcSegmentLegend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.durationCalcSegmentTableWrap {
  border: 1px solid var(--borderMuted);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.durationCalcSegmentTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.durationCalcSegmentTable th,
.durationCalcSegmentTable td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--borderMuted);
  text-align: left;
  vertical-align: middle;
}

.durationCalcSegmentTable th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: var(--surface2);
}

.durationCalcSegmentTable th:last-child {
  text-align: right;
}

.durationCalcSegmentTable td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.durationCalcSegmentDurationInput {
  width: 78px;
  max-width: 100%;
  margin-left: auto;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.durationCalcSegmentDurationInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}

.durationCalcSegmentTable tr:last-child td {
  border-bottom: none;
}

.targetsCalcStack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.targetsCalcButtons {
  margin-left: auto;
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.targetsSectionHeader .targetsHeaderCalcBtn {
  min-width: 220px;
}

.targetsSection.duration-calc-open .targetsSectionHeader {
  margin-bottom: 0;
}

.targetsSection.duration-calc-open .targetsSectionHeader .targetsHeaderCalcBtn {
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.28);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.targetsSection.duration-calc-open #durationCalcModal.expand-panel.open {
  margin-top: -1px;
  border-top-left-radius: var(--radiusXl);
  border-top-right-radius: 0;
  border-color: rgba(88, 166, 255, 0.28);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.16);
  overflow: hidden;
}

.targetsCalcButtons .btn,
.targetsCalcButtons .expand-btn {
  width: 100%;
}

.expand-panel.open {
  background: var(--surface);
}

.targetsCalcButtons + .expand-panel.open {
  margin-top: -8px;
  border-top-left-radius: var(--radiusXl);
  border-top-right-radius: 0;
  border-color: rgba(88, 166, 255, 0.28);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.16);
}

#carbCalcModal.expand-panel.open,
#sodiumCalcModal.expand-panel.open {
  margin-top: -8px;
  border-top-left-radius: var(--radiusXl);
  border-top-right-radius: 0;
  border-color: rgba(88, 166, 255, 0.28);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.16);
}

#durationCalcModal .durationCalcInputs .sliderValueInput {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

@media (max-width: 700px) {
  .targetsSectionHeader .targetsHeaderCalcBtn {
    width: 100%;
    min-width: 0;
  }

  .targetsCalcButtons {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .targetsCalcButtons + .expand-panel.open {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  #carbCalcModal.expand-panel.open,
  #sodiumCalcModal.expand-panel.open {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  .carbGuideTable {
    width: max-content;
    min-width: 100%;
  }

  .carbGuideTable .guideLabel {
    min-width: 0;
    width: 1%;
  }

  .carbRatioHint {
    display: none;
  }

  .carbGuideMatrixBtn {
    min-width: 34px;
    padding: 1px 5px;
    font-size: 9px;
    letter-spacing: 0.02em;
  }

  .carbGuidePresetTag {
    display: block;
    width: max-content;
    margin: 3px 0 0;
    font-size: 9px;
  }
}

@media (max-width: 900px) {
  .targetsSection.duration-calc-open #durationCalcModal.expand-panel.open {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  #sodiumCalcModal.expand-panel.open {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  #carbCalcModal.expand-panel.open {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
}

#segmentGraphBtn {
  width: 100%;
}

.ingredientQuickToggleBtn {
  width: 100%;
}

.ingredientQuickPanel {
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  background: var(--surface2);
  padding: 10px;
}

.ingredientQuickPanel.expand-panel.open {
  background: var(--surface);
}

.ingredientQuickPanel[hidden] { display: none !important; }

.ingredientQuickItem > .expand-btn[aria-expanded="true"] + .expand-panel,
.ingredientQuickAdd > .expand-btn[aria-expanded="true"] + .expand-panel {
  margin-top: -8px;
}

.sweatGuideGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.sweatGuideCard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 10px 6px;
  width: 100%;
}

.sweatRateGuideTitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.sweatRateTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.sweatRateTable th,
.sweatRateTable td {
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--borderMuted);
  vertical-align: middle;
}

.sweatRateTable th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

.sweatRateTable th.zoneRange {
  text-align: center;
}

.sweatRateTable .guideLabel {
  text-align: left;
}

.sweatRateTable td.guideValue {
  cursor: pointer;
  text-align: center;
}

.guideValueBtn {
  display: inline-flex;
  justify-content: center;
  width: auto;
  min-width: 44px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.guideValueBtn:focus-visible {
  outline: 2px solid rgba(88, 166, 255, 0.55);
  outline-offset: 2px;
  border-radius: 4px;
}

.guideValueBtn.is-selected {
  border-color: rgba(88, 166, 255, 0.55);
  background: rgba(88, 166, 255, 0.2);
  color: var(--text-strong);
  font-weight: 600;
}

.sweatRateTable tr.is-hover-row td,
.sweatRateTable tr.is-hover-row th {
  background: rgba(88, 166, 255, 0.08);
}

.sweatRateTable td.is-hover-col,
.sweatRateTable th.is-hover-col {
  background: rgba(88, 166, 255, 0.12);
}

.sweatRateTable tr.is-hover-row td.is-hover-col,
.sweatRateTable tr.is-hover-row th.is-hover-col {
  background: rgba(88, 166, 255, 0.2);
}

.sweatRateTable tr:last-child td,
.sweatRateTable tr:last-child th {
  border-bottom: none;
}

.carbGuideCard {
  overflow-x: auto;
}

.carbGuideTable {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.carbGuideTable th,
.carbGuideTable td {
  white-space: nowrap;
  padding-left: 3px;
  padding-right: 3px;
}

.carbGuideTable .guideLabel {
  min-width: 0;
  width: 1%;
  white-space: normal;
}

.carbGuideRateCell {
  text-align: left;
}

.carbGuideRateValue {
  color: var(--text-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.carbRatioHead {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.carbRatioValue {
  color: var(--text-strong);
  font-weight: 700;
}

.carbRatioHint {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.carbGuidePresetTag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
}

.carbGuidePresetTag.advanced {
  color: #d29922;
  border-color: rgba(210, 153, 34, 0.5);
  background: rgba(210, 153, 34, 0.14);
}

.carbGuidePresetTag.experimental {
  color: #f0883e;
  border-color: rgba(240, 136, 62, 0.5);
  background: rgba(240, 136, 62, 0.14);
}

.carbGuideMatrixCell {
  text-align: center;
  vertical-align: middle;
}

.carbGuideMatrixBtn {
  min-width: 44px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.carbGuideMatrixBtn[data-cell-status="best"] {
  color: #3fb950;
}

.carbGuideMatrixBtn[data-cell-status="ok"] {
  color: #58a6ff;
}

.carbGuideMatrixBtn[data-cell-status="train"] {
  color: #f0883e;
}

.carbGuideMatrixBtn.is-selected {
  border-color: currentColor;
}

.carbGuideMatrixBtn[data-cell-status="best"].is-selected {
  background: rgba(63, 185, 80, 0.16);
}

.carbGuideMatrixBtn[data-cell-status="ok"].is-selected {
  background: rgba(88, 166, 255, 0.16);
}

.carbGuideMatrixBtn[data-cell-status="train"].is-selected {
  background: rgba(240, 136, 62, 0.16);
}

.carbInfoGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.carbInfoCard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 9px 10px;
}

.carbInfoCard h3 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-strong);
}

.carbInfoCard p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

#carbCalcModal .durationCalcSportToggle {
  width: 100%;
}

.zoneDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.zoneDot.cool { background: #3fb950; }
.zoneDot.mild { background: #58a6ff; }
.zoneDot.warm { background: #d29922; }
.zoneDot.hot { background: #f0883e; }
.zoneDot.veryHot { background: #f85149; }

.zoneRange {
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.zoneAvg {
  font-weight: 700;
}

.zoneAvg.cool { color: #3fb950; }
.zoneAvg.mild { color: #58a6ff; }
.zoneAvg.warm { color: #d29922; }
.zoneAvg.hot { color: #f0883e; }
.zoneAvg.veryHot { color: #f85149; }

.metricCalcLine {
  margin-top: -2px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.title {
  font-size: 20px;
  color: var(--text-strong);
  letter-spacing: 0.2px;
  font-weight: 600;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
}

.pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--btn);
  white-space: nowrap;
}
.pill.ok { color: var(--good); border-color: rgba(63, 185, 80, 0.4); }
.pill.error { color: var(--danger); border-color: rgba(248, 81, 73, 0.5); }
.pill.warn { color: var(--warn); border-color: rgba(210, 153, 34, 0.5); }

.tabRow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
}

body.quickLogActive .tabRow { display: flex; }
body.quickLogActive #mixTabs,
body.quickLogActive .segmentedToggleWrap,
body.quickLogActive #segmentDivider,
body.quickLogActive #segmentTabs {
  display: none !important;
}
body.quickLogActive .tabMainRow {
  justify-content: flex-end;
}
body.quickLogActive .tabRowControls {
  margin-left: auto;
}

.tabDivider { height: 1px; width: 100%; background: var(--border); }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 2px 2px;
  -webkit-overflow-scrolling: touch;
  align-items: center;
}
.tabs::-webkit-scrollbar { display: none; }

.tabItem {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  min-height: 36px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.tabItem:hover {
  color: var(--text);
  border-color: var(--muted2);
}
.tabItem.active {
  border-color: rgba(88,166,255,0.38);
  color: var(--accent);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(88,166,255,0.12);
}
.tabItem.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--accent);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.tabButton {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.tabOptionsBtn {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  min-width: 26px;
  min-height: 26px;
  width: 26px;
  height: 26px;
  opacity: 0.55;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tabItem:hover .tabOptionsBtn { opacity: 0.85; }
.tabOptionsBtn:hover {
  opacity: 1;
  background: rgba(88, 166, 255, 0.16);
}

.tabOptionsDots {
  font-size: 17px;
  line-height: 1;
  display: inline-block;
  transform: translateY(-1px);
  letter-spacing: -0.02em;
}

.tabItem.active .tabButton,
.tabItem.active .tabOptionsBtn { color: inherit; }

.tabMenuOverlay {
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  padding: 6px;
  min-width: 160px;
  display: none;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  z-index: 60;
}
.tabMenuOverlay.open { display: grid; gap: 2px; }
.tabMenuOverlay button {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.tabMenuOverlay button:hover { background: rgba(88, 166, 255, 0.12); }
.tabMenuOverlay button.danger { color: var(--danger-soft-text); }

.tabAdd {
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  min-height: 34px;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.tabAdd:hover { color: var(--accent); border-color: var(--accent); }

.btn {
  min-height: 0;
  line-height: 1.2;
}
.btn.primary:hover {
  border-color: rgba(240, 246, 252, 0.1);
}
.btn:active { animation: button-pop 0.18s ease-out; }

.section {
  background: var(--surface);
  border-radius: var(--radiusLg);
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  animation: fadeUp 0.55s ease both;
  animation-delay: var(--delay, 0s);
}

.sectionHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sectionHeader > h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text-strong);
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
}
.sectionHeader > .sectionHint {
  order: 3;
  flex: 1 1 100%;
}
.sectionHeader > .btn,
.sectionHeader > .expand-btn,
.sectionHeader > .modalHeaderActions {
  order: 2;
  margin-left: auto;
  flex: 0 0 auto;
  align-self: flex-start;
}

.modalHeaderActions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-left: auto;
}

.modalFooterActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.sectionHint { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 12px; }
.inputsGrid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.targetsSection .field label {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
}

.labelWithAction { display: inline-flex; align-items: center; gap: 6px; }

/* Water & Bottles box */
.waterBox {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: grid;
  gap: 10px;
  align-items: start;
}
.waterBoxHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  flex-wrap: wrap;
}
.waterBoxTitle {
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-weight: 500;
}
.waterBoxField {
  border: none;
  padding: 0;
  background: transparent;
  min-width: 0;
}
.waterBoxField label {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.chaseWaterSection,
.bottlesSection {
  display: grid;
  gap: 6px;
}
.waterBoxDivider {
  border-top: none;
  margin: 0;
}
.bottlesHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.bottlesHeader label {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.bottleEmpty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0 2px;
}
#chaseWaterListContainer,
#bottleListContainer,
#quickLogChaseWaterListContainer,
#quickLogBottleListContainer {
  display: grid;
  gap: 6px;
}
#chaseWaterListContainer .bottleCard,
#bottleListContainer .bottleCard,
#quickLogChaseWaterListContainer .bottleCard,
#quickLogBottleListContainer .bottleCard {
  margin-top: 0;
}
.bottleCard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--bg);
  margin-top: 6px;
}
.bottleCardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.bottleLabelRow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bottleLabel {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.bottleLabelEdit {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}
.bottleCardBody {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bottleSliderField { padding: 0; border: none; background: transparent; }
.bottleSliderField .sliderRow { gap: 6px; }
.bottleSliderField .sliderValueInput { width: 72px; min-width: 72px; }
.bottleSliderField .sliderBtn { font-size: 14px; }
.bottleMixToggle {
  align-self: flex-start;
}
.bottleMixToggle button {
  min-width: 64px;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (min-width: 700px) {
  .waterBox {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 14px;
    row-gap: 10px;
  }
  .waterBoxHeader {
    grid-column: 1 / -1;
  }
  .waterBoxDivider {
    display: none;
  }
  .waterBoxField.bottlesSection {
    border-left: none;
    padding-left: 0;
    min-height: 0;
  }
  #bottleListContainer,
  #quickLogBottleListContainer {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .bottleCard {
    padding: 6px 8px;
    margin-top: 5px;
  }
  .bottleCardHeader {
    margin-bottom: 4px;
  }
  .bottleCardBody {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    row-gap: 4px;
    align-items: center;
  }
  .bottleSliderField .sliderValueInput {
    width: 74px;
    min-width: 74px;
    min-height: 34px;
    padding: 6px 8px;
  }
  .bottleSliderField .sliderBtn {
    min-width: 28px;
  }
  .bottleMixToggle button {
    min-width: 60px;
    padding: 8px 10px;
    font-size: 10px;
    letter-spacing: 0.06em;
  }
}

.targetsSection .field {
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  padding: 10px 12px;
  background: var(--surface2);
}

.field input {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  min-height: 0;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.field textarea {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  min-height: 90px;
  resize: vertical;
}
.field select {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  min-height: 0;
  font-size: 13px;
  font-family: inherit;
  appearance: auto;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
}

.field input::placeholder { color: var(--muted2); text-align: center; }
#ingredientSearch, #quickLogSearch { text-align: left; }
#ingredientSearch::placeholder, #quickLogSearch::placeholder { text-align: left; }

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}

.field input.is-error {
  border-color: rgba(248, 81, 73, 0.8);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.2);
}
.field.is-disabled label { color: rgba(139, 148, 158, 0.7); }
.field input:disabled {
  color: var(--muted);
  background: var(--surface2);
  border-color: var(--borderMuted);
}

/* Sliders */
.sliderField input[type="range"] {
  width: 100%;
  margin: 2px 0;
  height: 28px;
  background: transparent;
  -webkit-appearance: none;
}
.sliderRow { display: flex; gap: 8px; align-items: center; }
.sliderRow input[type="range"] { flex: 1; min-width: 120px; }
.sliderValueInput {
  width: 84px;
  min-width: 84px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  min-height: 0;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sliderValueInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}

.noSpinner::-webkit-outer-spin-button,
.noSpinner::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.noSpinner { -moz-appearance: textfield; }

/* Stepper buttons aligned with Random Workout Generator safe spin controls */
.sliderBtn,
.npStepperBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s, opacity 0.18s;
}
.sliderBtn:hover,
.npStepperBtn:hover {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(88, 166, 255, 0.14);
}
.sliderBtn:active,
.npStepperBtn:active {
  animation: button-pop 0.18s ease-out;
}

.targetsSection .sliderRow .sliderValueInput {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.sliderField input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
}
.sliderField input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-strong);
  margin-top: -8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.sliderField input[type="range"]:focus::-webkit-slider-runnable-track {
  background: rgba(88, 166, 255, 0.6);
}
.sliderField input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
}
.sliderField input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--accent-strong);
}

@media (min-width: 900px) {
  .targetsSection .inputsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .targetsSection .targetSliderFields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .sliderField input[type="range"] { height: 24px; }
  .sliderField input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(90deg, rgba(88, 166, 255, 0.4), rgba(88, 166, 255, 0.1));
  }
  .sliderField input[type="range"]::-webkit-slider-thumb {
    width: 18px; height: 18px; margin-top: -5px;
    background: #ffffff;
    border: 2px solid var(--accent-strong);
  }
  .sliderField input[type="range"]::-moz-range-track {
    height: 8px;
    background: linear-gradient(90deg, rgba(88, 166, 255, 0.4), rgba(88, 166, 255, 0.1));
  }
  .sliderField input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px;
    background: #ffffff;
    border: 2px solid var(--accent-strong);
  }
}

/* Summary */
.summaryRow {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.logModalActions { justify-content: flex-end; }
.summaryRow span { color: var(--text); margin-left: 6px; }
.summaryInlineHint {
  color: var(--muted) !important;
  margin-left: 8px;
  font-size: 12px;
}
.summaryGuidanceHint {
  display: block;
  margin-left: 0;
  margin-top: 4px;
  max-width: 440px;
  line-height: 1.4;
}

/* Ingredients */
.ingredientAdd {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 8px;
}
.ingredientAddActions {
  display: grid;
  gap: 8px;
}
.ingredientFilters { margin-bottom: 8px; }
.ingredientQuickAdd {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.ingredientQuickItem {
  display: grid;
  gap: 8px;
  align-content: start;
}

.quickSuggestionText {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.quickSuggestionName {
  font-size: 14px;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quickSuggestionMeta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 760px) {
  .plannerIngredientQuickAdd {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}

.ingredientList { display: grid; gap: 10px; margin-top: 8px; }

.ingredientRow {
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  padding: 12px;
  background: var(--surface2);
  display: grid;
  gap: 10px;
}
.ingredientRow.bad {
  border-color: rgba(248, 81, 73, 0.7);
  background: rgba(248, 81, 73, 0.08);
}
.ingredientRow.missing {
  border-color: rgba(210, 153, 34, 0.6);
  background: rgba(210, 153, 34, 0.08);
}

.ingredientHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}
.ingredientHeaderText { flex: 1 1 auto; min-width: 0; }
.ingredientName { font-size: 15px; color: var(--text-strong); }
.ingredientMeta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}
.ingredientTags { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.ingredientTag {
  border-radius: 999px;
  padding: 1px 7px;
  border: 1px solid var(--border);
  background: var(--btn);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.iconBtn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
#quickLogRecentList .iconBtn,
#quickLogFrequentList .iconBtn,
#quickLogRecommendedList .iconBtn,
#plannerRecentList .iconBtn,
#plannerFrequentList .iconBtn,
#plannerRecommendedList .iconBtn {
  color: var(--good);
  border-color: rgba(63, 185, 80, 0.5);
  background: rgba(63, 185, 80, 0.12);
}
.iconBtn.danger {
  color: var(--danger-soft-text);
  border-color: var(--danger-soft-border);
  background: var(--danger-soft-bg-strong);
}
.iconBtn:disabled { opacity: 0.45; cursor: not-allowed; }

.ingredientActionBtn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
}

.ingredientActions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  justify-content: flex-end;
}
.ingredientControls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.qtyField { flex: 1 1 140px; min-width: 140px; }
.modeField { flex: 0 0 auto; width: fit-content; justify-self: start; }
.modeField .ingredientModeToggle { width: auto; }
.deliveryField { flex: 1 1 160px; min-width: 160px; }
.qtyStepperRow {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qtyStepperRow .qtyInput {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.deliveryToggle {
  width: 100%;
}
.deliveryToggle button {
  min-width: 56px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
@media (min-width: 900px) {
  .deliveryField { flex: 0 0 auto; min-width: 0; }
  .deliveryToggle { width: auto; }
}

.binaryToggle {
  display: inline-flex;
}

.binaryToggle button {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 56px;
}

.bottleMixToggle button {
  min-width: 64px;
  padding: 8px 12px;
  font-size: 11px;
}

.segmentedModeToggle button {
  min-width: 54px;
  font-size: 11px;
}

.ingredientModeToggle button {
  min-width: 62px;
  font-size: 11px;
}

.tabRowControls #quickLogToggleBtn {
  min-height: 34px;
  padding: 6px 11px;
}

@media (max-width: 700px) {
  .ingredientList {
    gap: 8px;
  }

  .ingredientRow {
    padding: 10px;
    gap: 8px;
    border-radius: 12px;
  }

  .ingredientHeader {
    align-items: flex-start;
    gap: 8px;
  }

  .ingredientName {
    font-size: 14px;
    line-height: 1.2;
  }

  .ingredientMeta {
    gap: 4px;
    font-size: 11px;
    margin-top: 2px;
  }

  .ingredientTags {
    gap: 4px;
  }

  .ingredientTag {
    padding: 1px 6px;
    font-size: 9px;
  }

  .ingredientActions {
    gap: 4px;
  }

  .ingredientControls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 8px;
    align-items: end;
  }

  .ingredientControls .field {
    gap: 4px;
  }

  .ingredientControls .field label {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .ingredientControls .qtyField {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .ingredientControls .modeField {
    min-width: 0;
    width: auto;
  }

  .ingredientControls .deliveryField {
    min-width: 0;
    justify-self: end;
  }

  .ingredientControls .modeField .ingredientModeToggle,
  .ingredientControls .deliveryToggle {
    width: auto;
  }

  .qtyStepperRow {
    gap: 6px;
  }

  .qtyStepperRow .qtyInput {
    min-height: 34px;
    padding: 6px 8px;
  }

  .ingredientModeToggle button,
  .deliveryToggle button {
    min-width: 50px;
    padding: 3px 6px;
    font-size: 10px;
    letter-spacing: 0.05em;
  }

  .ingredientStats {
    font-size: 11px;
    line-height: 1.35;
  }
}

.qtyInput.readOnly { color: var(--accent); border-color: rgba(88, 166, 255, 0.5); }
.qtyInput.zero { color: var(--danger); border-color: rgba(248, 81, 73, 0.7); }
.ingredientStats { font-size: 12px; color: var(--muted); }

/* Alerts — unified with shared .alert from components.css */
.alert {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radiusMd);
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid rgba(248,81,73,0.25);
  background: rgba(248,81,73,0.1);
  color: var(--danger);
  white-space: pre-line;
  margin-bottom: 12px;
}
.alert.show { display: block; }
.alert.success {
  border-color: rgba(63,185,80,0.25);
  background: rgba(63,185,80,0.1);
  color: var(--success);
}

/* Constraint chips */
.constraintBar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.constraintChip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
}
.constraintChip.ok { color: var(--good); border-color: rgba(63, 185, 80, 0.4); }
.constraintChip.bad { color: var(--danger); border-color: rgba(248, 81, 73, 0.6); }

/* Metrics */
.metricGrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.metricCard {
  border-radius: var(--radiusXl);
  border: 1px solid var(--border);
  padding: 14px;
  background: var(--surface2);
  display: grid;
  gap: 8px;
}
.metricTitle {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metricRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 12px;
  font-size: 14px;
}
.metricRow span { text-align: left; min-width: 0; }
.metricRow strong {
  color: var(--text-strong);
  font-weight: 600;
  text-align: right;
  justify-self: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.metricValueWithHint {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.metricValueWithHint strong {
  justify-self: auto;
}
.metricInlineHint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: right;
  white-space: normal;
  max-width: 220px;
}

.infoBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--btn);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.infoBtn:hover {
  background: var(--btnHover);
  color: var(--text);
  border-color: var(--border);
}
.infoBtn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3);
}
.infoModalBody { white-space: pre-line; }

.metricGroup { display: grid; gap: 6px; }
.metricGroup + .metricGroup {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(48, 54, 61, 0.6);
}
.metricGroupTitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.metricRow.sub { font-size: 12px; color: var(--muted); padding-left: 12px; }
.metricRow.sub strong { color: var(--text); font-weight: 500; }
.metricRow.flagged, .metricRow.flagged strong { color: var(--danger); }

/* Segment graphs */
.outputGraphsWrap {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.outputGraphsWrap[hidden] { display: none !important; }
#outputViewGrid { margin-top: 12px; }
.segmentGraphInlinePanel {
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  background: var(--surface2);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.segmentGraphInlinePanel.expand-panel.open {
  background: var(--surface);
}

.segmentGraphInlinePanel[hidden] { display: none !important; }

.outputGraphsWrap > .expand-btn[aria-expanded="true"] + .expand-panel {
  margin-top: -10px;
}
.segmentGraphStack { display: grid; gap: 12px; }
.segmentGraphHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.segmentGraphUnit {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.segmentGraphAxis { display: flex; font-size: 11px; color: var(--muted); }
.segmentGraphAxisX { justify-content: space-between; }
.segmentGraphAxisY {
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  text-align: right;
}
.segmentGraphTick { white-space: nowrap; }
.segmentGraphFrame {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: stretch;
}
.segmentGraphPlotWrap { display: grid; gap: 6px; }
.segmentGraphPlot {
  border-radius: var(--radiusLg);
  border: 1px solid var(--border);
  background: var(--surface2);
  padding: 10px;
  height: 160px;
  position: relative;
  overflow: hidden;
}
.segmentGraphPlot svg { width: 100%; height: 100%; display: block; }
.segmentGraphArea { fill: rgba(88, 166, 255, 0.18); }
.segmentGraphLine {
  stroke: var(--accent);
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ratioLine { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* Recipe */
.recipeList { display: grid; gap: 10px; }
.recipeGroup { display: grid; gap: 10px; margin-bottom: 12px; }
.recipeGroup:last-child { margin-bottom: 0; }
.recipeSimpleList { gap: 4px; }
.recipeSimpleLine {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: baseline;
  font-size: 14px;
}
.recipeSimpleHead {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.recipeSimpleQty {
  color: var(--text-strong);
  font-weight: 600;
  justify-self: end;
  white-space: nowrap;
}
.recipeSimpleEmpty {
  color: var(--muted);
  font-size: 13px;
}
.recipeItem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radiusLg);
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 14px;
}

/* Dark gray surface alignment for requested controls/cards */
.targetsSection .field,
.ingredientRow,
#keyOutputsCard,
.metricCard.outputView,
.recipeItem,
.binaryToggle {
  background: var(--bg);
}
.segmentChoice { justify-content: flex-start; gap: 10px; cursor: pointer; }
.segmentChoice input { margin: 0; }
.recipeAmounts { display: grid; gap: 6px; min-width: 180px; }
.recipeAmount {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 10px;
  align-items: baseline;
  width: 100%;
  font-size: 14px;
  color: var(--text);
}
.recipeAmount strong { color: var(--text-strong); font-weight: 600; justify-self: end; }
.recipeTag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-left: 8px;
}

.smallNotice { font-size: 12px; color: var(--muted); min-height: 16px; }
.smallNotice.error { color: var(--danger); }

.dataAlert {
  display: none;
  border-radius: var(--radiusLg);
  padding: 12px 14px;
  font-size: 13px;
  border: 1px solid var(--danger-soft-border);
  background: var(--danger-soft-bg);
  color: var(--danger-soft-text);
  white-space: pre-line;
  margin-bottom: 16px;
}
.dataAlert.warn {
  border-color: var(--warn-soft-border);
  background: var(--warn-soft-bg);
  color: var(--warn-soft-text);
}
.dataAlert.show { display: block; }

/* Modals — follows shared .modal-overlay / .modal-card pattern from components.css */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 90;
}
.modalOverlay.open { display: flex; }
.modalCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  width: min(720px, 100%);
  max-height: 80vh;
  overflow: auto;
  margin-bottom: 0;
  position: relative;
}

.logSharedCard {
  display: grid;
  gap: 10px;
  margin-bottom: 0;
}
#logModal { margin-top: 0; }

.logCredentialsRow .field {
  min-width: 0;
}

.logFetchCell {
  display: flex;
  align-items: flex-end;
}

.logFetchCell .btn {
  width: auto;
  white-space: nowrap;
  min-height: 44px;
}

@media (min-width: 900px) {
  .logCredentialsRow {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    align-items: end;
  }

  .logCredentialsRow.durationCalcCredentialsRow {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
  }
}

.logRememberRow {
  margin-top: 2px;
}

.logExecutionHydrationGrid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.logExecutionColumn {
  display: grid;
  gap: 8px;
  align-content: start;
}

.logExecutionColumnHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.logExecutionColumnHeader label {
  margin: 0;
}

.logExecutionList {
  display: grid;
  gap: 6px;
  align-content: start;
}

.logExecutionList .bottleCard {
  margin-top: 0;
}

.logExecutionBottleCard .bottleCardBody {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.logExecutionCardTag {
  margin-left: 0;
}

.logExecutionOtherSection {
  display: grid;
  gap: 8px;
}

.logExecutionOtherList {
  display: grid;
  gap: 8px;
}

.logExecutionOtherRow {
  padding: 10px 12px;
  gap: 8px;
}

.logExecutionOtherHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.logExecutionOtherHead .ingredientName {
  font-size: 14px;
}

.logTotalsSection {
  display: grid;
  gap: 8px;
}

.logTotalsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.logTotalsTable th,
.logTotalsTable td {
  padding: 7px 0;
  border-bottom: 1px solid var(--borderMuted);
}

.logTotalsTable th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
}

.logTotalsTable td {
  text-align: right;
  color: var(--text-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.logTotalsTable tr:last-child th,
.logTotalsTable tr:last-child td {
  border-bottom: none;
}

@media (min-width: 900px) {
  .logExecutionHydrationGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.logFieldToggleSection {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.logFieldChipWrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.logFieldChip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.logFieldChip:hover {
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--text);
}

.logFieldChip.on {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.16);
  color: var(--accent);
  font-weight: 600;
}

.logFieldChipDot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--muted2);
  transition: background 0.15s;
}

.logFieldChip.on .logFieldChipDot {
  background: var(--accent);
}

.modalCard.ingredientBrowseCard {
  width: min(1120px, 100%);
  max-height: 90vh;
}

.modalCard.ingredientProposalCard {
  width: min(860px, 100%);
  max-height: 90vh;
}

.ingredientBrowseTableWrap {
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  background: var(--surface2);
  overflow: auto;
  max-height: 56vh;
}

.ingredientBrowseTable {
  border-collapse: collapse;
  table-layout: auto;
  width: max-content;
  min-width: 100%;
  --browse-action-col-width: 42px;
  --browse-flag-col-width: 42px;
}

.ingredientBrowseTable th,
.ingredientBrowseTable td {
  border-bottom: 1px solid rgba(48, 54, 61, 0.65);
  padding: 7px 10px;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  min-width: 110px;
}

.ingredientBrowseTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elev);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ingredientBrowseTable thead tr.filterRow th {
  top: 31px;
  z-index: 3;
  padding: 6px;
  text-transform: none;
  letter-spacing: 0;
  background: var(--surface);
}

.ingredientBrowseTable th.sortable {
  cursor: pointer;
  user-select: none;
}
.ingredientBrowseTable th.sortable:hover { color: var(--text-strong); }
.ingredientBrowseSort {
  font-size: 10px;
  margin-left: 4px;
}

.ingredientBrowseFilter {
  width: 100%;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
}
.ingredientBrowseFilter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.ingredientBrowseTable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ingredientBrowseTable th.itemCol,
.ingredientBrowseTable td.itemCol {
  position: sticky;
  left: 0;
  min-width: 160px;
  z-index: 2;
  background: var(--surface);
}
.ingredientBrowseTable thead tr:first-child th.itemCol {
  z-index: 5;
  background: var(--bg-elev);
}
.ingredientBrowseTable thead tr.filterRow th.itemCol {
  z-index: 6;
  background: var(--surface);
}
.ingredientBrowseTable td.actionCol,
.ingredientBrowseTable th.actionCol {
  text-align: center;
  width: var(--browse-action-col-width);
  min-width: var(--browse-action-col-width);
  max-width: var(--browse-action-col-width);
  padding-left: 4px;
  padding-right: 4px;
  position: sticky;
  right: 0;
  z-index: 4;
  background: var(--surface);
}
.ingredientBrowseTable td.flagCol,
.ingredientBrowseTable th.flagCol {
  text-align: center;
  width: var(--browse-flag-col-width);
  min-width: var(--browse-flag-col-width);
  max-width: var(--browse-flag-col-width);
  padding-left: 4px;
  padding-right: 4px;
  position: sticky;
  right: var(--browse-action-col-width);
  z-index: 3;
  background: var(--surface);
}
.ingredientBrowseTable thead tr:first-child th.actionCol,
.ingredientBrowseTable thead tr:first-child th.flagCol {
  z-index: 6;
  background: var(--bg-elev);
}
.ingredientBrowseTable thead tr.filterRow th.actionCol,
.ingredientBrowseTable thead tr.filterRow th.flagCol {
  z-index: 7;
  background: var(--surface);
}
.ingredientBrowseTable tbody tr:hover { background: rgba(88, 166, 255, 0.08); }
.ingredientBrowseTable tbody tr:hover td.itemCol {
  background: rgba(88, 166, 255, 0.08);
}
.ingredientBrowseTable tbody tr:hover td.actionCol,
.ingredientBrowseTable tbody tr:hover td.flagCol {
  background: rgba(88, 166, 255, 0.08);
}

.ingredientBrowseAddBtn {
  min-width: 30px;
  min-height: 30px;
  border-radius: 8px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.ingredientBrowseAddBtn.is-add {
  color: var(--good);
  border-color: rgba(63, 185, 80, 0.5);
  background: rgba(63, 185, 80, 0.15);
}
.ingredientBrowseAddBtn.is-remove {
  color: var(--danger-soft-text);
  border-color: var(--danger-soft-border);
  background: var(--danger-soft-bg-strong);
}
.ingredientBrowseFlagBtn {
  min-width: 30px;
  min-height: 30px;
  border-radius: 8px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  font-weight: 500;
  color: var(--danger-soft-text);
  border-color: var(--danger-soft-border);
  background: var(--danger-soft-bg);
}
.ingredientBrowseFlagBtn:hover {
  background: var(--danger-soft-bg-hover);
}
.ingredientBrowseProposalRow td {
  background: rgba(148, 163, 184, 0.08);
}
.ingredientBrowseProposalRow td.itemCol {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}
.ingredientBrowseProposalRow td.actionCol,
.ingredientBrowseProposalRow td.flagCol {
  background: rgba(148, 163, 184, 0.08);
}
.ingredientBrowseProposalBtn {
  color: var(--good);
  border-color: rgba(63, 185, 80, 0.5);
  background: rgba(63, 185, 80, 0.15);
  font-size: 12px;
  font-weight: 600;
  min-width: 30px;
  padding: 0;
}
.ingredientBrowseProposalBtn:hover {
  background: rgba(63, 185, 80, 0.24);
}

.ingredientProposalGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ingredientProposalField {
  min-width: 0;
}
.ingredientProposalRefField {
  grid-column: 1 / -1;
}
.ingredientProposalField.changed {
  padding: 8px;
  border: 1px solid rgba(88, 166, 255, 0.45);
  border-radius: var(--radius);
  background: rgba(88, 166, 255, 0.08);
}
.ingredientProposalHint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

/* Animation */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
  .ingredientAdd { grid-template-columns: 1fr auto; align-items: end; }
  .ingredientAddActions { min-width: 150px; }
}

@media (max-width: 640px) {
  .modalOverlay {
    padding: 8px;
  }
  #ingredientBrowseModal {
    padding: 0;
  }
  .modalCard.ingredientBrowseCard {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }
  .ingredientBrowseTableWrap {
    max-height: calc(100vh - 186px);
  }
  .modalCard.ingredientProposalCard {
    width: 100%;
    max-height: calc(100vh - 16px);
  }
  .ingredientProposalGrid {
    grid-template-columns: 1fr;
  }
  .tabMainRow {
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }
  .tabMainRow .tabs#mixTabs {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }
  .tabRowControls {
    width: auto;
    min-width: 0;
    justify-content: flex-end;
    gap: 6px;
    flex: 0 0 auto;
  }
  .tabRowControls .binaryToggle button {
    min-width: 48px;
    min-height: 28px;
    padding: 4px 10px;
    font-size: 10px;
  }
  .tabRowControls .binaryToggle {
    min-height: 32px;
    padding: 2px;
  }
  .tabRowControls #quickLogToggleBtn {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
    white-space: nowrap;
  }
  .segmentedToggleLabel {
    display: none;
  }
  .plannerStepPills {
    --step-pill-gap: 7px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .plannerStepTop {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .plannerStepTop #statusPill {
    align-self: auto;
    margin-left: auto;
  }
  .step-pill {
    flex: 0 0 auto;
    justify-content: center;
    gap: 5px;
    font-size: 11px;
    padding: 7px 9px;
  }
  .step-pill .pill-n {
    width: 17px;
    height: 17px;
    font-size: 9px;
  }
  .plannerStepPills .step-pill:not(:last-child)::after {
    left: calc(100% - 1px);
    width: calc(var(--step-pill-gap) + 2px);
  }
  .plannerStepFooter {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .plannerStepFooter .btn {
    width: 100%;
    min-width: 0;
  }
  .recipeLockControl {
    gap: 8px;
    padding: 4px 8px;
  }
  .recipeLockLabel {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section { animation: none; }
  html { scroll-behavior: auto; }
}
