@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --bg: #f6f3ec;
    --bg-subtle: #ede8dd;
    --surface: #fffdf9;
    --surface-elevated: #ffffff;
    --surface-heart: linear-gradient(145deg, #fff4f2 0%, #fffdf9 68%);
    --surface-camera-idle: radial-gradient(ellipse at 50% 38%, rgba(15, 118, 110, 0.08), transparent 68%), #eeebe2;
    --text: #182924;
    --text-secondary: #435952;
    --muted: #657b73;
    --accent: #0f766e;
    --accent-hover: #0b5d57;
    --accent-soft: rgba(15, 118, 110, 0.11);
    --accent-ring: rgba(15, 118, 110, 0.24);
    --heart: #d94e47;
    --heart-soft: rgba(217, 78, 71, 0.12);
    --heart-ring: rgba(217, 78, 71, 0.28);
    --amber: #b8731a;
    --line: #e2dcd0;
    --line-strong: #cfc7b8;
    --canvas-bg: #f1efe8;
    --pill-bg: rgba(255, 253, 249, 0.88);
    --shadow-sm: 0 2px 10px rgba(24, 41, 36, 0.045);
    --shadow-md: 0 10px 28px rgba(24, 41, 36, 0.075);
    --shadow-cta: 0 10px 24px rgba(15, 118, 110, 0.26);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1715;
    --bg-subtle: #15211e;
    --surface: #172420;
    --surface-elevated: #1d2d28;
    --surface-heart: linear-gradient(145deg, #2a1c1d 0%, #172420 68%);
    --surface-camera-idle: radial-gradient(ellipse at 50% 38%, rgba(56, 184, 164, 0.12), transparent 68%), #111c19;
    --text: #f2f6f3;
    --text-secondary: #b7c8c0;
    --muted: #849c93;
    --accent: #38b8a4;
    --accent-hover: #4ccab6;
    --accent-soft: rgba(56, 184, 164, 0.15);
    --accent-ring: rgba(56, 184, 164, 0.30);
    --heart: #f2746b;
    --heart-soft: rgba(242, 116, 107, 0.16);
    --heart-ring: rgba(242, 116, 107, 0.35);
    --amber: #eab45c;
    --line: #253933;
    --line-strong: #324c44;
    --canvas-bg: #101b18;
    --pill-bg: rgba(23, 36, 32, 0.88);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.38);
    --shadow-cta: 0 10px 26px rgba(56, 184, 164, 0.22);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background: var(--bg);
    background-image: radial-gradient(circle at 12% 0%, var(--accent-soft), transparent 42%);
    color: var(--text);
    font-family: 'Plus Jakarta Sans', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

button, a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    cursor: pointer;
}

button:focus-visible,
a:focus-visible {
    outline: 2.5px solid var(--accent);
    outline-offset: 3px;
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

[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.85;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ===== Main App Container ===== */
.app {
    width: min(100%, 1920px);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 clamp(16px, 2.2vw, 40px);
    gap: clamp(10px, 1.3vh, 18px);
}

/* ===== Header ===== */
.app-header {
    flex: 0 0 auto;
    min-height: clamp(60px, 7.2vh, 80px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: clamp(8px, 1vh, 14px) 0;
}

.brand {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.1vw, 16px);
    min-width: 0;
}

.brand-logo {
    width: clamp(38px, 4.4vh, 48px);
    height: clamp(38px, 4.4vh, 48px);
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.brand-copy {
    min-width: 0;
}

.brand-line {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-name {
    font-size: clamp(16px, 1.45vw, 23px);
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.2;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    margin-top: 2px;
    font-size: clamp(11px, 0.85vw, 13px);
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: clamp(8px, 0.8vw, 12px);
    flex-shrink: 0;
}

.lang-switch {
    display: flex;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

.lang-switch button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: clamp(12px, 0.9vw, 14px);
    font-weight: 700;
    border-radius: 999px;
    padding: 6px clamp(10px, 0.95vw, 14px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.lang-switch button:hover:not(.active) {
    color: var(--text);
}

.lang-switch button.active {
    background: var(--accent);
    color: #fffdf9;
}

html[data-theme="dark"] .lang-switch button.active {
    color: #0b1614;
}

.icon-button {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--line);
    width: clamp(36px, 4vh, 42px);
    height: clamp(36px, 4vh, 42px);
    border-radius: 50%;
    display: grid;
    place-items: center;
    padding: 0;
    box-shadow: var(--shadow-sm);
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.icon-button .icon {
    width: clamp(17px, 1.9vh, 20px);
    height: clamp(17px, 1.9vh, 20px);
}

.icon-button:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* ===== Main Split Dashboard (Widescreen Default) ===== */
.stage {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr);
    gap: clamp(14px, 1.8vw, 28px);
}

/* ===== Left Column: Hero + Camera Stage ===== */
.camera-column {
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 1.2vh, 16px);
}

.intro {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.intro-title-block {
    min-width: 0;
}

.eyebrow {
    font-size: clamp(11px, 0.82vw, 13px);
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent);
    text-transform: uppercase;
}

.heading-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 3px;
}

h1 {
    margin: 0;
    font-size: clamp(26px, 2.5vw, 42px);
    line-height: 1.08;
    letter-spacing: -0.02em;
    font-weight: 800;
    color: var(--text);
}

.product-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-ring);
    color: var(--accent);
    font-size: clamp(11px, 0.85vw, 13px);
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.intro-copy {
    text-align: right;
    min-width: 0;
}

.intro-copy h2 {
    margin: 0 0 3px;
    font-size: clamp(15px, 1.25vw, 20px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
}

.intro-copy p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(12px, 0.92vw, 14px);
    font-weight: 500;
}

.video-stage {
    flex: 1;
    min-height: 0;
    display: flex;
}

#video-frame {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border: 1.5px solid var(--line);
    border-radius: clamp(18px, 1.8vw, 26px);
    background: var(--surface-camera-idle);
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#video-frame[data-camera="live"] {
    background: #101916;
    border-color: var(--accent-ring);
}

#video-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(ellipse at center, #000 18%, transparent 78%);
    pointer-events: none;
}

#video-frame[data-camera="live"]::before {
    opacity: 0;
}

.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: clamp(14px, 1.6vw, 24px);
    right: clamp(14px, 1.6vw, 24px);
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.camera-topbar {
    top: clamp(14px, 1.5vh, 22px);
}

.camera-bottom {
    bottom: clamp(14px, 1.5vh, 22px);
}

.camera-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--pill-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 15px;
    font-size: clamp(13px, 0.95vw, 15px);
    font-weight: 600;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.live-dot,
.tiny-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

[data-camera="live"] .live-dot {
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
    animation: gentlePulse 2s ease-in-out infinite;
}

.heart-card.is-reading .tiny-dot {
    background: var(--heart);
    box-shadow: 0 0 0 4px var(--heart-soft);
    animation: gentlePulse 1.4s ease-in-out infinite;
}

.camera-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--pill-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    color: var(--text-secondary);
    font-size: clamp(11px, 0.8vw, 13px);
    font-weight: 600;
    letter-spacing: 0.06em;
}

[data-camera="live"] .camera-label,
[data-camera="live"] .camera-tag,
[data-camera="live"] .camera-hint-pill {
    background: rgba(14, 24, 21, 0.72);
    border-color: rgba(255, 255, 255, 0.16);
    color: #f4f7f5;
}

.camera-center {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 2.2vh, 26px);
    padding: 56px 24px 62px;
    pointer-events: none;
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 420px;
}

.face-guide {
    position: relative;
    width: clamp(92px, 12.5vh, 138px);
    height: clamp(102px, 13.8vh, 150px);
    color: var(--accent);
    margin-bottom: clamp(12px, 1.8vh, 20px);
    display: grid;
    place-items: center;
}

.face-guide::before {
    content: '';
    position: absolute;
    inset: -14%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
    animation: breatheHalo 4s ease-in-out infinite;
}

.face-guide svg {
    position: relative;
    height: 88%;
    width: 88%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.45;
    stroke-linecap: round;
    opacity: 0.78;
}

.face-guide i {
    position: absolute;
    width: 22px;
    height: 22px;
    border: solid currentColor;
    border-width: 2.2px 0 0 2.2px;
    border-radius: 8px 0 0 0;
}

.face-guide i:nth-child(1) { top: 0; left: 0; }
.face-guide i:nth-child(2) { top: 0; 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; left: 0; transform: rotate(270deg); }

.camera-placeholder h3 {
    margin: 0 0 6px;
    font-size: clamp(19px, 1.65vw, 26px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
}

.camera-placeholder p {
    margin: 0;
    color: var(--text-secondary);
    font-size: clamp(13px, 1.02vw, 16px);
    line-height: 1.5;
}

#largeStartBtn {
    pointer-events: auto;
    min-width: clamp(188px, 16vw, 240px);
    padding: clamp(13px, 1.5vh, 17px) clamp(28px, 2.8vw, 42px);
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fffdf9;
    font-size: clamp(16px, 1.25vw, 20px);
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    box-shadow: var(--shadow-cta);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

html[data-theme="dark"] #largeStartBtn {
    color: #091512;
}

#largeStartBtn:hover:enabled {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.34);
}

#largeStartBtn:active:enabled {
    transform: translateY(0);
}

.camera-hint-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--pill-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    color: var(--text-secondary);
    font-size: clamp(12px, 0.9vw, 14px);
    font-weight: 500;
}

#pauseBtn {
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 8px 18px;
    color: #fffdf9;
    background: rgba(16, 26, 23, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: clamp(13px, 0.95vw, 15px);
    font-weight: 600;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#pauseBtn:hover {
    background: rgba(217, 78, 71, 0.88);
    border-color: rgba(255, 255, 255, 0.4);
}

/* ===== Right Column: Vital Signs Dashboard ===== */
.vitals-column {
    min-height: 0;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0, 1.06fr) minmax(0, 1.08fr) minmax(0, 0.96fr);
    gap: clamp(12px, 1.4vh, 18px);
}

.metrics {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: clamp(12px, 1.2vw, 18px);
    min-height: 0;
}

.metric-card,
.signal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: clamp(16px, 1.5vw, 22px);
    padding: clamp(14px, 1.6vh, 22px) clamp(15px, 1.5vw, 24px);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.heart-card {
    background: var(--surface-heart);
}

.heart-card.is-reading {
    border-color: var(--heart-ring);
    box-shadow: 0 8px 24px var(--heart-soft);
}

.metric-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: clamp(14px, 1.08vw, 17px);
    font-weight: 700;
    color: var(--text-secondary);
}

.icon-badge {
    width: clamp(30px, 3.4vh, 38px);
    height: clamp(30px, 3.4vh, 38px);
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.icon-badge .icon {
    width: clamp(17px, 2vh, 21px);
    height: clamp(17px, 2vh, 21px);
}

.heart-badge {
    background: var(--heart-soft);
    color: var(--heart);
}

.heart-card.is-reading .heart-badge .icon {
    fill: var(--heart);
    animation: heartBeat 1.2s ease-in-out infinite;
}

.mood-badge {
    background: var(--accent-soft);
    color: var(--accent);
}

.wave-badge {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
}

.wave-badge .icon {
    width: 16px;
    height: 16px;
}

.metric-reading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: auto 0;
    padding: clamp(6px, 1vh, 14px) 0;
}

.metric-value {
    font-size: clamp(46px, 4.4vw, 78px);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.mood-value {
    font-size: clamp(34px, 3.2vw, 56px);
    letter-spacing: 0.02em;
    font-weight: 700;
}

.reading-unit {
    font-size: clamp(13px, 1.05vw, 17px);
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.04em;
}

#hrVal.active {
    color: var(--heart);
}

#moodVal[data-mood="calm"] {
    color: var(--accent);
}

#moodVal[data-mood="excited"] {
    color: var(--amber);
}

#moodVal[data-mood="tense"] {
    color: var(--heart);
}

.metric-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: clamp(12px, 0.92vw, 14px);
    font-weight: 500;
    line-height: 1.35;
}

.status-note {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ===== Pulse Wave Card ===== */
.wave-card {
    padding: clamp(12px, 1.4vh, 18px) clamp(15px, 1.5vw, 22px);
}

.wave-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: clamp(13px, 1vw, 16px);
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: clamp(8px, 1vh, 12px);
}

.wave-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.signal-code {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--muted);
    font-size: clamp(10px, 0.78vw, 12px);
    font-weight: 700;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.wave-body {
    flex: 1;
    min-height: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--canvas-bg);
    border: 1px solid var(--line);
}

.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: clamp(11px, 0.85vw, 13px);
    font-weight: 500;
    padding-top: 8px;
}

.signal-line {
    height: 3px;
    width: 32px;
    border-radius: 999px;
    background: var(--accent);
}

/* ===== Bottom Visuals + Telemetry Row ===== */
.signals {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.06fr);
    gap: clamp(10px, 1.1vw, 16px);
    min-height: 0;
}

.vis-card,
.telemetry-card {
    padding: clamp(11px, 1.3vh, 16px) clamp(12px, 1.2vw, 18px);
}

.vis-card .wave-head,
.telemetry-head {
    font-size: clamp(12px, 0.92vw, 14px);
    margin-bottom: clamp(6px, 0.9vh, 10px);
}

.heat-body {
    display: grid;
    flex: 1;
    min-height: 0;
    width: 100%;
    container-type: size;
    place-items: center;
}

.heat-square {
    position: relative;
    width: min(100cqi, 100cqb);
    height: min(100cqi, 100cqb);
    border-radius: 12px;
    overflow: hidden;
    background: var(--canvas-bg);
    border: 1px solid var(--line);
}

.heat-square canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.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: 8px;
}

.telemetry-list > div + div {
    border-top: 1px solid var(--line);
}

.telemetry-list dt {
    color: var(--muted);
    font-size: clamp(11px, 0.85vw, 13px);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.telemetry-list dd {
    margin: 0;
    color: var(--text);
    font-size: clamp(15px, 1.35vw, 21px);
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ===== Footer ===== */
.app-footer {
    flex: 0 0 auto;
    min-height: clamp(34px, 4.2vh, 46px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
    font-size: clamp(11px, 0.85vw, 13px);
    font-weight: 500;
    color: var(--muted);
    padding: 6px 0 clamp(8px, 1vh, 12px);
}

.privacy-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.privacy-note .icon {
    width: 17px;
    height: 17px;
    color: var(--accent);
}

.footer-copy {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#hidden-vis {
    position: fixed;
    width: 220px;
    height: 120px;
    left: -9999px;
    top: 0;
    overflow: hidden;
}

#hidden-vis canvas {
    width: 100%;
    height: 100%;
}

/* ===== Language-specific Typographic Tuning ===== */
html[data-lang="en"] .brand-name,
html[data-lang="pt"] .brand-name {
    font-size: clamp(14px, 1.25vw, 19px);
    letter-spacing: -0.01em;
}

html[data-lang="en"] .mood-value,
html[data-lang="pt"] .mood-value {
    font-size: clamp(24px, 2.3vw, 40px);
    letter-spacing: -0.02em;
}

html[data-lang="en"] .intro-copy h2,
html[data-lang="pt"] .intro-copy h2 {
    letter-spacing: -0.01em;
    font-size: clamp(14px, 1.1vw, 18px);
}

/* ===== Subtle Animations ===== */
@keyframes gentlePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.18); opacity: 0.85; }
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    18% { transform: scale(1.16); }
    34% { transform: scale(1); }
    50% { transform: scale(1.1); }
    66% { transform: scale(1); }
}

@keyframes breatheHalo {
    0%, 100% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 1; }
}

/* ===== Ultrawide Proportion Guard (> 16:9) ===== */
@media (min-aspect-ratio: 18/9) {
    .app {
        width: min(100%, calc(100dvh * 16 / 9));
    }
}

/* ===== Portrait & Tablet Kiosk Layout (<= 6:5 or <= 1024px) ===== */
@media (max-aspect-ratio: 6/5), (max-width: 1024px) {
    .app {
        height: 100dvh;
        padding: 0 clamp(14px, 3vw, 28px);
        gap: 8px;
    }

    .app-header {
        min-height: 54px;
        padding: 6px 0;
    }

    .stage {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 0.88fr) minmax(0, 1.12fr);
        gap: 10px;
    }

    .camera-column {
        gap: 8px;
    }

    .vitals-column {
        grid-template-rows: minmax(0, 0.84fr) minmax(0, 1.16fr) minmax(0, 1fr);
        gap: 9px;
    }

    .metric-card,
    .signal-card,
    .wave-card,
    .vis-card,
    .telemetry-card {
        padding: 10px 14px;
    }

    .wave-head,
    .vis-card .wave-head,
    .telemetry-head {
        margin-bottom: 6px;
    }

    .wave-caption {
        padding-top: 5px;
    }

    .display-layer {
        object-fit: cover;
    }

    .metric-value {
        font-size: clamp(34px, 5vw, 54px);
    }

    .mood-value {
        font-size: clamp(26px, 3.8vw, 42px);
    }

    .face-guide {
        width: clamp(64px, 8.5vh, 96px);
        height: clamp(72px, 9.5vh, 106px);
        margin-bottom: 8px;
    }

    .camera-center {
        gap: 10px;
        padding: 40px 16px 56px;
    }

    .camera-placeholder h3 {
        font-size: clamp(16px, 2.2vw, 22px);
    }

    .camera-placeholder p {
        font-size: clamp(12px, 1.5vw, 14px);
    }

    .footer-copy {
        display: none;
    }

    .app-footer {
        min-height: 30px;
        padding: 4px 0 6px;
        justify-content: center;
    }
}

/* ===== Compact Square / Short Landscape Guard ===== */
@media (max-height: 560px) and (max-width: 520px) {
    .app {
        height: auto;
        min-height: 100dvh;
    }

    .stage {
        grid-template-rows: auto auto;
    }

    .video-stage {
        height: 270px;
    }

    .vitals-column {
        grid-template-rows: auto auto auto;
    }

    .wave-body {
        height: 110px;
    }

    .heat-body {
        container-type: normal;
    }

    .heat-square {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}

/* ===== Mobile Phone Layout (<= 600px) ===== */
@media (max-width: 600px) {
    body {
        display: block;
    }

    .app {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        padding: 0 14px 16px;
        gap: 12px;
    }

    .app-header {
        flex-wrap: wrap;
        min-height: auto;
        padding: 12px 0 10px;
        gap: 10px;
    }

    .brand {
        width: 100%;
    }

    .brand-logo {
        width: 40px;
        height: 40px;
    }

    .brand-name {
        font-size: 16px;
        white-space: normal;
    }

    .brand-sub {
        font-size: 11px;
        white-space: normal;
    }

    html[data-lang="en"] .brand-name,
    html[data-lang="pt"] .brand-name {
        font-size: 14px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .stage {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .intro {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .intro-copy {
        text-align: left;
    }

    h1 {
        font-size: 28px;
    }

    .video-stage {
        flex: none;
        height: 360px;
    }

    .camera-topbar,
    .camera-bottom {
        left: 12px;
        right: 12px;
    }

    .camera-label {
        padding: 5px 11px;
        font-size: 12px;
    }

    .camera-tag {
        padding: 5px 9px;
        font-size: 10px;
    }

    .camera-hint-pill {
        font-size: 11px;
        padding: 5px 10px;
    }

    .face-guide {
        width: 82px;
        height: 92px;
        margin-bottom: 12px;
    }

    .camera-placeholder h3 {
        font-size: 18px;
    }

    .camera-placeholder p {
        font-size: 12.5px;
    }

    #largeStartBtn {
        font-size: 16px;
        padding: 13px 30px;
        min-width: 180px;
    }

    .vitals-column {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .metrics {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        gap: 10px;
    }

    .metric-card {
        padding: 14px;
        min-height: 138px;
    }

    .metric-head {
        font-size: 13px;
    }

    .icon-badge {
        width: 30px;
        height: 30px;
    }

    .metric-value {
        font-size: 40px;
    }

    .mood-value {
        font-size: 28px;
    }

    html[data-lang="en"] .mood-value,
    html[data-lang="pt"] .mood-value {
        font-size: 22px;
    }

    .wave-card {
        padding: 14px;
    }

    .wave-body {
        height: 128px;
        flex: none;
    }

    .signals {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .vis-card {
        padding: 12px;
    }

    .heat-body {
        container-type: normal;
    }

    .heat-square {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .telemetry-card {
        grid-column: 1 / -1;
        padding: 12px 14px;
        min-height: auto;
    }

    .telemetry-list {
        grid-template-rows: none;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .telemetry-list > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        padding: 4px 8px;
        border-radius: 10px;
        background: var(--bg-subtle);
    }

    .telemetry-list > div + div {
        border-top: 0;
    }

    .telemetry-list dt {
        font-size: 11px;
    }

    .telemetry-list dd {
        font-size: 17px;
    }

    .app-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 4px;
        padding: 12px 0 4px;
    }

    .footer-copy {
        display: block;
        white-space: normal;
        text-align: center;
        font-size: 11px;
    }
}
