:root {
  --ink: #1e3a34;
  --ink-deep: #283838;
  --muted: #4a5d59;
  --teal: #70a8a0;
  --teal-soft: #80c0b8;
  --sage: #a4c3b2;
  --cream: #f2efe9;
  --paper: #fdfcfb;
  --taupe: #dfdace;
  --line: #d4cfc4;
  --danger: #8b2e2e;
  --shadow: 0 10px 30px rgba(30, 58, 52, 0.08);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Instrument Sans", "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  padding: calc(20px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
}

.wrap {
  width: min(440px, 100%);
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 12px 8px 8px;
}

.logo {
  width: min(260px, 82%);
  height: auto;
  display: block;
  margin: 0 auto 14px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.tagline {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
}

.provider {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 18px;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  border: 1.5px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--ink-deep);
}

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--taupe);
}

.icon-svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.note {
  margin: 6px 2px 0;
  font-size: 0.86rem;
  color: var(--muted);
  text-align: center;
}

.section {
  margin-top: 28px;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.card-list {
  display: grid;
  gap: 10px;
}

.card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 0 rgba(30, 58, 52, 0.03);
}

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

.card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.price {
  margin: 2px 0 0;
  font-weight: 650;
  color: var(--ink);
}

.card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.more-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
}

.contact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.contact .btn {
  min-height: 50px;
  font-size: 0.98rem;
}

.contact .btn-wide {
  grid-column: 1 / -1;
}

.install {
  margin-top: 24px;
  background: #e8efe9;
  border: 1px solid var(--sage);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.install[hidden] {
  display: none;
}

.install h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.install p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.install ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.install li + li {
  margin-top: 6px;
}

.footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--taupe);
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.footer p {
  margin: 0 0 8px;
}

.emergency {
  color: var(--danger);
  font-weight: 650;
}

.footer a {
  color: var(--ink);
  font-weight: 600;
}

.legal {
  margin-top: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}

/* ---------- v2: tools, views, tab bar ---------- */
body {
  padding-bottom: calc(92px + var(--safe-bottom));
}

[hidden] {
  display: none !important;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  min-height: 118px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tool-card:active {
  transform: scale(0.98);
}

.tool-card:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.tool-card strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.25;
}

.tool-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.tool-card-wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  min-height: 0;
  background: #e8efe9;
  border-color: var(--sage);
}

.tool-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
}

.tool-icon svg {
  width: 22px;
  height: 22px;
}

.view-head {
  padding: 4px 0 10px;
}

.view-head h1 {
  margin: 6px 0 0;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.back-link {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.lead {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--cream);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 99px;
}

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

.choice {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--taupe);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 50px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice span {
  display: block;
  font-weight: 600;
  line-height: 1.3;
}

.choice small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.choice:hover,
.choice:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.choices-danger .choice {
  font-size: 0.93rem;
  border-color: #e6d4d0;
  background: #fcf8f7;
}

.choices-danger .choice:hover,
.choices-danger .choice:focus-visible {
  border-color: var(--danger);
}

.panel > .btn,
.rec .btn,
.alert .btn,
#refill-status .btn {
  width: 100%;
  font: inherit;
  font-weight: 650;
  font-size: 1.02rem;
  cursor: pointer;
}

button.btn {
  font-family: inherit;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
}

.link-btn {
  background: none;
  border: 0;
  padding: 6px 2px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-danger {
  color: var(--danger);
}

.rec {
  display: grid;
  gap: 8px;
  background: #e8efe9;
  border: 1px solid var(--sage);
  border-radius: 16px;
  padding: 16px;
}

.rec h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.rec p {
  margin: 0;
}

.rec-price {
  font-size: 1.35rem;
}

.rec-why {
  color: var(--ink);
}

.rec-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.rec .more-link {
  margin-top: 2px;
  text-align: center;
}

.panel .eyebrow,
.result .eyebrow {
  text-align: left;
}

.alert {
  display: grid;
  gap: 10px;
  border-radius: 16px;
  padding: 16px;
}

.alert h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.alert p {
  margin: 0;
}

.alert-danger {
  background: #fbefed;
  border: 1.5px solid var(--danger);
  color: var(--danger);
}

.alert-danger p {
  color: #5c2222;
}

.alert-info {
  background: #f6f3ec;
  border: 1.5px solid var(--taupe);
}

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
}

.crisis {
  font-weight: 600;
}

.disclaimer {
  margin: 12px 2px 0;
  font-size: 0.84rem;
  color: var(--muted);
  font-style: italic;
}

.panel .disclaimer,
.result .disclaimer {
  margin: 0;
}

.privacy {
  margin: 4px 0 0;
  padding: 10px 12px;
  background: #e8efe9;
  border: 1px solid var(--sage);
  border-radius: 12px;
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 500;
}

/* Forms */
.field {
  display: grid;
  gap: 5px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 48px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.field textarea {
  min-height: 70px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(112, 168, 160, 0.3);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.units-us,
.units-metric {
  display: grid;
  gap: 12px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--cream);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 9px 6px;
  cursor: pointer;
}

.seg-btn.is-on {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(30, 58, 52, 0.12);
}

.checks {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.checks legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.checks input {
  width: 20px;
  height: 20px;
  accent-color: var(--ink);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row .btn {
  min-height: 50px;
  font-size: 0.98rem;
}

.btn-row .btn:only-child {
  grid-column: 1 / -1;
}

.btn-danger {
  color: var(--danger);
  border-color: #e6d4d0;
}

/* BMI */
.bmi-value {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.bmi-cat {
  margin: -4px 0 0;
  font-weight: 600;
  color: var(--muted);
}

/* Tracker */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stats:empty {
  display: none;
}

.stat {
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat strong {
  display: block;
  font-size: 1.05rem;
  margin-top: 2px;
}

.stat-good strong {
  color: #2f6d5f;
}

.chart-panel {
  padding: 10px 8px 6px;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart .grid {
  stroke: var(--taupe);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart .axis {
  font-size: 11px;
  fill: var(--muted);
  font-family: inherit;
}

.chart .line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .area {
  fill: rgba(112, 168, 160, 0.18);
}

.chart .dot {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
}

.empty {
  margin: 0;
  padding: 10px 6px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  list-style: none;
}

.entry-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.entry {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: 14px;
  padding: 10px 12px;
}

.entry-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.entry-main strong {
  font-size: 1.05rem;
}

.entry-date {
  font-size: 0.85rem;
  color: var(--muted);
}

.entry-dose,
.entry-notes {
  font-size: 0.86rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.entry-notes {
  color: var(--muted);
}

.entry-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 0 auto;
}

/* Refill */
.countdown {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.count {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.due-date {
  margin: -6px 0 0;
  color: var(--muted);
}

.shot-line {
  margin: 0;
  font-size: 0.95rem;
}

/* FAQ */
.faq {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.faq details {
  background: var(--paper);
  border: 1px solid var(--taupe);
  border-radius: 14px;
  overflow: hidden;
}

.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 44px 14px 16px;
  font-weight: 650;
  position: relative;
  line-height: 1.35;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--muted);
}

.faq details[open] summary::after {
  content: "\2212";
}

.faq summary:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: -3px;
}

.faq details > p,
.faq details > ul {
  margin: 0;
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 0.94rem;
}

.faq a {
  color: var(--ink);
  font-weight: 600;
}

.price-list {
  list-style: none;
  display: grid;
  gap: 6px;
}

.price-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--taupe);
  padding-bottom: 6px;
}

.price-list strong {
  color: var(--ink);
  white-space: nowrap;
}

.emergency-text {
  color: var(--danger) !important;
  font-weight: 600;
}

/* Bottom tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: rgba(253, 252, 251, 0.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--taupe);
  padding: 6px max(6px, calc((100% - 480px) / 2)) calc(6px + var(--safe-bottom));
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

.tabbar a[aria-current="page"] {
  color: var(--ink);
  background: #e8efe9;
}

.tabbar a:focus-visible {
  outline: 2px solid var(--teal);
}

@media (prefers-reduced-motion: reduce) {
  .tool-card,
  .choice {
    transition: none;
  }
}
