:root {
  --paper: #f7f2e9;
  --paper-deep: #eee6d9;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --ink: #173d41;
  --ink-2: #365c60;
  --muted: #60777a;
  --line: #d9dfda;
  --teal: #155e63;
  --teal-2: #0e4b4f;
  --teal-soft: #dcebea;
  --blue: #4c6f8e;
  --blue-soft: #e1eaf1;
  --coral: #c35d42;
  --coral-soft: #f8e3dc;
  --amber: #97681f;
  --amber-soft: #f4e8ca;
  --danger: #a13e35;
  --danger-soft: #f6dcd8;
  --success: #236b54;
  --success-soft: #dcece4;
  --shadow: 0 14px 40px rgba(23, 61, 65, .08);
  --shadow-sm: 0 5px 18px rgba(23, 61, 65, .07);
  --radius-sm: .65rem;
  --radius: 1rem;
  --radius-lg: 1.4rem;
  --max: 1180px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.55; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--teal) 0 74%, #efb08d 74%); z-index: 1000; }
a { color: var(--teal-2); text-underline-offset: .2em; }
a:hover { color: var(--coral); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, .button, input[type="submit"] { touch-action: manipulation; }
:focus-visible { outline: 3px solid #e59165; outline-offset: 3px; }
.skip-link { position: fixed; top: .5rem; left: .5rem; transform: translateY(-180%); z-index: 2000; padding: .65rem 1rem; background: var(--ink); color: white; border-radius: .5rem; }
.skip-link:focus { transform: none; }
.container { width: min(calc(100% - 2rem), var(--max)); margin-inline: auto; }
.narrow { width: min(calc(100% - 2rem), 720px); margin-inline: auto; }
.site-header { position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(21,94,99,.12); background: rgba(247,242,233,.94); backdrop-filter: blur(14px); }
.header-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.brand { display: inline-flex; align-items: center; flex: 0 1 320px; }
.brand img { display: block; width: 320px; height: auto; }
.header-actions, .main-nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.main-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .75rem; border-radius: .6rem; color: var(--ink-2); font-weight: 650; text-decoration: none; }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--teal-soft); color: var(--teal-2); }
.main-nav a.button { min-height: 38px; color: white; }
.main-nav a.button:hover { background: var(--teal-2); color: white; }
.site-main { min-height: calc(100dvh - 190px); padding: 2rem 0 4rem; }
.site-footer { padding: 2.2rem 0 3rem; border-top: 1px solid var(--line); color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -.025em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); margin: 0 0 1rem; }
h2 { font-size: clamp(1.4rem, 3vw, 2.1rem); margin: 0 0 .85rem; }
h3 { font-size: 1.08rem; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--teal); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.lede { max-width: 66ch; color: var(--ink-2); font-size: clamp(1.05rem, 2vw, 1.25rem); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tabular, .metric-value, time, .glucose-value { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.button, button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .7rem 1rem; border: 1px solid transparent; border-radius: .7rem; background: var(--teal); color: white; font-weight: 750; text-decoration: none; cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease; }
.button:hover, button:hover { background: var(--teal-2); color: white; }
.button-secondary { border-color: #aac0bd; background: transparent; color: var(--teal-2); }
.button-secondary:hover { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-2); }
.button-quiet { background: transparent; color: var(--ink-2); }
.button-quiet:hover { background: var(--paper-deep); color: var(--ink); }
.button-danger { background: var(--danger); }
.button-small { min-height: 38px; padding: .45rem .75rem; font-size: .88rem; }
button:disabled, .button[aria-disabled="true"] { opacity: .48; cursor: not-allowed; }
.button-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }

.card { padding: clamp(1rem, 2.5vw, 1.5rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-flat { box-shadow: none; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-header > :last-child { flex: none; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 1rem; }
.stack-lg { display: grid; gap: 1.6rem; }
.section { margin-top: 2.5rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }

.flash-stack { width: min(calc(100% - 2rem), var(--max)); margin: 1rem auto 0; display: grid; gap: .5rem; }
.flash { padding: .8rem 1rem; border: 1px solid; border-radius: .7rem; background: var(--surface); }
.flash-success { border-color: #89b7a5; background: var(--success-soft); color: #164f3d; }
.flash-error { border-color: #d59b92; background: var(--danger-soft); color: #7a2e28; }
.flash-warning { border-color: #d4b678; background: var(--amber-soft); color: #654612; }
.flash-info { border-color: #9db7c9; background: var(--blue-soft); color: #284c66; }

.hero { display: grid; grid-template-columns: 1.08fr .92fr; gap: clamp(2rem, 7vw, 6rem); align-items: center; padding: clamp(2rem, 7vw, 6rem) 0; }
.hero h1 { max-width: 13ch; }
.hero-copy .button-row { margin-top: 1.5rem; }
.hero-panel { position: relative; padding: 1.4rem; border: 1px solid #cbd8d4; border-radius: 1.6rem; background: var(--surface); box-shadow: var(--shadow); }
.hero-panel::before { content: ""; position: absolute; left: -3px; top: 18%; bottom: 18%; width: 6px; border-radius: 20px; background: var(--teal); }
.demo-status { display: grid; gap: 1rem; }
.demo-reading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.demo-reading strong { display: block; font-size: 2.4rem; line-height: 1; }
.demo-thread { position: relative; display: grid; gap: .9rem; padding-left: 1.6rem; }
.demo-thread::before { content: ""; position: absolute; left: .35rem; top: .35rem; bottom: .35rem; width: 2px; background: #aacbc7; }
.demo-event { position: relative; }
.demo-event::before { content: ""; position: absolute; left: -1.48rem; top: .3rem; width: .65rem; height: .65rem; border: 3px solid var(--surface); border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px #80aaa6; }
.trust-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.trust-strip > div { padding: 1.25rem; background: var(--surface); }

.pet-context { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.pet-identity { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.pet-avatar { width: 64px; height: 64px; flex: none; border: 3px solid var(--surface); border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #aac0bd, var(--shadow-sm); }
.pet-avatar-large { width: 86px; height: 86px; }
.pet-avatar-feature { width: 104px; height: 104px; }
.pet-avatar-link { position: relative; display: inline-grid; flex: none; border-radius: 50%; text-decoration: none; }
.pet-avatar-link-editable:focus-visible { outline-offset: 5px; }
.pet-avatar-link-editable:hover .pet-avatar { box-shadow: 0 0 0 3px var(--teal-soft), var(--shadow); }
.pet-avatar-edit { position: absolute; right: -2px; bottom: 2px; display: grid; place-items: center; width: 30px; height: 30px; border: 3px solid var(--paper); border-radius: 50%; background: var(--teal); color: white; box-shadow: var(--shadow-sm); }
.pet-avatar-edit svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pet-context h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: .25rem; }
.pet-meta { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.pill, .tag { display: inline-flex; align-items: center; min-height: 28px; padding: .25rem .58rem; border-radius: 999px; background: var(--teal-soft); color: var(--teal-2); font-size: .78rem; font-weight: 750; }
.tag-neutral { background: var(--paper-deep); color: var(--ink-2); }
.pet-tabs { display: flex; gap: .35rem; overflow-x: auto; padding: .35rem; margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: .8rem; background: rgba(255,255,255,.55); scrollbar-width: thin; }
.pet-tabs a { flex: none; display: inline-flex; align-items: center; min-height: 42px; padding: .5rem .8rem; border-radius: .55rem; color: var(--ink-2); font-weight: 700; text-decoration: none; }
.pet-tabs a:hover, .pet-tabs a[aria-current="page"] { background: var(--surface-strong); color: var(--teal-2); box-shadow: 0 1px 5px rgba(23,61,65,.1); }

.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.status-card { min-height: 142px; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.status-label { display: block; margin-bottom: .6rem; color: var(--muted); font-size: .77rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.metric-value { display: block; margin-bottom: .3rem; font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 780; line-height: 1.1; }
.status-detail { color: var(--muted); font-size: .84rem; }
.insulin-panel { position: relative; overflow: hidden; border: 2px solid #76a6a2; background: #f6fbfa; }
.insulin-panel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--teal); }
.insulin-layout { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 1.4rem; padding-left: .5rem; }
.insulin-layout > div + div { border-left: 1px solid #c8dcd9; padding-left: 1.4rem; }
.warning-panel { border: 2px solid #d79a67; background: #fff8ed; }
.warning-panel h2, .warning-panel h3 { color: #6f4018; }

.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.quick-action { min-height: 76px; justify-content: flex-start; padding: .9rem; border: 1px solid #b9d1ce; background: var(--surface); color: var(--teal-2); text-align: left; box-shadow: var(--shadow-sm); }
.quick-action:hover { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-2); }
.quick-action span:first-child { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--teal-soft); font-size: 1.2rem; line-height: 1; }
.quick-action:hover span:first-child { background: var(--surface); }

form { margin: 0; }
label, legend { color: var(--ink); font-weight: 700; }
label { display: grid; gap: .35rem; }
input, select, textarea { width: 100%; min-height: 46px; padding: .7rem .75rem; border: 1px solid #aebfbd; border-radius: .62rem; background: var(--surface-strong); color: var(--ink); }
textarea { min-height: 104px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #789092; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(21,94,99,.13); outline: none; }
.field { display: grid; gap: .35rem; }
.field-help { color: var(--muted); font-size: .82rem; font-weight: 450; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .8rem; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 40px; font-weight: 550; }
.check input { width: 20px; min-height: 20px; flex: none; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.auth-card { width: min(100%, 510px); margin: 2.5rem auto; }
.auth-card .brand-mini { display: block; width: 250px; margin-bottom: 1.6rem; }
.section-compact { margin-top: .8rem; }
.verification-resend { margin-top: 1.2rem; }
.verification-resend summary { min-height: 44px; display: flex; align-items: center; color: var(--teal-2); cursor: pointer; font-weight: 700; }

.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem; align-items: start; }
.account-photo-preview { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.account-photo-preview h2, .account-photo-preview p { margin-bottom: .25rem; }
.account-pet-avatar { width: 104px; height: 104px; }
.pet-avatar-placeholder { display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-2); font-size: 2.2rem; font-weight: 800; }
.install-account-card { border-color: #9fc4c0; background: #eff8f5; }

.install-prompt { position: fixed; right: 1rem; bottom: 1rem; z-index: 500; display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: .8rem; width: min(calc(100% - 2rem), 560px); padding: .85rem 2.8rem .85rem .85rem; border: 1px solid #95bcb8; border-radius: 1rem; background: rgba(255,253,249,.98); box-shadow: 0 18px 50px rgba(17,45,48,.24); backdrop-filter: blur(18px); }
.install-prompt[hidden] { display: none; }
.install-prompt-icon { width: 46px; height: 46px; }
.install-prompt-icon img { display: block; width: 100%; height: 100%; }
.install-prompt-copy { display: grid; gap: .1rem; font-size: .86rem; line-height: 1.3; }
.install-prompt-copy span { color: var(--muted); }
.install-prompt-close { position: absolute; top: .25rem; right: .3rem; min-width: 40px; min-height: 40px; padding: 0; background: transparent; color: var(--muted); font-size: 1.45rem; }
.install-prompt-close:hover { background: var(--paper-deep); color: var(--ink); }

dialog { width: min(calc(100% - 1.25rem), 620px); max-height: min(88dvh, 860px); padding: 0; border: 0; border-radius: 1.2rem; background: var(--surface); color: var(--ink); box-shadow: 0 26px 90px rgba(17,45,48,.28); }
dialog::backdrop { background: rgba(12,37,39,.62); backdrop-filter: blur(2px); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.dialog-header h2 { margin: 0; font-size: 1.3rem; }
.dialog-close { min-width: 44px; padding: .45rem; background: transparent; color: var(--ink); font-size: 1.5rem; }
.dialog-body { padding: 1.2rem; }

.chart-card { overflow: hidden; }
.chart-wrap { position: relative; min-height: 330px; padding: .5rem 0; overflow-x: auto; }
.chart-svg { display: block; width: 100%; min-width: 660px; height: 330px; }
.chart-grid { stroke: #dce3de; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-line { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-insulin-line { stroke: #c35d42; stroke-width: 1.5; stroke-dasharray: 4 5; opacity: .75; }
.chart-insulin-marker { fill: #c35d42; stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.chart-insulin-marker:hover, .chart-insulin-marker:focus { fill: #923e2c; outline: none; }
.chart-point { fill: var(--surface); stroke: var(--teal); stroke-width: 3; cursor: pointer; }
.chart-point:focus, .chart-point:hover { fill: #f0a47d; stroke-width: 4; outline: none; }
.chart-tooltip { position: absolute; z-index: 5; display: none; max-width: 220px; padding: .55rem .7rem; border-radius: .55rem; background: var(--ink); color: white; font-size: .8rem; box-shadow: var(--shadow); pointer-events: none; }
.chart-tooltip.is-visible { display: block; }
.chart-disclosure { padding-top: .35rem; border-top: 1px solid var(--line); }
.chart-disclosure > summary { display: flex; align-items: center; min-height: 44px; width: fit-content; color: var(--teal-2); cursor: pointer; }
.range-nav { display: flex; align-items: center; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; }
.range-nav a { flex: none; padding: .4rem .65rem; border-radius: .5rem; color: var(--ink-2); font-size: .85rem; font-weight: 700; text-decoration: none; }
.range-nav a[aria-current="true"], .range-nav a:hover { background: var(--teal-soft); color: var(--teal-2); }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 1rem; overflow: hidden; border: 1px solid var(--line); border-radius: .75rem; background: var(--line); }
.metric-strip > div { padding: .75rem; background: var(--surface); }
.metric-strip strong { display: block; font-size: 1.2rem; }

.timeline { --timeline-gutter: 1rem; position: relative; display: grid; gap: .15rem; margin: 0; padding: 0 var(--timeline-gutter); list-style: none; }
.timeline::before { content: ""; position: absolute; left: calc(var(--timeline-gutter) + 1.05rem); top: 1rem; bottom: 1rem; width: 2px; background: #b7ceca; }
.timeline-item { position: relative; display: grid; grid-template-columns: 2.2rem 1fr; gap: .8rem; padding: .85rem 0; }
.timeline-node { z-index: 1; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 4px solid var(--surface); border-radius: 50%; background: var(--teal); color: white; font-size: .7rem; font-weight: 800; box-shadow: 0 0 0 1px #98b9b5; }
.timeline-node[data-type="insulin"] { background: var(--coral); }
.timeline-node[data-type="ketone"], .timeline-node[data-type="health"] { background: var(--amber); }
.timeline-node[data-type="note"], .timeline-node[data-type="feeding"], .timeline-node[data-type="water"] { background: var(--blue); }
.timeline-content { min-width: 0; padding: .15rem 0 .85rem; border-bottom: 1px solid var(--line); }
.timeline-title { display: flex; justify-content: space-between; gap: 1rem; }
.timeline-title strong { overflow-wrap: anywhere; }
.timeline-meta { color: var(--muted); font-size: .82rem; }
.timeline-detail { margin: .45rem 0 0; color: var(--ink-2); white-space: pre-wrap; }
.delete-entry { margin-top: .65rem; }
.delete-entry summary { width: fit-content; min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.delete-entry[open] { padding: .8rem; border: 1px solid #d8aaa4; border-radius: var(--radius-sm); background: var(--danger-soft); }
.delete-entry[open] summary { color: var(--danger); font-weight: 700; }
.delete-entry form { margin-top: .5rem; }
.delete-entry .button-danger { width: fit-content; }
.filter-bar { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: rgba(255,255,255,.5); }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .75rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #edf3f0; color: var(--ink-2); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.cycle-cell { min-width: 270px; }
.cycle-dose { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.reading-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.reading-chip { display: inline-flex; gap: .3rem; align-items: baseline; padding: .3rem .45rem; border: 1px solid #b9cbc8; border-radius: .45rem; background: white; font-size: .8rem; }

.glucose-glance-card .filter-bar { margin-bottom: 1rem; }
.glucose-legend { display: flex; align-items: center; gap: .45rem .65rem; flex-wrap: wrap; margin: .25rem 0 1rem; font-size: .76rem; font-variant-numeric: tabular-nums; }
.glucose-legend-item { display: inline-flex; align-items: center; gap: .3rem; font-weight: 720; white-space: nowrap; }
.glucose-legend-item > span { width: 1.05rem; height: 1.05rem; border: 1px solid rgba(18, 39, 41, .28); border-radius: .22rem; background: var(--band-bg); }
.band-critical-low { --band-bg: #41e34f; --band-text: #102d17; }
.band-low { --band-bg: #087b37; --band-text: #ffffff; }
.band-reference { --band-bg: #315fce; --band-text: #ffffff; }
.band-raised { --band-bg: #f1dc25; --band-text: #272707; }
.band-high { --band-bg: #e64bd8; --band-text: #32102f; }
.band-very-high { --band-bg: #c92c2c; --band-text: #ffffff; }
.band-critical-high { --band-bg: #202020; --band-text: #ffffff; }
.glucose-glance-wrap { width: 100%; overflow: auto; border: 1px solid #b8c6c3; border-radius: .75rem; background: #cdd6d3; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.glucose-glance-wrap:focus-visible { outline-offset: 4px; }
.glucose-glance-table { min-width: 1180px; border-collapse: separate; border-spacing: 1px; background: #cdd6d3; font-variant-numeric: tabular-nums; }
.glucose-glance-table th, .glucose-glance-table td { height: 64px; padding: .2rem; border: 0; text-align: center; vertical-align: middle; }
.glucose-glance-table thead th { height: 38px; padding: .35rem .2rem; background: #e5ece9; color: var(--ink-2); font-size: .73rem; letter-spacing: .025em; text-transform: none; }
.glucose-glance-table .glance-group-row th { height: 32px; background: #dce7e3; }
.glucose-glance-table .glance-group-row th[rowspan] { vertical-align: middle; }
.glucose-glance-table .glance-hours-heading { color: var(--teal-2); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.glucose-glance-table tbody th { background: #f5f7f4; }
.glucose-glance-table .glance-sticky-date { position: sticky; left: 0; z-index: 3; width: 78px; min-width: 78px; box-shadow: 2px 0 0 #b8c6c3; }
.glucose-glance-table .glance-sticky-cycle { position: sticky; left: 79px; z-index: 3; width: 58px; min-width: 58px; box-shadow: 2px 0 0 #b8c6c3; }
.glance-sticky-date span, .glance-sticky-date small, .glance-sticky-cycle strong, .glance-sticky-cycle small { display: block; }
.glance-sticky-date span { font-size: .85rem; }
.glance-sticky-date small, .glance-sticky-cycle small { color: var(--muted); font-size: .67rem; font-weight: 650; }
.glance-sticky-cycle strong { color: var(--teal-2); font-size: .78rem; letter-spacing: .05em; }
.glance-reading-cell { width: 66px; min-width: 66px; background: #f8faf8; }
.glance-dose-cell { width: 62px; min-width: 62px; background: #f6d8ca; color: #723522; }
.glance-dose-cell strong, .glance-dose-cell small { display: block; }
.glance-dose-cell strong { font-size: 1rem; }
.glance-dose-cell small { overflow: hidden; color: #723522; font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.glucose-reading-box { display: grid; place-items: center; min-width: 58px; min-height: 56px; padding: .22rem .12rem; border: 1px solid rgba(13, 32, 34, .28); border-radius: .3rem; background: var(--band-bg); color: var(--band-text); box-shadow: inset 0 1px 0 rgba(255,255,255,.22); line-height: 1.05; }
.glucose-reading-box + .glucose-reading-box { margin-top: .2rem; }
.glucose-reading-box strong, .glucose-reading-box small { display: block; }
.glucose-reading-box strong { font-size: 1rem; font-weight: 820; }
.glucose-reading-box small { margin-top: .18rem; font-size: .62rem; font-weight: 750; }
.glance-empty { color: #a7b2af; }
.glance-scroll-hint { margin: .55rem 0 0; }

.empty-state { padding: 2rem; border: 1px dashed #9fb7b4; border-radius: var(--radius); background: rgba(255,255,255,.4); text-align: center; }
.empty-state h2, .empty-state h3 { margin-bottom: .4rem; }
.disclaimer { padding: .9rem 1rem; border-left: 4px solid var(--blue); background: var(--blue-soft); color: #284c66; font-size: .9rem; }
.glucose-band { display: inline-flex; align-items: center; gap: .35rem; }
.glucose-band::before { content: ""; width: .65rem; height: .65rem; border: 1px solid rgba(18,39,41,.25); border-radius: 50%; background: var(--band-bg, #999); }

.share-banner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; padding: .9rem 1rem; border-radius: .8rem; background: var(--teal); color: white; }
.share-banner p { margin: 0; }
.share-link-box { display: grid; gap: .5rem; padding: 1rem; border: 2px solid #70a49f; border-radius: .8rem; background: #eef8f5; }
.share-link-box code { overflow-wrap: anywhere; color: var(--ink); }
.public-header { padding: 1.5rem 0; border-bottom: 1px solid var(--line); }
.public-header .brand { width: 250px; }
.mobile-tab-bar { display: none; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { max-width: 720px; }
  .hero-panel { max-width: 680px; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insulin-layout { grid-template-columns: 1fr 1fr; }
  .insulin-layout > div:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid #c8dcd9; padding: 1rem 0 0; }
}

@media (max-width: 680px) {
  .container, .narrow { width: min(calc(100% - 1.1rem), var(--max)); }
  .site-main { padding-top: 1rem; }
  .header-inner { min-height: 88px; gap: .65rem; padding-block: .7rem; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand img { width: clamp(170px, 49vw, 210px); }
  .main-nav { flex: 0 0 auto; flex-wrap: nowrap; gap: .2rem; }
  .main-nav a { min-height: 44px; padding: .45rem .55rem; white-space: nowrap; }
  .main-nav a.button { min-height: 44px; padding-inline: .7rem; font-size: .84rem; }
  .main-nav .nav-hide-mobile { display: none; }
  .grid-2, .grid-3, .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; gap: 1rem; }
  .account-pet-avatar { width: 82px; height: 82px; }
  .status-grid { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .status-card { min-height: 126px; padding: .8rem; }
  .quick-actions { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .quick-action { min-height: 64px; padding: .65rem; font-size: .88rem; }
  .insulin-layout { grid-template-columns: 1fr; gap: 1rem; }
  .insulin-layout > div + div, .insulin-layout > div:nth-child(3) { grid-column: auto; border-left: 0; border-top: 1px solid #c8dcd9; padding: 1rem 0 0; }
  .pet-context { display: grid; gap: .75rem; }
  .pet-identity { align-items: flex-start; gap: .85rem; }
  .pet-avatar-feature { width: 92px; height: 92px; }
  .pet-avatar-large { width: 76px; height: 76px; }
  .pet-avatar-edit { width: 28px; height: 28px; }
  .pet-context .button-row { width: 100%; }
  .glucose-glance-card .card-header { display: grid; }
  .glucose-glance-card .range-nav { width: 100%; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .trust-strip { grid-template-columns: 1fr; }
  .timeline-title { display: grid; gap: .15rem; }
  .check-grid { grid-template-columns: 1fr; }
  .form-actions { position: sticky; bottom: 0; margin-inline: -1.2rem; padding: .8rem 1.2rem calc(.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
  dialog { max-height: 94dvh; }
  .has-mobile-tab-bar .site-main { padding-bottom: calc(6.4rem + env(safe-area-inset-bottom)); }
  .has-mobile-tab-bar .site-footer { padding-bottom: calc(6.8rem + env(safe-area-inset-bottom)); }
  .install-prompt { right: .55rem; bottom: calc(5.4rem + env(safe-area-inset-bottom)); left: .55rem; grid-template-columns: 40px minmax(0, 1fr) auto; width: auto; padding: .7rem 2.5rem .7rem .7rem; }
  body:not(.has-mobile-tab-bar) .install-prompt { bottom: calc(.7rem + env(safe-area-inset-bottom)); }
  .install-prompt-icon { width: 40px; height: 40px; }
  .install-prompt-copy { font-size: .78rem; }
  .mobile-tab-bar {
    position: fixed;
    right: .55rem;
    bottom: .55rem;
    left: .55rem;
    z-index: 200;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 66px;
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
    border: 1px solid rgba(21,94,99,.18);
    border-radius: 1.15rem;
    background: rgba(255,253,249,.96);
    box-shadow: 0 12px 36px rgba(17,45,48,.2);
    backdrop-filter: blur(18px);
  }
  .mobile-tab {
    display: flex;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .12rem;
    padding: .25rem .12rem;
    border-radius: .75rem;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 750;
    line-height: 1.1;
    text-decoration: none;
    touch-action: manipulation;
  }
  .mobile-tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-tab:hover, .mobile-tab[aria-current="page"] { background: var(--teal-soft); color: var(--teal-2); }
  .mobile-tab-record svg { box-sizing: content-box; padding: .18rem; border-radius: 50%; background: var(--teal); color: white; stroke-width: 2.2; }
  .record-event-section { scroll-margin-top: 6rem; }
}

@media (max-width: 400px) {
  .status-grid, .quick-actions { grid-template-columns: 1fr; }
  .status-card { min-height: auto; }
  .header-inner { min-height: 82px; gap: .35rem; }
  .brand img { width: clamp(155px, 48vw, 185px); }
  .main-nav a { padding-inline: .45rem; font-size: .84rem; }
  .main-nav a.button { padding-inline: .6rem; font-size: .8rem; }
  .install-prompt { grid-template-columns: 36px minmax(0, 1fr); }
  .install-prompt > [data-install-action] { grid-column: 2; width: fit-content; }
  .install-prompt-icon { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  :root { --paper: white; --surface: white; --line: #bbb; }
  body::before, .site-header, .site-footer, .pet-tabs, .quick-actions, .button, button, .range-nav, .filter-bar, dialog, .no-print { display: none !important; }
  .site-main { padding: 0; }
  .container, .narrow { width: 100%; max-width: none; }
  .card, .status-card { break-inside: avoid; box-shadow: none; }
  .chart-wrap { overflow: visible; }
  .chart-svg { min-width: 0; }
  a { color: inherit; text-decoration: none; }
  h1 { font-size: 2rem; }
}
