:root {
    color-scheme: dark;
    --health-bg: #08111d;
    --health-surface: #0f1b2a;
    --health-surface-raised: #152438;
    --health-surface-soft: rgba(255, 255, 255, .045);
    --health-border: rgba(148, 163, 184, .2);
    --health-text: #f1f5f9;
    --health-muted: #9fb0c4;
    --health-primary: #2dd4bf;
    --health-primary-strong: #14b8a6;
    --health-primary-soft: rgba(45, 212, 191, .12);
    --health-info: #60a5fa;
    --health-warning: #fbbf24;
    --health-danger: #fb7185;
    --health-shadow: 0 22px 60px rgba(0, 0, 0, .28);
    --health-radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--health-text);
    background:
        radial-gradient(circle at 12% 0%, rgba(45, 212, 191, .13), transparent 30rem),
        radial-gradient(circle at 90% 14%, rgba(96, 165, 250, .09), transparent 28rem),
        var(--health-bg);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--health-primary) 55%, transparent);
    outline-offset: 3px;
}
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--health-primary); color: #042f2e; font-weight: 800; }
.skip-link:focus { top: 12px; }
.top { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--health-border); background: color-mix(in srgb, var(--health-bg) 86%, transparent); backdrop-filter: blur(18px); }
.topin { max-width: 1440px; min-height: 68px; margin: auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--health-text); text-decoration: none; font-size: 20px; font-weight: 900; letter-spacing: -.03em; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: linear-gradient(135deg, var(--health-primary), var(--health-info)); color: #042f2e; box-shadow: 0 8px 24px rgba(45, 212, 191, .22); }
.brand b { color: var(--health-primary); }
.top-actions, .stage-actions, .history-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account { display: inline-flex; align-items: center; gap: 7px; color: var(--health-primary); font-size: 13px; font-weight: 700; }
.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--health-border); border-radius: 12px; color: var(--health-text); background: var(--health-surface-soft); font-weight: 750; font-size: 13px; cursor: pointer; text-decoration: none; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--health-primary); background: var(--health-primary-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { border-color: color-mix(in srgb, var(--health-primary) 60%, transparent); background: var(--health-primary-soft); color: var(--health-primary); }
.btn.danger:hover:not(:disabled) { border-color: var(--health-danger); color: var(--health-danger); background: color-mix(in srgb, var(--health-danger) 10%, transparent); }
.icon-btn { width: 42px; padding: 0; font-size: 18px; }
.page { max-width: 1440px; margin: auto; padding: 32px 24px 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 360px); gap: 22px; align-items: end; margin-bottom: 24px; }
.kicker { color: var(--health-primary); font-size: 12px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.title { max-width: 760px; margin: 7px 0 9px; font-size: clamp(30px, 5vw, 52px); line-height: 1.05; letter-spacing: -.045em; }
.subtitle { max-width: 820px; margin: 0; color: var(--health-muted); font-size: 15px; }
.model { display: flex; align-items: center; gap: 12px; min-height: 74px; padding: 14px; border: 1px solid var(--health-border); border-radius: 16px; background: color-mix(in srgb, var(--health-surface) 88%, transparent); box-shadow: var(--health-shadow); }
.model-indicator { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: var(--health-warning); box-shadow: 0 0 0 5px color-mix(in srgb, var(--health-warning) 14%, transparent); }
.model[data-state="ready"] .model-indicator { background: var(--health-primary); box-shadow: 0 0 0 5px var(--health-primary-soft); }
.model[data-state="error"] .model-indicator { background: var(--health-danger); }
.model-copy { display: grid; gap: 3px; min-width: 0; }
.model-copy strong { font-size: 13px; }
.model-copy span { color: var(--health-muted); font-size: 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .8fr); gap: 20px; align-items: start; }
.card { border: 1px solid var(--health-border); border-radius: var(--health-radius); background: var(--health-surface); box-shadow: var(--health-shadow); }
.stage-card { overflow: hidden; }
.stage-head, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--health-border); background: var(--health-surface-raised); }
.section-title { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 15px; }
.section-title .symbol { color: var(--health-primary); }
.stage { position: relative; display: grid; min-height: 540px; aspect-ratio: 16 / 10; overflow: hidden; background: #020617; }
.body-video, .body-overlay { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: contain; transform: scaleX(-1); }
.body-overlay { pointer-events: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; background: radial-gradient(circle, rgba(45,212,191,.1), transparent 50%); }
.empty-content { max-width: 460px; display: grid; justify-items: center; gap: 10px; color: var(--health-muted); }
.empty-icon { display: grid; width: 62px; height: 62px; place-items: center; border: 1px solid var(--health-border); border-radius: 20px; background: var(--health-surface-soft); color: var(--health-primary); font-size: 28px; }
.empty-content strong { color: var(--health-text); font-size: 17px; }
.empty-content p { margin: 0; }
.stage-foot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 16px; border-top: 1px solid var(--health-border); }
.tag { min-width: 0; padding: 10px; border: 1px solid var(--health-border); border-radius: 13px; background: var(--health-surface-soft); text-align: center; }
.tag span { display: block; color: var(--health-muted); font-size: 11px; }
.tag strong { display: block; margin-top: 2px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.side { display: grid; gap: 16px; }
.panel { padding: 18px; }
.panel h2, .plan-panel h2, .history-panel h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--health-text); font-size: 14px; }
.panel h2 .symbol, .plan-panel h2 .symbol, .history-panel h2 .symbol { color: var(--health-primary); }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric { min-width: 0; padding: 13px; border: 1px solid var(--health-border); border-radius: 14px; background: var(--health-surface-soft); }
.metric span { display: block; color: var(--health-muted); font-size: 12px; }
.metric strong { display: block; margin-top: 3px; font-size: 24px; letter-spacing: -.03em; }
.metric small { margin-left: 4px; color: var(--health-muted); font-size: 11px; font-weight: 500; }
.note { margin: 10px 0 0; color: var(--health-muted); font-size: 12px; line-height: 1.55; }
.capture-status { padding: 10px 12px; border-radius: 12px; background: var(--health-primary-soft); color: var(--health-primary); font-weight: 750; }
.adjust-toggle { width: 100%; margin-top: 14px; }
.manual-measures { margin-top: 12px; padding: 14px; border: 1px solid var(--health-border); border-radius: 14px; background: var(--health-surface-soft); }
.manual-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.manual-fields .field { margin-bottom: 0; }
.manual-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { color: var(--health-muted); font-size: 12px; font-weight: 750; }
.field input:not([type="range"]), .field select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--health-border); border-radius: 12px; color: var(--health-text); background: color-mix(in srgb, var(--health-bg) 65%, var(--health-surface)); }
.field input:focus, .field select:focus { border-color: var(--health-primary); }
.field input[type="range"] { width: 100%; accent-color: var(--health-primary); }
.callout { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 14px; border: 1px solid; border-radius: 15px; font-size: 12px; line-height: 1.55; }
.callout .symbol { font-size: 20px; }
.callout.privacy { border-color: color-mix(in srgb, var(--health-primary) 35%, transparent); background: var(--health-primary-soft); color: color-mix(in srgb, var(--health-primary) 80%, white); }
.callout.disclaimer { border-color: color-mix(in srgb, var(--health-warning) 35%, transparent); background: color-mix(in srgb, var(--health-warning) 8%, transparent); color: color-mix(in srgb, var(--health-warning) 78%, white); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.plan-panel, .history-panel { padding: 18px; }
.list { display: grid; gap: 9px; }
.item { position: relative; padding: 11px 12px 11px 36px; border: 1px solid var(--health-border); border-radius: 13px; background: var(--health-surface-soft); font-size: 13px; }
.item::before { content: "✓"; position: absolute; left: 12px; color: var(--health-primary); font-weight: 900; }
.history-panel { margin-top: 20px; }
.history-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.history-head h2 { margin-bottom: 2px; }
.history-status { min-height: 18px; color: var(--health-muted); font-size: 12px; }
.history-status[data-state="error"] { color: var(--health-danger); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.history-card { overflow: hidden; border: 1px solid var(--health-border); border-radius: 15px; background: var(--health-surface-soft); }
.history-photo { width: 100%; height: 150px; display: block; object-fit: cover; background: #020617; }
.history-body { padding: 12px; display: grid; gap: 5px; }
.history-metrics { font-size: 13px; font-weight: 800; }
.history-category { color: var(--health-primary); font-size: 12px; }
.history-meta { color: var(--health-muted); font-size: 11px; }
.empty-state { grid-column: 1 / -1; padding: 32px 18px; border: 1px dashed var(--health-border); border-radius: 15px; color: var(--health-muted); text-align: center; }
.skeleton { min-height: 188px; border-radius: 15px; background: linear-gradient(90deg, var(--health-surface-soft), rgba(148,163,184,.14), var(--health-surface-soft)); background-size: 200% 100%; animation: health-shimmer 1.25s infinite; }
.footer { margin: 28px 0 6px; color: var(--health-muted); font-size: 11px; text-align: center; }
.symbol { font-family: "Material Symbols Outlined"; font-size: 20px; font-weight: normal; line-height: 1; }
@keyframes health-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (prefers-color-scheme: light) {
    :root { color-scheme: light; --health-bg: #f5f8fb; --health-surface: #ffffff; --health-surface-raised: #f8fafc; --health-surface-soft: rgba(15, 23, 42, .035); --health-border: rgba(15, 23, 42, .13); --health-text: #102033; --health-muted: #52657b; --health-shadow: 0 18px 45px rgba(15, 23, 42, .08); }
}
html[data-theme="dark"] { color-scheme: dark; --health-bg:#08111d; --health-surface:#0f1b2a; --health-surface-raised:#152438; --health-surface-soft:rgba(255,255,255,.045); --health-border:rgba(148,163,184,.2); --health-text:#f1f5f9; --health-muted:#9fb0c4; --health-shadow:0 22px 60px rgba(0,0,0,.28); }
html[data-theme="light"] { color-scheme: light; --health-bg:#f5f8fb; --health-surface:#fff; --health-surface-raised:#f8fafc; --health-surface-soft:rgba(15,23,42,.035); --health-border:rgba(15,23,42,.13); --health-text:#102033; --health-muted:#52657b; --health-shadow:0 18px 45px rgba(15,23,42,.08); }
@media (max-width: 1100px) { .layout, .hero { grid-template-columns: 1fr; } .stage { min-height: 440px; } }
@media (max-width: 720px) {
    .topin { min-height: 60px; padding: 8px 14px; }
    .account { display: none; }
    .page { padding: 22px 14px 18px; }
    .hero { gap: 16px; }
    .title { font-size: 34px; }
    .subtitle { font-size: 14px; }
    .stage-head, .history-head { align-items: stretch; flex-direction: column; }
    .stage-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .stage-actions .primary { grid-column: 1 / -1; }
    .stage { min-height: 360px; aspect-ratio: 3 / 4; }
    .plans { grid-template-columns: 1fr; gap: 14px; }
    .history-actions .btn { flex: 1; }
    .history-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
}
@media (max-width: 420px) { .metrics { grid-template-columns: 1fr 1fr; } .manual-fields, .manual-actions { display: grid; grid-template-columns: 1fr; } .stage-foot { gap: 6px; padding-inline: 10px; } .tag { padding-inline: 5px; } }

/* Mobile camera stabilization: keep preview/overlay locked to one viewport box and avoid scroll anchoring while metrics update. */
.stage-card, .stage { overflow-anchor: none; }
.stage { isolation: isolate; contain: layout paint; }
.body-video, .body-overlay { position: absolute; inset: 0; display: block; }
.body-video { background: #020617; }
body.health-camera-active { overflow-x: hidden; }
@media (max-width: 720px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    .page { width: 100%; padding-inline: 10px; }
    .hero { margin-bottom: 16px; }
    .model { min-height: 66px; }
    .stage-card { width: 100%; max-width: 100%; transform: translateZ(0); }
    .stage-head { padding: 12px; gap: 10px; }
    .stage-actions { gap: 7px; }
    .stage-actions .btn { min-width: 0; padding-inline: 10px; }
    .stage { width: 100%; height: clamp(420px, 64dvh, 620px); min-height: 0; aspect-ratio: auto; }
    .body-video, .body-overlay { width: 100%; height: 100%; object-fit: contain; }
    .stage-foot { min-height: 70px; }
    .tag strong { min-height: 20px; }
}
@media (max-width: 420px) {
    .stage { height: clamp(400px, 62dvh, 560px); }
    .title { font-size: clamp(28px, 9vw, 34px); }
    .brand { font-size: 18px; }
    .top-actions .btn.primary { padding-inline: 10px; }
}
@supports not (height: 1dvh) {
    @media (max-width: 720px) { .stage { height: 64vh; } }
}
