/* ============================================================
   FWD Range Report — shared stylesheet
   Friends With Diabetes International
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,650&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --paper: #faf8f4;
  --card: #ffffff;
  --ink: #22303a;
  --ink-soft: #5b6b76;
  --line: #e4dfd6;
  --accent: #1e6f5c;        /* deep range-green: the tool's thesis */
  --accent-soft: #e6f2ee;

  /* Glucose band colors — the field's own vernacular */
  --b-verylow: #b3261e;
  --b-low: #e2574c;
  --b-inrange: #3f9d6f;
  --b-high: #e8b330;
  --b-veryhigh: #d97a1f;
  --b-custom: #2a7fa8;

  --radius: 12px;
  --shadow: 0 1px 3px rgba(34,48,58,.08), 0 4px 16px rgba(34,48,58,.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px 80px; }

/* ---------- header ---------- */
header.site {
  padding: 28px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.brand {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--accent);
  text-decoration: none;
}
.brand:hover { text-decoration: underline; }

h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 650;
  font-size: clamp(30px, 5.5vw, 44px);
  line-height: 1.12;
  margin: 14px 0 8px;
}
.lede { color: var(--ink-soft); font-size: 17px; max-width: 60ch; margin: 0 0 8px; }

h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 650;
  font-size: 24px;
  margin: 0 0 6px;
}
h3 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }

/* ---------- cards & sections ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 0 0 22px;
}
.card .hint { color: var(--ink-soft); font-size: 14px; margin: 4px 0 0; }

.privacy {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid #cbe4db;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14.5px;
  color: #1c4f43;
  margin-bottom: 22px;
}
.privacy strong { font-weight: 600; }

/* ---------- platform chooser ---------- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 26px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }

a.choice {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, transform .15s ease;
}
a.choice:hover { border-color: var(--accent); transform: translateY(-2px); }
a.choice .go { color: var(--accent); font-weight: 600; font-size: 14.5px; }
.choice p { color: var(--ink-soft); font-size: 14.5px; margin: 6px 0 10px; }
.soon {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--ink-soft);
}
.soon h2 { color: var(--ink-soft); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 14.5px; margin: 14px 0 5px; }
label .opt { font-weight: 400; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=date], input[type=number] {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible {
  outline: 3px solid #9fd0c2;
  outline-offset: 1px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; }
.chip {
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.chip[aria-pressed="true"], .chip:hover { border-color: var(--accent); color: var(--accent); }

button.primary {
  font: inherit; font-weight: 600; font-size: 16px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  margin-top: 18px;
}
button.primary:hover { background: #185a4b; }
button.primary:disabled { background: #9db8b0; cursor: default; }

button.ghost {
  font: inherit; font-size: 14.5px; font-weight: 500;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }

.status { margin-top: 14px; font-size: 14.5px; color: var(--ink-soft); }
.status.error { color: #a3271f; }

.fallback {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #f0d9a8;
  background: #fdf6e6;
  border-radius: 10px;
  font-size: 14.5px;
  display: none;
}
.fallback code { word-break: break-all; font-size: 13px; }

/* ---------- upload ---------- */
.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--ink-soft);
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease;
}
.drop.dragover, .drop:hover { border-color: var(--accent); color: var(--accent); }
.drop input { display: none; }

/* ---------- instructions ---------- */
ol.steps { padding-left: 22px; margin: 10px 0; }
ol.steps li { margin: 8px 0; }
ol.steps code { background: #f1ede5; border-radius: 5px; padding: 1px 6px; font-size: 14px; }

details.help { margin-top: 12px; font-size: 14.5px; }
details.help summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.help p { color: var(--ink-soft); }

/* ---------- results ---------- */
#results { display: none; }

.spanline {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  font-size: 14.5px; color: var(--ink-soft);
  margin-bottom: 14px;
}
.spanline strong { color: var(--ink); font-weight: 600; }

.notice {
  border: 1px solid #f0d9a8; background: #fdf6e6;
  border-radius: 10px; padding: 12px 14px;
  font-size: 14.5px; margin: 0 0 14px;
}

.bignum { font-family: 'Fraunces', Georgia, serif; font-weight: 650; font-size: 52px; line-height: 1; }
.bignum-label { font-size: 14px; font-weight: 600; color: var(--ink-soft); letter-spacing: .02em; }

/* the month ribbon */
.ribbon {
  display: flex;
  height: 34px;
  border-radius: 8px;
  overflow: hidden;
  margin: 18px 0 10px;
}
.ribbon div { min-width: 0; }

.bandlist { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14.5px; }
.bandlist li { display: flex; align-items: center; gap: 9px; padding: 4px 0; }
.bandlist .sw { width: 13px; height: 13px; border-radius: 4px; flex: none; }
.bandlist .nm { flex: 1; }
.bandlist .pc { font-weight: 600; font-variant-numeric: tabular-nums; }

.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
}
.stat .v { font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 13px; color: var(--ink-soft); }

/* custom bands */
.myrange { border-top: 3px solid var(--accent); }
.bandrow {
  display: grid;
  grid-template-columns: 1fr 86px 86px 34px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.bandrow label { margin: 0 0 4px; font-size: 12.5px; color: var(--ink-soft); }
.bandrow .del {
  border: 0; background: transparent; color: var(--ink-soft);
  font-size: 20px; cursor: pointer; padding: 8px 4px; line-height: 1;
}
.bandrow .del:hover { color: #a3271f; }
@media (max-width: 560px) {
  .bandrow { grid-template-columns: 1fr 70px 70px 30px; }
}

.customresult { margin: 16px 0 4px; }
.customresult .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.customresult .head .nm { font-weight: 600; }
.customresult .head .pc {
  font-family: 'Fraunces', Georgia, serif; font-weight: 650; font-size: 30px;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.meter {
  height: 14px; border-radius: 7px; background: #efece5; overflow: hidden; margin-top: 4px;
}
.meter div { height: 100%; background: var(--b-custom); border-radius: 7px; }
.customresult .sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

.localnote { font-size: 13px; color: var(--ink-soft); margin-top: 14px; }

footer.site {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-soft);
}

@media print {
  header.site, footer.site, .privacy, #getdata, .drop, .presets, button, .bandrow .del { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
