/* iGluPal website (design A, "The Reading"). Light by default, dark from the
   system setting or the theme button ([data-theme] on <html> wins). Numbers
   follow the unit switch ([data-unit] on <html>). */
:root {
  --bg: #FBFAF8; --surface: #FFFFFF; --ink: #1C1A1E; --muted: #5E5A60; --line: #E7E3DF;
  --chip: #F0ECE8; --red: #C4362C; --red-soft: #FBEAE7; --red-on-ink: #FF8A7E; --device: #1C1A1E;
  --shadow: rgba(40,20,20,.25);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141215; --surface: #1D1A1E; --ink: #F4F1EE; --muted: #ABA5A8; --line: #322D31;
    --chip: #28242A; --red: #FF6B5E; --red-soft: #3A1F1D; --red-on-ink: #C4362C; --device: #3A353B;
    --shadow: rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141215; --surface: #1D1A1E; --ink: #F4F1EE; --muted: #ABA5A8; --line: #322D31;
  --chip: #28242A; --red: #FF6B5E; --red-soft: #3A1F1D; --red-on-ink: #C4362C; --device: #3A353B;
  --shadow: rgba(0,0,0,.5);
  color-scheme: dark;
}

/* Theme-only and unit-only elements */
.only-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-dark { display: revert !important; }
  :root:not([data-theme="light"]) .only-light { display: none !important; }
}
:root[data-theme="dark"] .only-dark { display: revert !important; }
:root[data-theme="dark"] .only-light { display: none !important; }
.only-mmol { display: none !important; }
:root[data-unit="mmol"] .only-mmol { display: block !important; }
:root[data-unit="mmol"] .only-mgdl { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink); overflow-x: hidden;
  font: 17px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased; transition: background .3s, color .3s;
}
:lang(ar) body, body:lang(ar) { font-family: Inter, "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 20px; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; border-radius: 8px; }
h1, h2, .big-num, .brand span, .live-num, .stat-val .num, .est-avg .num, .est-out .num, .val, #draft, .lp-est, .report-head strong {
  font-family: "Bricolage Grotesque", Inter, sans-serif;
}
:lang(ar) :is(h1, h2, .big-num, .live-num, .lp-est), :lang(hi) :is(h1, h2, .lp-est), :lang(th) :is(h1, h2, .lp-est),
:lang(ja) :is(h1, h2, .lp-est), :lang(ko) :is(h1, h2, .lp-est), :lang(zh-Hans) :is(h1, h2, .lp-est), :lang(zh-Hant) :is(h1, h2, .lp-est),
:lang(ru) :is(h1, h2, .lp-est) {
  font-family: Inter, -apple-system, "Noto Sans", sans-serif; letter-spacing: -0.01em;
}
h2 { margin: 0; font-weight: 800; font-size: clamp(32px, 4vw, 52px); line-height: 1.05; letter-spacing: -0.03em; overflow-wrap: break-word; }
.eyebrow { margin: 0 0 16px; font-size: 14px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.lead { margin: 20px 0 0; max-width: 32em; color: var(--muted); }
.big-num { margin: 0; font-weight: 800; font-size: clamp(72px, 12vw, 120px); line-height: .8; color: var(--red); }
.big-num + h2 { margin-top: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; }

/* Header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-inline-end: auto; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand span { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.nav { display: flex; gap: 22px; font-size: 15px; font-weight: 500; }
.nav a { text-decoration: none; padding: 10px 0; }
.nav a:hover { color: var(--red); }
.controls { display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--chip); flex-wrap: nowrap; }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.lang-wrap { position: relative; display: inline-flex; min-width: 0; }
.lang-wrap::after { content: ""; position: absolute; inset-inline-end: 15px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.lang-select { -webkit-appearance: none; appearance: none; height: 44px; width: 100%; max-width: 11rem; padding-block: 0; padding-inline: 14px 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; line-height: 1.2; cursor: pointer; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
@media (max-width: 760px) {
  .nav { display: none; }
}
@media (max-width: 520px) {
  .topbar { gap: 10px; }
  .brand { margin-inline-end: 0; }
  .controls { width: 100%; justify-content: space-between; gap: 8px; }
  .lang-wrap { flex: 1; }
  .lang-select { max-width: none; }
  .units button { padding: 0 10px; }
}

/* Hero */
.hero { display: flex; flex-wrap: wrap; gap: 56px; align-items: center; padding-block: clamp(24px, 6vw, 56px) clamp(48px, 9vw, 80px); }
.hero-copy { flex: 1 1 440px; min-width: 0; }
.hero h1 { margin: 0; font-weight: 800; font-size: clamp(42px, 5.6vw, 78px); line-height: .98; letter-spacing: -0.035em; overflow-wrap: break-word; }
.hero-sub { margin: 24px 0 0; max-width: 30em; font-size: 19px; color: var(--muted); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin-top: 32px; }
.cta-row > span { font-size: 15px; color: var(--muted); }
.store-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 20px; text-align: start; line-height: 1.25; border-radius: 14px; background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 600; }
.store-btn:hover { opacity: .9; }
.store-btn svg { flex: none; }
.store-btn.on-red { background: #FFFFFF; color: #A52A21; margin-top: 24px; }

/* Logger */
.logger { flex: 1 1 400px; min-width: 0; max-width: 520px; margin-inline: auto; padding: clamp(18px, 5vw, 28px); box-shadow: 0 30px 60px -30px var(--shadow); }
.logger-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.logger-head span { font-size: 14px; font-weight: 600; color: var(--muted); }
.logger-head small { font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.step-btn { width: 52px; height: 52px; flex: none; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); font-size: 26px; cursor: pointer; }
.draft { flex: 1; min-width: 0; text-align: center; }
#draft { width: 100%; border: 0; background: transparent; text-align: center; font-weight: 800; font-size: clamp(54px, 15vw, 76px); line-height: 1; color: var(--red); letter-spacing: -0.03em; -moz-appearance: textfield; appearance: textfield; padding: 0; }
#draft::-webkit-outer-spin-button, #draft::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.draft .unit-label { display: block; font-size: 15px; font-weight: 600; color: var(--muted); }
.pill-rows { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.save-btn { width: 100%; min-height: 52px; margin-top: 18px; border: 0; border-radius: 16px; background: var(--red); color: #FFFFFF; font-size: 17px; font-weight: 700; cursor: pointer; }
:root[data-theme="dark"] .save-btn { color: #1C0F0E; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .save-btn { color: #1C0F0E; } }
.live { margin-top: 22px; padding: 18px; border-radius: 18px; background: var(--red-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.live-num { font-weight: 800; font-size: 44px; line-height: 1; color: var(--red); }
.live p { flex: 1; min-width: 180px; margin: 0; font-size: 14px; line-height: 1.45; }
.rows { list-style: none; margin: 18px 0 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rows li.new { animation: rowIn .4s ease-out; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .rows li.new { animation: none; } }
.when { flex: 1; min-width: 0; }
.when small { display: block; font-size: 14px; color: var(--muted); }
.when b { display: block; font-weight: 600; }
.val { font-weight: 700; font-size: 28px; color: var(--red); }
.u { width: 54px; font-size: 13px; color: var(--muted); }

/* Bands */
.band { border-top: 1px solid var(--line); }
.band.alt { background: var(--surface); border-bottom: 1px solid var(--line); }
.band > .wrap { padding-block: clamp(56px, 10vw, 96px); }
.band.alt + .band, .band.alt + .trio { border-top: 0; }
.split { display: flex; flex-wrap: wrap; gap: 56px 64px; align-items: center; }
.split-copy { flex: 1 1 400px; min-width: 0; }
.phones { flex: 1 1 320px; min-width: 0; display: flex; justify-content: center; gap: 20px; padding-bottom: 32px; }
.phone { width: 46%; max-width: 250px; border-radius: 30px; border: 8px solid var(--device); overflow: hidden; background: var(--device); box-shadow: 0 30px 60px -30px var(--shadow); }
.phone img { width: 100%; height: auto; }
.phone.lift { transform: translateY(32px); }

/* Trends */
.trend-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: end; justify-content: space-between; }
.trend-head > div:first-child { max-width: 640px; }
.trend { margin-top: 40px; padding: 24px; background: var(--bg); border-radius: 24px; }
#trend { display: block; width: 100%; height: clamp(150px, 36vw, 260px); }
#trend-avg { stroke: var(--muted); stroke-dasharray: 6 8; stroke-width: 1.5; }
#trend-area { fill: var(--red-soft); }
#trend-line { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linejoin: round; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 16px; margin-top: 24px; }
.stat-label { font-size: 14px; color: var(--muted); }
.stat-val .num { font-weight: 700; font-size: 34px; }
.stat-val small { font-size: 15px; font-weight: 500; color: var(--muted); }
.example { margin: 16px 0 0; font-size: 13px; color: var(--muted); }

/* Estimator */
.estimator { flex: 1 1 400px; min-width: 0; border-radius: 28px; background: var(--ink); color: var(--bg); padding: clamp(22px, 6vw, 36px); }
.estimator label { font-size: 15px; font-weight: 600; opacity: .85; }
.est-avg { margin-top: 4px; }
.est-avg .num { font-weight: 700; font-size: 40px; }
.est-avg small { font-size: 17px; opacity: .75; }
#avg { width: 100%; height: 44px; margin: 12px 0 20px; accent-color: var(--red); cursor: pointer; }
.est-out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.est-out .num { font-weight: 800; font-size: clamp(64px, 18vw, 96px); line-height: .9; color: var(--red-on-ink); }
.est-out span:last-child { font-size: 15px; opacity: .85; }

/* Report */
.report-wrap { flex: 1 1 400px; min-width: 0; display: flex; justify-content: center; }
.report { width: 100%; max-width: 460px; background: #FFFFFF; color: #1C1A1E; border-radius: 6px; padding: clamp(20px, 5vw, 32px) clamp(16px, 5vw, 30px); box-shadow: 0 2px 0 #E7E3DF, 0 40px 70px -35px rgba(40,20,20,.35); transform: rotate(-1.5deg); }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 2px solid #1C1A1E; padding-bottom: 12px; }
.report-head strong { font-size: 20px; }
.report-head img { width: 28px; height: 28px; border-radius: 7px; }
.report [role="table"] { margin-top: 12px; font-size: 14px; }
.report [role="row"] { display: grid; grid-template-columns: 4.2em 1fr auto; gap: 12px; padding: 8px 0; border-top: 1px solid #ECE8E4; }
.report .report-cols { border-top: 0; color: #5E5A60; font-weight: 600; padding-top: 4px; }
.report .r { text-align: end; font-weight: 700; }
.report-foot { margin: 14px 0 0; font-size: 12px; color: #5E5A60; }

/* Trio */
.trio { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 32px; padding-block: clamp(48px, 9vw, 72px); }
.trio svg { color: var(--red); }
.trio h3 { margin: 12px 0 6px; font-size: 19px; }
.trio p { margin: 0; color: var(--muted); }

/* Languages */
.lang-preview { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: clamp(20px, 5vw, 28px); border-radius: 24px; background: var(--red-soft); min-height: 108px; }
.lp-est { font-weight: 800; font-size: clamp(30px, 4vw, 48px); line-height: 1.1; color: var(--red); }
.lp-moment { font-size: 20px; font-weight: 600; }
.lp-open { margin-inline-start: auto; font-weight: 600; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; }
.lp-open[hidden] { display: none; }
.lang-pills { margin-top: 24px; gap: 10px; }

/* Pro */
.pro-wrap { padding-block: 24px clamp(56px, 10vw, 96px); }
.pro { border-radius: 32px; background: #C4362C; color: #FFFFFF; padding: clamp(22px, 5vw, 64px); display: flex; flex-wrap: wrap; gap: 32px 40px; align-items: center; }
.pro > div { flex: 1 1 380px; min-width: 0; }
.pro p { margin: 14px 0 0; font-size: 19px; }
.pro ul { flex: 1 1 240px; min-width: 0; list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 18px; font-weight: 600; }
.pro li { display: flex; gap: 10px; align-items: center; }
.pro li svg { flex: none; }

/* Footer */
.footer { border-top: 1px solid var(--line); }
.footer .wrap { padding-block: 40px 56px; display: flex; flex-wrap: wrap; gap: 16px 24px; justify-content: space-between; font-size: 15px; color: var(--muted); }
.footer p { margin: 0; }
.disclaimer { max-width: 36em; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.footer nav a { min-height: 44px; display: inline-flex; align-items: center; }
.copy { display: flex; align-items: center; gap: 10px; width: 100%; }
.copy img { border-radius: 6px; }

/* Legal pages */
.legal { max-width: 760px; padding-block: 24px 72px; }
.legal h1 { font-size: clamp(32px, 5vw, 44px); line-height: 1.1; letter-spacing: -0.02em; margin: 24px 0 8px; }
.legal h2 { font-size: 22px; letter-spacing: -0.01em; margin: 36px 0 8px; }
.legal li { margin: 6px 0; }
.legal a { color: var(--red); }
.legal .note { padding: 14px 16px; border-radius: 14px; background: var(--red-soft); }
