/* ════════════════════════════════════════════════════════════════
   SKELETON — style.css
   Palette: #f4f6f1 · #a3b18a · #517751 · #3a5a40 · #1a2e1f
   Font: Public Sans
   ════════════════════════════════════════════════════════════════ */

:root {
    --bg:     #f4f6f1;
    --sage:   #a3b18a;
    --forest: #517751;
    --deep:   #3a5a40;
    --ink:    #1a2e1f;

    --cam-bg:     #0c120e;
    --cam-panel:  rgba(12, 18, 14, 0.90);
    --cam-border: rgba(163, 177, 138, 0.14);

    --good: #5cb86e;
    --warn: #e8b84b;
    --bad:  #e05252;

    --font: 'Public Sans', system-ui, -apple-system, sans-serif;

    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 18px;
    --r-lg: 24px;
    --r-xl: 999px;

    /* topbar height — used to offset metrics strip */
    --topbar-h: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--cam-bg);
    font-family: var(--font);
    color: #fff;
    -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════════════════════════════════════════
   LOADING
   ════════════════════════════════════════════════════════════════ */

#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--cam-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loader-content { display: flex; flex-direction: column; align-items: center; gap: 20px; }

.loader-ring {
    width: 52px; height: 52px;
    border: 2px solid rgba(163, 177, 138, 0.15);
    border-top-color: var(--sage);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.20em;
    color: rgba(163, 177, 138, 0.55);
    text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════
   CAMERA VIEWPORT
   ════════════════════════════════════════════════════════════════ */

#viewport { position: relative; width: 100vw; height: 100vh; overflow: hidden; }

#video, #canvas {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* ── Viewfinder corners ── */
.vf-corners { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.vf-c {
    position: absolute;
    width: 24px; height: 24px;
    border-color: rgba(163, 177, 138, 0.50);
    border-style: solid;
    transition: border-color 0.6s ease;
}

.vf-c.tl { top: calc(var(--topbar-h) + 10px); left: 14px; border-width: 2px 0 0 2px; border-radius: var(--r-xs) 0 0 0; }
.vf-c.tr { top: calc(var(--topbar-h) + 10px); right: 14px; border-width: 2px 2px 0 0; border-radius: 0 var(--r-xs) 0 0; }
.vf-c.bl { bottom: 52px; left: 14px; border-width: 0 0 2px 2px; border-radius: 0 0 0 var(--r-xs); }
.vf-c.br { bottom: 52px; right: 14px; border-width: 0 2px 2px 0; border-radius: 0 0 var(--r-xs) 0; }

.vf-corners.good .vf-c { border-color: rgba(92, 184, 110, 0.65); }
.vf-corners.bad  .vf-c { border-color: rgba(224, 82, 82, 0.65); }

/* ════════════════════════════════════════════════════════════════
   TOP BAR (CAMERA)
   ════════════════════════════════════════════════════════════════ */

#topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--cam-panel);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--cam-border);
    z-index: 10;
}

.tb-left   { display: flex; align-items: center; gap: 10px; }
.tb-center { display: flex; align-items: center; gap: 8px; }
.tb-right  { display: flex; align-items: center; gap: 8px; }

.tb-sep { font-size: 5px; color: rgba(163, 177, 138, 0.22); line-height: 1; }

.home-btn, .voice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: rgba(163, 177, 138, 0.10);
    border: 1px solid rgba(163, 177, 138, 0.20);
    border-radius: var(--r-sm);
    color: rgba(163, 177, 138, 0.80);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    font-family: var(--font);
    flex-shrink: 0;
}

.home-btn:hover, .voice-btn:hover {
    background: rgba(163, 177, 138, 0.22);
    color: var(--bg);
    border-color: rgba(163, 177, 138, 0.42);
    transform: scale(1.05);
}

.voice-btn.muted { color: rgba(163, 177, 138, 0.25); border-color: rgba(163, 177, 138, 0.08); }

.brand {
    font-family: var(--font);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: rgba(244, 246, 241, 0.90);
    text-transform: uppercase;
}

.view-badge {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    padding: 5px 12px;
    border: 1px solid rgba(163, 177, 138, 0.35);
    color: var(--sage);
    background: rgba(163, 177, 138, 0.08);
    border-radius: var(--r-xl);
    text-transform: uppercase;
}

.view-badge.profile {
    border-color: rgba(232, 184, 75, 0.40);
    color: var(--warn);
    background: rgba(232, 184, 75, 0.08);
}

.exercise-badge {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    padding: 5px 12px;
    border: 1px solid rgba(163, 177, 138, 0.18);
    color: rgba(163, 177, 138, 0.60);
    background: rgba(163, 177, 138, 0.06);
    border-radius: var(--r-xl);
    text-transform: uppercase;
    transition: border-color 0.4s, color 0.4s;
}

.exercise-badge[data-ex="inpiedi"] { border-color: rgba(163, 177, 138, 0.40); color: var(--sage); }
.exercise-badge[data-ex="seduto"]  { border-color: rgba(232, 184, 75, 0.40);  color: var(--warn); }
.exercise-badge[data-ex="squat"]   { border-color: rgba(92, 184, 110, 0.40);  color: var(--good); }
.exercise-badge[data-ex="pushup"]  { border-color: rgba(224, 82, 82, 0.40);   color: var(--bad);  }

.status-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(12, 18, 14, 0.70);
    border: 1px solid var(--cam-border);
    padding: 5px 12px;
    border-radius: var(--r-xl);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: rgba(163, 177, 138, 0.55);
    white-space: nowrap;
}

.sdot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(163, 177, 138, 0.30);
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.sdot.active  { background: var(--good); box-shadow: 0 0 8px var(--good); animation: blink 2s infinite; }
.sdot.warning { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.sdot.error   { background: var(--bad);  box-shadow: 0 0 8px var(--bad); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ════════════════════════════════════════════════════════════════
   ANGLE + REP BADGES
   ════════════════════════════════════════════════════════════════ */

@keyframes badgePulseRed {
    0%, 100% { box-shadow: 0 0 10px rgba(224, 82, 82, 0.40); }
    50%       { box-shadow: 0 0 28px rgba(224, 82, 82, 0.90), 0 0 48px rgba(224, 82, 82, 0.28); }
}

@keyframes repPulse {
    0%, 100% { border-color: rgba(92, 184, 110, 0.30); }
    50%       { border-color: rgba(92, 184, 110, 0.88); box-shadow: 0 0 18px rgba(92, 184, 110, 0.40); }
}

#angle-badge {
    position: absolute;
    top: calc(var(--topbar-h) + 14px);
    right: 16px;
    background: rgba(12, 18, 14, 0.82);
    border: 1px solid rgba(163, 177, 138, 0.24);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    padding: 14px 20px;
    text-align: center;
    z-index: 10;
    min-width: 100px;
    border-radius: var(--r-md);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
    transition: border-color 0.3s, box-shadow 0.3s;
}

#angle-badge.good    { border-color: rgba(92, 184, 110, 0.55); box-shadow: 0 8px 28px rgba(0,0,0,.18), 0 0 18px rgba(92,184,110,.22); }
#angle-badge.warning { border-color: rgba(232, 184, 75, 0.55); box-shadow: 0 8px 28px rgba(0,0,0,.18), 0 0 18px rgba(232,184,75,.20); }
#angle-badge.bad     { border-color: rgba(224, 82, 82, 0.65); animation: badgePulseRed 1.2s ease-in-out infinite; }

#rep-badge {
    position: absolute;
    top: calc(var(--topbar-h) + 122px);
    right: 16px;
    background: rgba(92, 184, 110, 0.12);
    border: 1px solid rgba(92, 184, 110, 0.30);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    padding: 14px 20px;
    text-align: center;
    z-index: 10;
    min-width: 100px;
    border-radius: var(--r-md);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    animation: repPulse 2s ease-in-out infinite, fadeInUp 0.3s ease;
}

.badge-value {
    font-family: var(--font);
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    color: var(--bg);
    letter-spacing: -0.02em;
    transition: color 0.3s;
}

.badge-label {
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.24em;
    color: rgba(163, 177, 138, 0.72);
    margin-top: 5px;
    text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════
   METRICS PANEL — desktop: left side panel
   ════════════════════════════════════════════════════════════════ */

#metrics-panel {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--cam-panel);
    border: 1px solid var(--cam-border);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    z-index: 10;
    min-width: 210px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--r-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.48);
}

.metrics-hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    font-family: var(--font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(163, 177, 138, 0.50);
    border-bottom: 1px solid rgba(163, 177, 138, 0.09);
    background: rgba(163, 177, 138, 0.04);
    text-transform: uppercase;
}

.mh-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--sage);
    box-shadow: 0 0 6px var(--sage);
    flex-shrink: 0;
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(163, 177, 138, 0.07);
    border-left: 2px solid transparent;
    transition: background 0.2s, border-left-color 0.2s;
}

.metric-row:last-child { border-bottom: none; }
.metric-row.warn { background: rgba(224, 82, 82, 0.11); border-left-color: var(--bad); }
.metric-row.ok   { background: rgba(232, 184, 75, 0.08); border-left-color: var(--warn); }

.m-icon {
    font-size: 13px;
    color: rgba(163, 177, 138, 0.35);
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.m-label {
    font-family: var(--font);
    color: rgba(163, 177, 138, 0.68);
    flex: 1;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.m-val {
    font-family: var(--font);
    font-weight: 700;
    color: var(--bg);
    min-width: 44px;
    text-align: right;
    font-size: 13px;
    transition: color 0.3s;
}

.m-val.good    { color: var(--good); }
.m-val.warning { color: var(--warn); }
.m-val.bad     { color: var(--bad);  }

/* ════════════════════════════════════════════════════════════════
   BANNERS
   ════════════════════════════════════════════════════════════════ */

@keyframes warnGlow {
    0%, 100% { box-shadow: 0 0 14px rgba(224, 82, 82, 0.38); }
    50%       { box-shadow: 0 0 34px rgba(224, 82, 82, 0.80), 0 0 56px rgba(224, 82, 82, 0.22); }
}

@keyframes goodGlow {
    0%, 100% { box-shadow: 0 0 14px rgba(92, 184, 110, 0.32); }
    50%       { box-shadow: 0 0 30px rgba(92, 184, 110, 0.75), 0 0 50px rgba(92, 184, 110, 0.16); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#warning-banner {
    position: absolute;
    bottom: 28px; left: 50%;
    transform: translateX(-50%);
    background: rgba(160, 28, 28, 0.92);
    border: 1px solid rgba(224, 82, 82, 0.65);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 14px 36px;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.10em;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    z-index: 10;
    border-radius: var(--r-md);
    animation: fadeInUp 0.3s ease, warnGlow 1.4s ease-in-out infinite;
}

#good-banner {
    position: absolute;
    bottom: 28px; left: 50%;
    transform: translateX(-50%);
    background: rgba(36, 90, 50, 0.94);
    border: 1px solid rgba(92, 184, 110, 0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 14px 40px;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.16em;
    white-space: nowrap;
    z-index: 10;
    color: var(--bg);
    border-radius: var(--r-md);
    animation: fadeInUp 0.3s ease, goodGlow 2s ease-in-out infinite;
}

.hidden { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   EXERCISE SELECTION SCREEN
   ════════════════════════════════════════════════════════════════ */

@keyframes exCardIn {
    from { opacity: 0; transform: translateY(28px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes exHeaderIn {
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes subtlePulse {
    0%, 100% { opacity: 0.40; }
    50%       { opacity: 0.75; }
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Page shell ── */
#exercise-select {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.45s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

#exercise-select::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(58, 90, 64, 0.08) 1.2px, transparent 1.2px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
    animation: subtlePulse 7s ease-in-out infinite;
}

#exercise-select::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 140% 80% at 50% 0%, transparent 50%, rgba(163, 177, 138, 0.10) 100%);
    pointer-events: none;
    z-index: 0;
}

#exercise-select .scan-line { display: none; }
#exercise-select.hidden { opacity: 0; pointer-events: none; }

/* ── Inner layout ── */
.ex-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    padding: 100px 28px 60px;
    width: 100%;
    max-width: 1100px;
}

/* ── Header ── */
.ex-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    animation: exHeaderIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ex-logo {
    font-family: var(--font);
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--ink);
    line-height: 1;
    text-transform: uppercase;
}

.ex-tagline {
    font-family: var(--font);
    font-size: clamp(1rem, 2.8vw, 1.20rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--forest);
    text-align: center;
}

.ex-divider-line { display: none; }

.ex-prompt {
    font-family: var(--font);
    font-size: clamp(0.95rem, 2.4vw, 1.05rem);
    font-weight: 400;
    color: rgba(26, 46, 31, 0.46);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.ex-prompt::after {
    content: '▌';
    font-size: 11px;
    animation: cursorBlink 1.2s step-end infinite;
    color: var(--forest);
    opacity: 0.55;
}

/* ════════════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════════════ */

.ex-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    width: 100%;
}

/* ── Card base ── */
.ex-card {
    --card-rgb: 81, 119, 81;

    position: relative;
    display: flex;
    flex-direction: column;
    border: 1.5px solid rgba(163, 177, 138, 0.24);
    border-radius: var(--r-lg);
    overflow: hidden;
    cursor: pointer;
    font-family: var(--font);
    text-align: center;
    color: var(--bg);
    background: transparent;
    transition:
        transform    0.32s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow   0.32s ease,
        border-color 0.32s ease;
    box-shadow:
        0 4px 16px rgba(26, 46, 31, 0.20),
        0 1px 4px  rgba(26, 46, 31, 0.12);
}

.ex-card[data-ex="inpiedi"] { --card-rgb: 81, 119, 81; }
.ex-card[data-ex="seduto"]  { --card-rgb: 58, 90, 64; }
.ex-card[data-ex="squat"]   { --card-rgb: 81, 119, 81; }
.ex-card[data-ex="pushup"]  { --card-rgb: 26, 46, 31; }

/* Green gradient only on the text section */
.ex-card-info                              { background: linear-gradient(160deg, #3a5a40 0%, #517751 100%); }
.ex-card[data-ex="seduto"]  .ex-card-info  { background: linear-gradient(160deg, #2d4a33 0%, #3a5a40 100%); }
.ex-card[data-ex="squat"]   .ex-card-info  { background: linear-gradient(160deg, #3f6145 0%, #4e7252 100%); }
.ex-card[data-ex="pushup"]  .ex-card-info  { background: linear-gradient(160deg, #1a2e1f 0%, #3a5a40 100%); }

/* sage shimmer stripe — revealed on hover */
.ex-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(to right, transparent, rgba(163, 177, 138, 0.80), transparent);
    opacity: 0;
    transition: opacity 0.30s;
    z-index: 3;
}

/* hover brightness overlay */
.ex-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background 0.32s;
    pointer-events: none;
    z-index: 1;
}

.ex-card:hover,
.ex-card:focus-visible {
    outline: none;
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(163, 177, 138, 0.58);
    box-shadow:
        0 28px 60px -12px rgba(26, 46, 31, 0.48),
        0 8px 20px rgba(26, 46, 31, 0.22),
        0 0 0 1px rgba(163, 177, 138, 0.18);
}

.ex-card:hover::before,
.ex-card:focus-visible::before { opacity: 1; }

.ex-card:hover::after,
.ex-card:focus-visible::after  { background: rgba(255, 255, 255, 0.06); }

.ex-card:active { transform: translateY(-4px) scale(1.01); }

/* stagger entrance */
.ex-card:nth-child(1) { animation: exCardIn 0.50s cubic-bezier(0.22, 1, 0.36, 1) 0.06s both; }
.ex-card:nth-child(2) { animation: exCardIn 0.50s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both; }
.ex-card:nth-child(3) { animation: exCardIn 0.50s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both; }
.ex-card:nth-child(4) { animation: exCardIn 0.50s cubic-bezier(0.22, 1, 0.36, 1) 0.30s both; }

/* ── Card image ── */
.ex-fig-wrap {
    position: relative;
    width: 100%;
    height: 170px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
}

.ex-fig-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(26, 46, 31, 0.18) 100%);
    z-index: 1;
    pointer-events: none;
}

.ex-fig {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: center 15%;
    filter: none;
    transition: transform 0.55s ease, filter 0.35s;
    display: block;
}

.ex-card:hover .ex-fig {
    transform: scale(1.08);
    filter: brightness(1.04);
}

/* ── Card info ── */
.ex-card-info {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 20px 24px;
    width: 100%;
    flex: 1;
}

.ex-name {
    font-family: var(--font);
    font-size: clamp(1.20rem, 3.8vw, 1.55rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--bg);
    line-height: 1;
    transition: color 0.22s;
}

.ex-card:hover .ex-name { color: #fff; }

.ex-desc {
    font-family: var(--font);
    font-size: clamp(0.84rem, 2.0vw, 0.95rem);
    font-weight: 400;
    letter-spacing: 0.03em;
    color: rgba(163, 177, 138, 0.88);
    line-height: 1.55;
}

.ex-view {
    display: inline-block;
    font-family: var(--font);
    font-size: clamp(0.72rem, 1.8vw, 0.80rem);
    font-weight: 600;
    letter-spacing: 0.14em;
    color: rgba(244, 246, 241, 0.80);
    border: 1.5px solid rgba(244, 246, 241, 0.28);
    padding: 6px 16px;
    margin-top: 6px;
    border-radius: var(--r-xl);
    background: rgba(244, 246, 241, 0.09);
    transition: background 0.22s, border-color 0.22s, color 0.22s;
    white-space: nowrap;
    text-transform: uppercase;
}

.ex-card:hover .ex-view {
    background: rgba(244, 246, 241, 0.20);
    border-color: rgba(244, 246, 241, 0.65);
    color: #fff;
}

/* ── Back link (selection screen) ── */
.ex-back-link {
    position: fixed;
    top: 20px; left: 20px;
    z-index: 2010;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--deep);
    text-decoration: none;
    padding: 10px 20px;
    border: 1.5px solid rgba(58, 90, 64, 0.26);
    background: rgba(244, 246, 241, 0.90);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: var(--r-xl);
    transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 2px 12px rgba(26, 46, 31, 0.10);
}

.ex-back-link:hover {
    color: var(--ink);
    border-color: rgba(58, 90, 64, 0.50);
    background: rgba(244, 246, 241, 0.99);
    box-shadow: 0 4px 18px rgba(26, 46, 31, 0.16);
    transform: translateY(-1px);
}

/* ── Camera back button ── */
#back-btn { cursor: pointer; }
#back-btn:hover { background: rgba(163, 177, 138, 0.20); color: var(--bg); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET ≤ 900px
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .ex-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .ex-inner { padding: 88px 20px 52px; gap: 28px; max-width: 680px; }
    .ex-fig-wrap { height: 148px; }
    .ex-card-info { padding: 16px 16px 20px; }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET ≤ 768px  (camera adjustments)
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    :root { --topbar-h: 48px; }

    .brand   { font-size: 15px; }
    .tb-sep  { display: none; }

    .exercise-badge,
    .view-badge { font-size: 10px; padding: 4px 10px; }

    #status-text { display: none; }
    .status-pill { padding: 4px 9px; }

    .home-btn, .voice-btn { width: 34px; height: 34px; }

    #angle-badge { right: 10px; min-width: 88px; padding: 10px 14px; }
    #rep-badge   { right: 10px; min-width: 88px; padding: 10px 14px; }
    .badge-value { font-size: 34px; }
    .badge-label { font-size: 9px; letter-spacing: 0.18em; }

    #warning-banner, #good-banner {
        white-space: normal;
        max-width: 84vw;
        text-align: center;
        padding: 12px 20px;
        font-size: 14px;
        bottom: 20px;
    }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE ≤ 600px
   Metrics panel → horizontal scroll strip below topbar
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    :root { --topbar-h: 48px; }

    /* ── Metrics: full-width strip below topbar ── */
    #metrics-panel {
        position: absolute;
        top: var(--topbar-h);
        left: 0; right: 0;
        bottom: auto;
        transform: none;
        min-width: 0;
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        background: rgba(12, 18, 14, 0.88);
        padding: 0;
        gap: 0;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.30);
    }

    #metrics-panel::-webkit-scrollbar { display: none; }

    .metrics-hdr { display: none; }

    .metric-row {
        flex: 0 0 auto;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 10px 16px;
        border-bottom: none;
        border-left: none;
        border-right: 1px solid var(--cam-border);
        border-top: 3px solid transparent;
        gap: 3px;
        min-width: 78px;
    }

    .metric-row:last-child { border-right: none; }

    .metric-row.warn {
        border-top-color: var(--bad);
        background: rgba(224, 82, 82, 0.08);
    }

    .metric-row.ok {
        border-top-color: var(--warn);
        background: rgba(232, 184, 75, 0.06);
    }

    .m-icon { display: none; }

    .m-label {
        font-size: 10px;
        letter-spacing: 0.06em;
        white-space: nowrap;
        color: rgba(163, 177, 138, 0.60);
        text-align: center;
    }

    .m-val {
        font-size: 16px;
        font-weight: 800;
        min-width: 0;
        text-align: center;
    }

    /* Push badges below the metrics strip */
    #angle-badge {
        top: calc(var(--topbar-h) + 52px + 12px);
        right: 10px;
        min-width: 82px;
        padding: 10px 13px;
    }

    #rep-badge {
        top: calc(var(--topbar-h) + 52px + 116px);
        right: 10px;
        min-width: 82px;
        padding: 10px 13px;
    }

    .badge-value { font-size: 30px; }
    .badge-label { font-size: 9px; }

    /* Viewfinder — lower corners above banners */
    .vf-c.bl, .vf-c.br { bottom: 80px; }

    #warning-banner, #good-banner {
        white-space: normal;
        width: 90vw;
        max-width: 90vw;
        padding: 10px 16px;
        font-size: 13px;
        bottom: 14px;
    }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE ≤ 480px  (selection screen)
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .ex-inner { padding: 76px 14px 44px; gap: 22px; }
    .ex-fig-wrap { height: 118px; }
    .ex-card-info { padding: 14px 14px 18px; gap: 6px; }
    .ex-back-link { top: 14px; left: 14px; font-size: 13px; padding: 9px 16px; }

    .brand { font-size: 14px; }
    .home-btn, .voice-btn { width: 32px; height: 32px; }
    #view-badge { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — VERY SMALL ≤ 380px
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
    .brand     { display: none; }
    .tb-center { flex: 1; justify-content: center; }

    .ex-inner  { padding: 68px 12px 40px; }
    .ex-grid   { gap: 12px; }
    .ex-fig-wrap { height: 100px; }

    .badge-value { font-size: 26px; }
}
