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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.page-layout {
  display: flex;
  gap: 2rem;
  width: 100%;
  max-width: 960px;
  align-items: flex-start;
}

h1 {
  font-size: 2rem;
  color: #c0392b;
  margin-bottom: 0.25rem;
  letter-spacing: 0.5px;
}

.subtitle {
  color: #888;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.subtitle a {
  color: #c0392b;
  text-decoration: underline;
}

.subtitle a:hover {
  color: #e74c3c;
}

.calculator {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  flex: 1;
  min-width: 0;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.input-group input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 1px solid #333;
  border-radius: 8px;
  background: #111;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: #c0392b;
}

.unit-toggle {
  display: flex;
  border: 1px solid #333;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.unit-toggle button {
  padding: 0.75rem 1rem;
  border: none;
  background: #111;
  color: #888;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}

.unit-toggle button.active {
  background: #c0392b;
  color: #fff;
}

.calculate-btn {
  width: 100%;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  background: #c0392b;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.calculate-btn:hover {
  background: #a93226;
}

.results {
  margin-top: 1.5rem;
  display: none;
}

.results.visible {
  display: block;
}

.section-heading {
  font-size: 0.85rem;
  color: #c0392b;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #2a2a2a;
}

.section-heading:not(:first-child) {
  margin-top: 1.25rem;
}

/* Collapsible iron sections */
.iron-section {
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: #151515;
  overflow: hidden;
}

.iron-section > *:not(summary) {
  animation: sectionReveal 0.25s ease-out;
}

.iron-section > summary.section-heading {
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 1rem;
  margin-bottom: 0;
  border-bottom: none;
  border-radius: 8px;
  transition: background 0.2s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.iron-section > summary.section-heading::after {
  content: "▸";
  font-size: 0.9rem;
  color: #555;
  transition: transform 0.2s;
}
@keyframes sectionReveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.iron-section[open] > summary.section-heading::after {
  transform: rotate(90deg);
}

.iron-section > summary.section-heading:hover {
  background: #1e1e1e;
}

.iron-section > summary.section-heading::-webkit-details-marker {
  display: none;
}

.iron-section[open] > summary.section-heading {
  border-bottom: 1px solid #2a2a2a;
  border-radius: 8px 8px 0 0;
}

.iron-section > .section-desc,
.iron-section > .dose-range,
.iron-section > .pill-count-banner,
.iron-section > .nonheme-group,
.iron-section > .warning,
.iron-section > .dose-limit {
  margin-left: 1rem;
  margin-right: 1rem;
}

.iron-section > .section-desc {
  margin-top: 0.75rem;
}

.iron-section > .pill-count-banner:last-child,
.iron-section > .nonheme-group:last-child,
.iron-section > .warning:last-child {
  margin-bottom: 1rem;
}

.section-desc {
  font-size: 0.82rem;
  color: #777;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.dose-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dose-range .result-card {
  flex: 1;
  margin-bottom: 0;
}

.dose-separator {
  color: #555;
  font-size: 0.85rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

.result-card {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.result-label {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #e0e0e0;
}

.result-value span {
  font-size: 0.9rem;
  color: #888;
  font-weight: 400;
}

.warning {
  background: #2a1a0a;
  border: 1px solid #6b3a00;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #f0a030;
  line-height: 1.5;
  display: none;
}

.warning.visible {
  display: block;
}

.weight-display {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1.25rem;
  min-height: 1.25rem;
}

.warning a {
  color: #f0a030;
  text-decoration: underline;
}

.warning a:hover {
  color: #ffc060;
}

.product-card {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.product-name {
  font-size: 0.85rem;
  color: #e0e0e0;
  margin-bottom: 0.25rem;
}
.product-detail {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.25rem;
}
.pill-count-banner {
  margin-bottom: 0.75rem;
}

.pill-count {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e0e0e0;
  text-align: center;
  padding: 0.75rem;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.pill-count-banner .product-card {
  border-radius: 0 0 8px 8px;
  margin-bottom: 0;
}

.heme-product-select {
  flex: 1;
}

.promo-code {
  font-size: 0.8rem;
  color: #4caf50;
  margin-top: 0.25rem;
}

.product-link {
  background: #c0392b;
  color: #fff;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s;
}

.product-link:hover {
  background: #a93226;
}

.disclaimer {
  margin-top: 1.5rem;
  max-width: 960px;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
  line-height: 1.5;
}

/* Schedule Panel */
.schedule-panel {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  flex: 1;
  min-width: 0;
}

.schedule-title {
  font-size: 1.25rem;
  color: #e0e0e0;
  margin-bottom: 0.75rem;
}

.schedule-intro {
  font-size: 0.85rem;
  color: #888;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.schedule-intro strong {
  color: #ccc;
}

.schedule-options {
  margin-bottom: 1.25rem;
}

.schedule-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: #ccc;
  transition: border-color 0.2s;
}

.schedule-option:hover {
  border-color: #444;
}

.schedule-option input[type="checkbox"] {
  accent-color: #c0392b;
  width: 16px;
  height: 16px;
}

.schedule-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: #0f0f0f;
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
  margin-left: auto;
}

.schedule-result {
  margin-top: 1.25rem;
}

.timeline-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid #1f1f1f;
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-time {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c0392b;
  min-width: 70px;
  flex-shrink: 0;
}

.timeline-event {
  font-size: 0.85rem;
  color: #ccc;
  line-height: 1.4;
}

.timeline-note {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.15rem;
}

.dose-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.dose-progress-bar {
  flex: 1;
  height: 6px;
  background: #2a2a2a;
  border-radius: 3px;
  overflow: hidden;
  max-width: 160px;
}

.dose-progress-fill {
  height: 100%;
  background: #c0392b;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.dose-progress-label {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
}

.nonheme-group {
  border: 2px solid #555;
  border-radius: 10px;
  padding: 0;
  margin-top: 0.5rem;
  background: #131313;
  overflow: hidden;
}

.nonheme-group .pill-count-banner {
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
}

.nonheme-group .pill-count-banner + .pill-count-banner {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.schedule-summary {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: #1a1a1a;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  font-size: 0.8rem;
  color: #999;
  line-height: 1.6;
}

.schedule-tips {
  margin-top: 1.5rem;
}

.schedule-tips ul {
  list-style: none;
  padding: 0;
}

.schedule-tips li {
  font-size: 0.82rem;
  color: #888;
  line-height: 1.5;
  padding: 0.4rem 0;
  padding-left: 1.2rem;
  position: relative;
}

.schedule-tips li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #555;
}

.schedule-tips a {
  color: #c0392b;
  text-decoration: underline;
}

.schedule-tips a:hover {
  color: #e74c3c;
}

.dose-limit {
  font-size: 0.8rem;
  color: #ccc;
  background: #1a1a2a;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
}

/* Dosage Chart */
.dosage-chart {
  background: #111;
  border: 1px solid #2a2a2a;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0.75rem 1rem;
}

.dosage-chart-title {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  text-align: center;
}

.dosage-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.dosage-table th {
  text-align: left;
  padding: 0.35rem 0.6rem;
  color: #666;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #2a2a2a;
}

.dosage-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid #1f1f1f;
}

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

.dosage-table .col-pills {
  color: #888;
}

.dosage-table .col-mg {
  color: #e0e0e0;
  font-weight: 600;
  text-align: right;
}

.dosage-table tr.highlighted {
  background: #132a13;
}

.dosage-table tr.highlighted td {
  border-left: 1px solid #4caf50;
  border-right: 1px solid #4caf50;
}

.dosage-table tr.highlighted td:first-child {
  border-left: 2px solid #4caf50;
}

.dosage-table tr.highlighted td:last-child {
  border-right: 2px solid #4caf50;
}

.dosage-table tr.highlighted td.col-marker {
  border-left: none;
  border-right: none;
}

.dosage-table tr.highlighted .col-pills,
.dosage-table tr.highlighted .col-mg {
  color: #4caf50;
}

.dosage-table tr.highlight-start td {
  border-top: 2px solid #4caf50;
}

.dosage-table tr.highlight-end td {
  border-bottom: 2px solid #4caf50;
}

.dosage-table .col-marker {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: transparent;
  padding: 0 0.4rem;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dosage-table tr.highlighted .col-marker {
  color: #4caf50;
}

.dosage-table .range-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  color: #4caf50;
  background: #1a3a1a;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  body {
    padding: 0.5rem 0;
  }

  h1 {
    padding-left: 0.5rem;
    font-size: 1.5rem;
  }

  .subtitle {
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .page-layout {
    flex-direction: column;
    gap: 0;
  }

  .calculator {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  .input-group {
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
  }

  .weight-display {
    padding: 0 0.5rem;
    margin-bottom: 0.75rem;
  }

  .calculate-btn {
    border-radius: 0;
  }

  .results {
    margin-top: 0;
  }

  .iron-section {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-bottom: 0;
  }

  .iron-section > summary.section-heading {
    padding: 0.6rem 0.5rem;
    border-radius: 0;
  }

  .iron-section[open] > summary.section-heading {
    border-radius: 0;
  }

  .iron-section > .section-desc,
  .iron-section > .dose-range,
  .iron-section > .pill-count-banner,
  .iron-section > .nonheme-group,
  .iron-section > .warning,
  .iron-section > .dose-limit {
    margin: 0;
  }

  .iron-section > .section-desc {
    padding: 0.4rem 0.5rem;
  }

  .iron-section > .pill-count-banner:last-child,
  .iron-section > .nonheme-group:last-child,
  .iron-section > .warning:last-child {
    margin-bottom: 0;
  }

  .dose-range {
    gap: 0;
    margin-bottom: 0;
  }

  .result-card {
    padding: 0.5rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-bottom: 0;
  }

  .result-label {
    font-size: 0.7rem;
  }

  .result-value {
    font-size: 1.15rem;
  }

  .dose-separator {
    padding: 0 0.15rem;
  }

  .pill-count {
    padding: 0.5rem;
    font-size: 0.85rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .pill-count-banner {
    margin-bottom: 0;
  }

  .product-card {
    padding: 0.5rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-bottom: 0;
  }

  .product-link {
    text-align: center;
    padding: 0.5rem;
    border-radius: 0;
  }

  .dose-limit {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .dosage-chart {
    padding: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .dosage-table td,
  .dosage-table th {
    padding: 0.3rem 0.5rem;
  }

  .nonheme-group {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-width: 1px;
  }

  .warning {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .disclaimer {
    margin-top: 0.75rem;
    padding: 0 0.5rem;
  }
}
