@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Noto+Sans+TC:wght@400;500;600;700&display=swap');

:root { color-scheme: dark; --bg: #091411; --panel: #101f1b; --panel-soft: #12261f; --text: #edf4ee; --muted: #92a89c; --accent: #c1ed99; --accent-dim: #c1ed9912; --line: #294036; --heart: #e6a4a2; --canvas-bg: #0b1813; }
html[data-theme="light"] { color-scheme: light; --bg: #f0f4ec; --panel: #fcfdf9; --panel-soft: #e8efdf; --text: #1b3025; --muted: #627565; --accent: #3d6b2c; --accent-dim: #3d6b2c0c; --line: #d5dfcd; --heart: #b85050; --canvas-bg: #e4ecde; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; background: var(--bg); color: var(--text); font-family: 'Manrope', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif; -webkit-font-smoothing: antialiased; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
/* Desktop uses a 16:9 canvas; --ui scales its contents independently of the frame width. */
.app { --ui: 0.6cqi; width: min(100%, calc(100dvh * 16 / 9)); height: min(100dvh, 56.25vw); margin: auto; container-type: inline-size; display: flex; flex-direction: column; padding: 0 min(2.5vw, 4.444dvh); }
.exhibit-header { flex: 0 0 calc(9 * var(--ui)); display: flex; justify-content: space-between; align-items: center; gap: calc(2 * var(--ui)); border-bottom: 1px solid var(--line); }
.lab-brands { --brand-ui: calc(1.5 * var(--ui)); display: flex; align-items: center; gap: calc(2 * var(--ui)); min-width: 0; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: calc(1.3 * var(--brand-ui)); min-width: 0; }
.brand-logo { width: calc(5.5 * var(--brand-ui)); height: calc(5.5 * var(--brand-ui)); object-fit: contain; flex-shrink: 0; }
.brand-copy { min-width: 0; }
.brand-line, .partner-lab-line { display: flex; align-items: center; gap: calc(1.2 * var(--brand-ui)); }
.brand-line strong, .partner-lab-line strong { font-size: calc(2.4 * var(--brand-ui)); letter-spacing: -.06em; }
.brand-line span, .partner-lab-name { font-size: calc(1.55 * var(--brand-ui)); font-weight: 600; letter-spacing: .06em; }
.brand-en { margin-top: calc(.25 * var(--brand-ui)); color: var(--muted); font-size: calc(1 * var(--brand-ui)); letter-spacing: .015em; }
.lab-separator { color: var(--muted); font-size: calc(2.4 * var(--brand-ui)); line-height: 1; flex-shrink: 0; }
.partner-lab { flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: calc(.8 * var(--ui)); flex-shrink: 0; }
.lang-switch { display: flex; padding: calc(.3 * var(--ui)); border: 1px solid var(--line); border-radius: calc(2 * var(--ui)); }
.lang-switch button { border: 0; background: transparent; color: var(--muted); font-size: calc(1.2 * var(--ui)); font-weight: 700; border-radius: calc(1.6 * var(--ui)); padding: calc(.65 * var(--ui)) calc(.9 * var(--ui)); }
.lang-switch button.active { background: var(--accent); color: var(--bg); }
.icon-button { background: transparent; color: var(--muted); border: 1px solid var(--line); width: calc(3.6 * var(--ui)); height: calc(3.6 * var(--ui)); border-radius: 50%; display: grid; place-items: center; padding: 0; }
.icon-button .icon { width: calc(1.8 * var(--ui)); height: calc(1.8 * var(--ui)); }
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.stage { flex: 1; min-height: 0; display: grid; grid-template-rows: calc(8 * var(--ui)) minmax(0, 1fr) calc(14 * var(--ui)) calc(14 * var(--ui)); gap: calc(1.4 * var(--ui)); padding-bottom: calc(1.3 * var(--ui)); }
.intro { display: flex; align-items: center; justify-content: space-between; gap: calc(2 * var(--ui)); }
.eyebrow { font-size: calc(1 * var(--ui)); font-weight: 600; letter-spacing: .2em; color: var(--muted); }
h1 { font-size: calc(5.6 * var(--ui)); line-height: 1; letter-spacing: -.065em; font-weight: 500; margin: calc(.65 * var(--ui)) 0 0; }
.title-dot { color: var(--accent); }
.intro-copy { text-align: right; }
.intro-copy h2 { margin: 0 0 calc(.6 * var(--ui)); font-size: calc(2.25 * var(--ui)); font-weight: 500; letter-spacing: .1em; }
.intro-copy p { margin: 0; color: var(--muted); font-size: calc(1.2 * var(--ui)); }
.video-stage { min-height: 0; }
#video-frame { position: relative; width: 100%; height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: calc(2 * var(--ui)); background: radial-gradient(ellipse at 50% 40%, var(--accent-dim), transparent 70%), var(--canvas-bg); }
#video-frame::before { content: ''; position: absolute; inset: 0; opacity: .3; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: calc(5 * var(--ui)) calc(5 * var(--ui)); mask-image: radial-gradient(ellipse, #000, transparent 75%); }
.display-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#videoInput { z-index: 1; }
#overlayCanvas { z-index: 2; pointer-events: none; }
.camera-topbar, .camera-bottom { position: absolute; left: calc(2.4 * var(--ui)); right: calc(2.4 * var(--ui)); z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: calc(1 * var(--ui)); }
.camera-topbar { top: calc(2 * var(--ui)); font-size: calc(1.2 * var(--ui)); }
.camera-label { display: inline-flex; align-items: center; gap: calc(.8 * var(--ui)); background: var(--panel); border: 1px solid var(--line); border-radius: calc(3 * var(--ui)); padding: calc(.65 * var(--ui)) calc(1.1 * var(--ui)); }
.live-dot, .tiny-dot { width: calc(.65 * var(--ui)); height: calc(.65 * var(--ui)); border-radius: 50%; background: var(--muted); flex-shrink: 0; }
[data-camera="live"] .live-dot, .heart-card.is-reading .tiny-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.spo2-card.is-reading .tiny-dot { background: #7ec8e3; box-shadow: 0 0 8px #7ec8e344; }
.camera-tag { color: var(--muted); font-size: calc(1 * var(--ui)); letter-spacing: .12em; }
.camera-placeholder { position: absolute; inset: 10% 0 27%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.face-guide { position: relative; width: calc(12 * var(--ui)); height: calc(13 * var(--ui)); color: var(--accent); opacity: .8; margin-bottom: calc(1.7 * var(--ui)); }
.face-guide svg { height: 100%; width: 100%; stroke: currentColor; fill: none; stroke-width: 1; opacity: .65; }
.face-guide i { position: absolute; width: calc(2.2 * var(--ui)); height: calc(2.2 * var(--ui)); border: solid currentColor; border-width: 1px 0 0 1px; border-radius: calc(.6 * var(--ui)) 0 0; }
.face-guide i:nth-child(2) { right: 0; transform: rotate(90deg); }
.face-guide i:nth-child(3) { bottom: 0; right: 0; transform: rotate(180deg); }
.face-guide i:nth-child(4) { bottom: 0; transform: rotate(270deg); }
.camera-placeholder h3 { font-size: calc(2 * var(--ui)); font-weight: 500; letter-spacing: .1em; margin: 0 0 calc(.6 * var(--ui)); }
.camera-placeholder p { margin: 0; color: var(--muted); font-size: calc(1.35 * var(--ui)); }
#largeStartBtn { position: absolute; z-index: 4; left: 50%; bottom: 15%; transform: translateX(-50%); min-width: calc(20 * var(--ui)); padding: calc(1.25 * var(--ui)) calc(3 * var(--ui)); border: 1px solid var(--accent); border-radius: calc(4 * var(--ui)); background: var(--accent); color: var(--bg); font-size: calc(1.6 * var(--ui)); font-weight: 700; white-space: nowrap; }
#largeStartBtn:hover:enabled { filter: brightness(1.1); box-shadow: 0 0 0 5px var(--accent-dim); }
.camera-bottom { bottom: calc(1.8 * var(--ui)); color: var(--muted); font-size: calc(1.15 * var(--ui)); }
#pauseBtn { border: 1px solid var(--line); border-radius: calc(3 * var(--ui)); padding: calc(.6 * var(--ui)) calc(1.2 * var(--ui)); color: var(--text); background: var(--panel); font-size: calc(1.2 * var(--ui)); }
[data-camera="live"] .camera-bottom > span, [data-camera="live"] .camera-tag { color: #fff; text-shadow: 0 1px 5px #000; }
.metrics { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: calc(1.5 * var(--ui)); min-height: 0; }
.metrics-spo2 { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1fr); }
.metric-card { padding: calc(1.8 * var(--ui)) calc(2.2 * var(--ui)); background: var(--panel); border: 1px solid var(--line); border-radius: calc(1.8 * var(--ui)); display: flex; flex-direction: column; min-width: 0; }
.heart-card, .spo2-card { background: var(--panel-soft); }
.metric-head { display: flex; justify-content: space-between; align-items: center; gap: calc(.5 * var(--ui)); font-size: calc(1.4 * var(--ui)); font-weight: 500; color: var(--muted); }
.metric-head .icon { width: calc(1.9 * var(--ui)); height: calc(1.9 * var(--ui)); color: var(--muted); }
.heart-card .icon { color: var(--heart); }
.spo2-card .icon { color: #7ec8e3; }
.metric-reading { display: flex; align-items: baseline; gap: calc(1 * var(--ui)); flex: 1; padding-top: calc(.9 * var(--ui)); }
.metric-value { font-size: calc(4.8 * var(--ui)); line-height: 1.2; font-weight: 500; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.mood-value { font-size: calc(4.2 * var(--ui)); padding-top: calc(.9 * var(--ui)); letter-spacing: .03em; }
.reading-unit { font-size: calc(1.25 * var(--ui)); color: var(--muted); }
#hrVal.active, #moodVal[data-mood="calm"] { color: var(--accent); }
#spo2Val.active { color: #8fd0c6; }
html[data-theme="light"] #spo2Val.active { color: #1f7a72; }
#moodVal[data-mood="excited"] { color: #d6b878; }
html[data-theme="light"] #moodVal[data-mood="excited"] { color: #896823; }
#moodVal[data-mood="tense"] { color: var(--heart); }
.metric-note { display: flex; align-items: center; gap: calc(.7 * var(--ui)); color: var(--muted); font-size: calc(1.15 * var(--ui)); line-height: 1.4; }
.telemetry-list { display: grid; grid-template-rows: repeat(3, minmax(0, 1fr)); flex: 1; min-height: 0; margin: 0; }
.telemetry-list > div { display: flex; align-items: center; justify-content: space-between; gap: calc(.5 * var(--ui)); }
.telemetry-list > div + div { border-top: 1px solid var(--line); }
.telemetry-list dt { color: var(--muted); font-size: calc(1.4 * var(--ui)); letter-spacing: .04em; }
.telemetry-list dd { margin: 0; color: var(--text); font-size: calc(2.2 * var(--ui)); font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.signals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(1.5 * var(--ui)); min-height: 0; }
.signal-card { border: 1px solid var(--line); border-radius: calc(1.8 * var(--ui)); background: var(--panel); padding: calc(1.5 * var(--ui)); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wave-head { display: flex; align-items: center; justify-content: space-between; gap: calc(.6 * var(--ui)); font-size: calc(1.25 * var(--ui)); font-weight: 500; margin-bottom: calc(1 * var(--ui)); }
.signal-code { color: var(--muted); font-size: calc(1 * var(--ui)); letter-spacing: .05em; }
.wave-body { flex: 1; min-height: 0; border-radius: calc(.8 * var(--ui)); overflow: hidden; background: var(--canvas-bg); }
.wave-body canvas { display: block; width: 100%; height: 100%; }
.wave-caption { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: calc(1 * var(--ui)); padding-top: calc(.8 * var(--ui)); }
.signal-line { height: 2px; width: calc(2.8 * var(--ui)); background: var(--accent); }
.heat-body { display: grid; flex: 1; min-height: 0; place-items: center; }
.heat-square { position: relative; height: 100%; aspect-ratio: 1; max-width: 100%; border-radius: calc(.8 * var(--ui)); overflow: hidden; background: var(--canvas-bg); }
.heat-square canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.app-footer { flex: 0 0 calc(3.5 * var(--ui)); display: flex; align-items: center; justify-content: space-between; gap: calc(1 * var(--ui)); border-top: 1px solid var(--line); font-size: calc(1.05 * var(--ui)); color: var(--muted); padding-bottom: calc(.6 * var(--ui)); }
.privacy-note { display: flex; align-items: center; gap: calc(.7 * var(--ui)); }
.privacy-note .icon { width: calc(1.5 * var(--ui)); height: calc(1.5 * var(--ui)); color: var(--accent); }
#hidden-vis { position: fixed; width: 220px; height: 120px; left: -9999px; top: 0; overflow: hidden; }
#hidden-vis canvas { width: 100%; height: 100%; }
html[data-lang="en"] .brand-line span, html[data-lang="pt"] .brand-line span { font-size: calc(1.15 * var(--brand-ui)); letter-spacing: 0; max-width: calc(28 * var(--brand-ui)); }
html[data-lang="en"] .mood-value, html[data-lang="pt"] .mood-value { font-size: calc(3.3 * var(--ui)); }
html[data-lang="en"] .intro-copy h2, html[data-lang="pt"] .intro-copy h2 { letter-spacing: 0; }
@media (max-aspect-ratio: 4/3) {
    .app { --ui: 1cqi; width: min(100%, calc(100dvh * 8 / 9)); height: 100dvh; padding: 0 min(3.5vw, 3.111dvh); }
    .exhibit-header { flex-basis: auto; min-height: calc(10.5 * var(--ui)); flex-wrap: wrap; gap: calc(1 * var(--ui)); padding: calc(.75 * var(--ui)) 0; }
    .lab-brands { width: 100%; }
    .header-actions { margin-left: auto; }
    .stage { grid-template-rows: calc(11 * var(--ui)) minmax(0, 1fr) calc(18 * var(--ui)) calc(18 * var(--ui)); gap: calc(1.7 * var(--ui)); padding-bottom: calc(1.8 * var(--ui)); }
    .metric-value { font-size: calc(5.5 * var(--ui)); }
    .app-footer { flex-basis: calc(5 * var(--ui)); }
    .display-layer { object-fit: cover; }
}
@media (max-width: 520px) and (max-aspect-ratio: 4/5) {
    .app { width: 100%; height: auto; min-height: 100dvh; padding: 0 4vw; }
    .exhibit-header { flex-basis: auto; flex-wrap: wrap; gap: 8px; padding: 12px 0; }
    .lab-brands { width: 100%; gap: 8px; }
    .brand { flex: 1; gap: 8px; }
    .brand-logo { width: 60px; height: 60px; }
    .brand-line, .partner-lab-line { display: block; }
    .brand-line strong, .partner-lab-line strong { font-size: 27px; }
    .brand-line span { display: block; font-size: 15px; }
    .brand .brand-en { display: none; }
    .lab-separator { font-size: 27px; }
    .partner-lab-name { display: block; font-size: 15px; }
    .partner-lab .brand-en { font-size: 10px; }
    .header-actions { margin-left: auto; }
    .lang-switch button { padding: 7px; font-size: 11px; }
    .icon-button { width: 30px; height: 30px; }
    .icon-button .icon { width: 15px; height: 15px; }
    .stage { flex: none; grid-template-rows: 90px 330px 140px 150px; gap: 12px; padding-bottom: 16px; }
    .eyebrow { font-size: 7px; }
    h1 { font-size: 36px; }
    .intro-copy h2 { font-size: 14px; }
    .intro-copy p { font-size: 10px; max-width: 165px; }
    .camera-topbar, .camera-bottom { font-size: 10px; }
    .camera-tag { font-size: 8px; }
    .camera-label { padding: 5px 9px; }
    .face-guide { width: 85px; height: 95px; margin-bottom: 16px; }
    .camera-placeholder h3 { font-size: 17px; }
    .camera-placeholder p { font-size: 12px; }
    #largeStartBtn { padding: 12px 28px; font-size: 14px; }
    #pauseBtn { font-size: 11px; padding: 6px 10px; }
    .metric-card { padding: 12px 10px; }
    .metric-head { font-size: 11px; }
    .metric-head .icon { width: 14px; height: 14px; }
    .metric-value { font-size: 34px; }
    .mood-value { font-size: 24px; padding-top: 9px; }
    .reading-unit, .metric-note { font-size: 9px; }
    .metrics { grid-template-columns: minmax(0, 2.5fr) minmax(0, 1fr); }
    .metrics-spo2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); }
    .metrics-spo2 .metric-value { font-size: 26px; }
    .metrics-spo2 .metric-head { font-size: 10px; }
    .metrics-spo2 .metric-card { padding: 10px 8px; }
    .signals .metric-card { padding: 12px 7px; }
    .signals .metric-head { flex-wrap: wrap; }
    .signals .metric-value { font-size: 28px; }
    .signals .mood-value { font-size: 22px; }
    .signals .metric-reading { flex-wrap: wrap; align-content: center; gap: 0 4px; }
    .telemetry-list dt { font-size: 9px; }
    .telemetry-list dd { font-size: 13px; }
    .wave-head { font-size: 10px; align-items: start; }
    .signal-code { font-size: 8px; }
    .wave-caption { font-size: 9px; }
    .heat-square { height: auto; width: 100%; }
    .app-footer { min-height: 45px; font-size: 9px; flex-wrap: wrap; }
    .privacy-note .icon { width: 14px; height: 14px; }
    html[data-lang="en"] .brand-line span, html[data-lang="pt"] .brand-line span { font-size: 12px; max-width: 225px; }
    html[data-lang="en"] .mood-value, html[data-lang="pt"] .mood-value { font-size: 14px; }
}
