/* ============================================================
   Smart Reconstitution Optimizer — page styles
   Depends on shared.css for theme tokens and base components.
   ============================================================ */

.calc-shell--optimize { max-width: 680px; }

/* ---------- Input fields ---------- */
.opt-field { margin: 0 0 20px; }

.opt-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.opt-field .field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ---------- Chips ---------- */
.opt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opt-chip {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.opt-chip:hover { color: var(--text); border-color: var(--accent); }

.opt-chip.selected,
.opt-chip[aria-checked="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.opt-chip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.opt-chip--other { font-style: normal; }

/* Custom input revealed under a chip group */
.opt-custom { margin-top: 10px; }

.opt-custom-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.opt-custom input {
  width: 9em;
  max-width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  -moz-appearance: textfield;
}

.opt-custom input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.opt-custom-unit {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---------- Dose row: chips + unit toggle ---------- */
.dose-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.dose-head .opt-chips { flex: 1; }

.unit-toggle {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 3px;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
}

.unit-toggle button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.unit-toggle button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.unit-toggle button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Compound picker ---------- */
.compound-select { position: relative; display: block; }

.compound-select::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.compound-select select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 34px 9px 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.compound-select select:hover { border-color: var(--accent); }
.compound-select select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.opt-compound-note {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--text-faint);
  line-height: 1.5;
}
.opt-compound-note strong { color: var(--text-muted); font-weight: 600; }

/* ---------- Preference segmented control ---------- */
.seg-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.seg {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.seg:hover { color: var(--text); }

.seg.on,
.seg[aria-checked="true"] {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.seg:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Results ---------- */
.opt-results-wrap { margin-top: 26px; }

.opt-summary {
  margin: 26px 0 14px;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text);
}
.opt-summary__doses {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--accent);
}
.opt-summary__sub {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.opt-fallback-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--danger);
}

.opt-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.opt-card--rec {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.opt-card__main { min-width: 0; }

.opt-card__headline {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.45;
}
.opt-card__headline strong {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  color: var(--text);
}
.opt-card--rec .opt-card__headline strong { color: var(--accent); }
.opt-card__arrow { color: var(--text-faint); margin: 0 2px; }

.opt-card__detail {
  margin: 5px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.opt-approx-note {
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

/* ---------- Badges ---------- */
.opt-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.opt-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.opt-badge--read  { color: var(--accent);  background: var(--accent-soft);  border-color: var(--accent); }
.opt-badge--small { color: var(--text-muted); background: var(--bg-subtle); border-color: var(--border-strong); }
.opt-badge--water { color: var(--success); background: var(--success-soft); border-color: var(--success); }
.opt-badge--approx { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Use-this link ---------- */
.opt-use {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.opt-use:hover { background: var(--accent); color: var(--accent-text); }
.opt-use:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.opt-empty {
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Share bar ---------- */
.opt-sharebar {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.share-btn:hover { background: var(--accent); color: var(--accent-text); }
.share-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.share-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Below-tool reference section ---------- */
.section-divider {
  max-width: 720px;
  margin: 56px auto 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.reference {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 22px 8px;
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.reference h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.reference h3 {
  margin: 24px 0 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.reference p { margin: 0 0 12px; }
.reference strong { color: var(--text); font-weight: 600; }

.reference a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.reference a:hover { border-bottom-color: var(--accent); }

.reference .ref-formula {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
}

.reference .ref-disclaimer {
  font-size: 0.85rem;
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
}

.reference .related-tools {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.reference .related-tools li { margin: 0 0 8px; }

.footer-disclaimer {
  max-width: 720px;
  margin: 0 auto 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .calc-shell.calc-shell--optimize {
    padding: 0 16px;
    margin-top: 80px;
  }
  .opt-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .opt-use { justify-content: center; }
  .reference { padding: 28px 16px 8px; }
  .section-divider { margin-top: 40px; }
}
