/* Recovio Motion — shared design tokens and components.
   Layout: content pages are a single centered column (max 1080px) with a 16px+ gutter; the test runner is a full-screen camera stage. */
:root {
  --bg: #f2f5f4; --surface: #ffffff; --surface-2: #e8eeec; --line: #d2dcd9;
  --ink: #12201e; --muted: #5a6d6a;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #d5ece9;
  --left: #1b8fb3; --right: #d4623a;
  --good: #1e8a4c; --warn: #a77a06; --risk: #c9621a; --bad: #bf3a36;
  --stage: #071113; --stage-ink: #eaf3f1;
  --f-display: "Secular One", "IBM Plex Sans Hebrew", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Hebrew", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --f-data: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1619; --surface: #132227; --surface-2: #1a2e34; --line: #28434b;
    --ink: #e6efed; --muted: #8fa6a6;
    --accent: #3aa79f; --accent-ink: #04201e; --accent-soft: #163a3a;
    --left: #4fc3d9; --right: #f28c6b;
    --good: #6fcf97; --warn: #f2c14e; --risk: #f39a4f; --bad: #ef6f6c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1619; --surface: #132227; --surface-2: #1a2e34; --line: #28434b;
  --ink: #e6efed; --muted: #8fa6a6;
  --accent: #3aa79f; --accent-ink: #04201e; --accent-soft: #163a3a;
  --left: #4fc3d9; --right: #f28c6b;
  --good: #6fcf97; --warn: #f2c14e; --risk: #f39a4f; --bad: #ef6f6c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
body.rm-open { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(28px, 5vw, 44px); }
h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(22px, 3.4vw, 28px); }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, .mono { font-family: var(--f-data); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); padding-block: 20px 48px; display: grid; gap: 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 14px; padding-inline: max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand b { font-family: var(--f-display); font-weight: 400; font-size: 24px; letter-spacing: .3px; }
.brand span { color: var(--muted); font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.warn { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { min-height: 58px; font-size: 18px; padding-inline: 28px; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field .lab { font-size: 14px; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 8px 12px; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; min-height: 46px; padding: 8px 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* level chips */
.lv { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.lv-ok { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.lv-watch { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.lv-risk { color: var(--risk); background: color-mix(in srgb, var(--risk) 15%, transparent); }
.lv-refer { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* results */
.result { display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.rh { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); min-width: 0; border-top: 3px solid var(--line); }
.tile.t-ok { border-top-color: var(--good); } .tile.t-watch { border-top-color: var(--warn); } .tile.t-risk { border-top-color: var(--risk); } .tile.t-refer { border-top-color: var(--bad); }
.tile small { color: var(--muted); font-size: 13px; display: block; }
.tv { font-family: var(--f-data); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tv.side-L { color: var(--left); } .tv.side-R { color: var(--right); }
.ts { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fl { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.fl .lv { margin-top: 2px; }
.chart { margin: 0; }
.chart figcaption { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart canvas { width: 100%; display: block; }
.legend { font-weight: 400; color: var(--muted); display: inline-flex; gap: 12px; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-inline-end: 5px; background: var(--accent); }
.sw.side-L { background: var(--left); } .sw.side-R { background: var(--right); }
.reps summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }

/* ─── Test runner (always dark: it is a camera screen) ─── */
.rm { position: fixed; inset: 0; z-index: 50; background: var(--stage); color: var(--stage-ink); display: grid; grid-template-rows: auto 1fr auto; color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.rm-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #1e3439; }
.rm-title { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.rm-title b { font-family: var(--f-display); font-weight: 400; font-size: 20px; }
.rm-title span { color: #8fa6a6; font-size: 14px; }
.rm-x { background: transparent; border: 1px solid #2c464c; color: #eaf3f1; border-radius: 10px; min-height: 40px; padding: 6px 14px; cursor: pointer; }
.rm-stage { position: relative; min-height: 0; overflow: hidden; }
.rm-stage video { display: none; }
.rm-cv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.rm-chips { position: absolute; top: 12px; inset-inline: 12px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.chip { background: rgba(8,18,21,.8); border: 1px solid #28434b; border-radius: 12px; padding: 6px 12px; display: grid; min-width: 92px; }
.chip small { color: #8fa6a6; font-size: 12px; }
.chip b { font-family: var(--f-data); font-size: clamp(18px, 2.6vw, 28px); font-variant-numeric: tabular-nums; font-weight: 600; }
.chip.side-L { border-top: 3px solid #4fc3d9; } .chip.side-R { border-top: 3px solid #f28c6b; }
.chip.lv-watch b { color: #f2c14e; } .chip.lv-risk b { color: #f39a4f; }
.rm-big { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.rm-big .n { font-family: var(--f-display); font-size: clamp(64px, 20vh, 170px); line-height: .9; text-shadow: 0 4px 30px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.rm-big small { color: #b6c8c6; letter-spacing: .14em; font-size: 13px; }
.rm-cue { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(242,193,78,.95); color: #241a00; font-weight: 700; font-size: clamp(16px, 2.6vw, 24px); padding: 10px 18px; border-radius: 12px; max-width: min(90%, 560px); text-align: center; pointer-events: none; }
.rm-card { position: absolute; inset-inline-start: 16px; top: 16px; bottom: 16px; width: min(440px, calc(100% - 32px)); overflow-y: auto; background: rgba(12,24,27,.94); border: 1px solid #28434b; border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.rm-card h2 { color: #fff; }
.rm-card .muted { color: #9fb3b1; }
.rm-card ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }
.rm-step { color: #4fc3d9; font-size: 13px; font-weight: 700; letter-spacing: .06em; }
.rm-setup { font-size: 14px; color: #c6d5d3; background: #172b30; border-radius: 10px; padding: 10px 12px; }
.rm-lead { font-weight: 600; }
.rm-ready { border-radius: 10px; padding: 10px 12px; font-weight: 600; background: #3b2a12; color: #f2c14e; }
.rm-ready[data-ok="1"] { background: #12382a; color: #6fcf97; }
.rm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.rm-card .btn { background: #1a2e34; color: #eaf3f1; border-color: #2c464c; }
.rm-card .btn.primary { background: #3aa79f; color: #04201e; border-color: #3aa79f; }
.rm-count { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-display); font-size: clamp(120px, 40vh, 300px); text-shadow: 0 8px 40px rgba(0,0,0,.7); pointer-events: none; }
.rm-ctl { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 10px 16px; border-top: 1px solid #1e3439; background: #0c1a1d; }
.rm-ctl .btn { background: #1a2e34; color: #eaf3f1; border-color: #2c464c; min-width: 140px; }
.rm-ctl .btn.primary { background: #3aa79f; color: #04201e; border-color: #3aa79f; }
.rm-ctl .btn.warn { background: #ef6f6c; color: #2a0606; border-color: #ef6f6c; }
@media (max-width: 640px) {
  .rm-card { top: auto; inset-inline: 12px; bottom: 12px; width: auto; max-height: 62%; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* print: reports only */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; color-scheme: light; }
  body { background: #fff; }
  .noprint, .topbar, .rm, details.reps summary { display: none !important; }
  .result, .card { break-inside: avoid; border-color: #bbb; }
  .wrap { padding: 0; max-width: none; }
}

/* ─── App screens (lists, forms, workbench) ─── */
.head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.head > div:first-child { display: grid; gap: 4px; min-width: 0; }
.list { display: grid; gap: 8px; }
.person { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; cursor: pointer; text-align: start; width: 100%; color: var(--ink); }
.person:hover { border-color: var(--accent); }
.person b { font-size: 17px; }
@media (max-width: 520px) { .person { grid-template-columns: minmax(0, 1fr) auto; } .person > span:nth-child(2) { display: none; } }
.empty { text-align: center; padding: 36px 16px; border: 2px dashed var(--line); border-radius: var(--r); display: grid; gap: 10px; justify-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.trend { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; align-content: space-between; }
.results { display: grid; gap: 14px; }
.letter { display: grid; gap: 16px; padding: 28px; }
.lh { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--accent); padding-bottom: 12px; }
.lb { font-family: var(--f-display); font-weight: 400; font-size: 26px; color: var(--accent); }
.sig { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-top: 28px; }
.ms select { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 4px 8px; max-width: 220px; }
.ms td { vertical-align: top; }
@media print { .letter { border: 0; padding: 0; } .letter textarea { border: 0; resize: none; padding: 0; } }

/* numbers with units always read left-to-right inside RTL text (e.g. "69°", "12 ש׳" stays intact) */
.tv, .chip b, .deg, td.num, .num, .rm-big .n { direction: ltr; unicode-bidi: isolate; text-align: right; }
.rm-big .n { text-align: center; }

/* slim bar over a clear camera view before the measurement starts */
.rm-strip { position: absolute; inset-inline: 12px; bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: rgba(10,22,25,.92); border: 1px solid #28434b; border-radius: 14px; padding: 10px 12px; }
.rm-strip-main { flex: 1 1 200px; min-width: 0; display: grid; gap: 4px; }
.rm-strip-main b { color: #fff; }
.rm-strip-main small { color: #9fb3b1; }
.rm-strip .rm-ready { padding: 6px 10px; font-size: 14px; }
.rm-strip-btns { display: flex; gap: 8px; }
.rm-strip .btn { background: #1a2e34; color: #eaf3f1; border-color: #2c464c; }
.rm-strip .btn.primary { background: #3aa79f; color: #04201e; border-color: #3aa79f; min-width: 110px; }
.rm-strip-fig svg { width: 72px; height: auto; display: block; }
.rm-fig { background: #f4f7f6; border-radius: 12px; padding: 10px; display: grid; place-items: center; }
.rm-fig svg { width: min(220px, 70%); height: auto; }
.rm-strip-fig { background: #f4f7f6; border-radius: 10px; padding: 4px; }

.tv .u { font-family: var(--f-body); font-size: .55em; font-weight: 500; margin-inline-start: 6px; color: var(--muted); }
.tv .tw { font-family: var(--f-body); font-size: .8em; }

/* phone level: green frame = straight, red = straighten first */
.rm-stage::after { content: ""; position: absolute; inset: 6px; border-radius: 18px; border: 5px solid transparent; pointer-events: none; transition: border-color .2s; }
.rm-stage.lv-ok::after { border-color: #3ddc84; box-shadow: inset 0 0 24px rgba(61,220,132,.25); }
.rm-stage.lv-bad::after { border-color: #ff5a5a; box-shadow: inset 0 0 24px rgba(255,90,90,.3); }
.rm-level { position: absolute; left: 0; right: 0; margin-inline: auto; width: fit-content; bottom: 18px; z-index: 2; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); line-height: 1.35;
  padding: 10px 16px; border-radius: 999px; background: rgba(90,12,12,.92); color: #fff; font-weight: 700; font-size: clamp(15px, 2.4vw, 20px); box-shadow: 0 6px 24px rgba(0,0,0,.4); pointer-events: none; }
.rm-level[data-ok="1"] { background: rgba(10,70,40,.92); }
.rm-level b { font-weight: 700; flex: 1 1 auto; min-width: 0; } .rm-level .num { opacity: .85; margin-inline-start: 4px; }
.lv-track { position: relative; flex: none; width: 112px; height: 16px; border-radius: 8px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); direction: ltr; }
.lv-track::before, .lv-track::after { content: ""; position: absolute; top: 2px; bottom: 2px; width: 2px; background: rgba(255,255,255,.55); left: calc(50% - 12px); }
.lv-track::after { left: calc(50% + 10px); }
.lv-track i { position: absolute; top: 2px; left: calc(50% - 7px); width: 14px; height: 10px; border-radius: 6px; background: #ffd34d; transition: transform .1s linear; }
.rm-level[data-ok="1"] .lv-track i { background: #7dffb3; }
.rm-strip [data-go]:disabled { opacity: .45; cursor: not-allowed; }
.rm-level.mini { left: 12px; right: auto; margin: 0; bottom: 14px; padding: 8px 12px; gap: 8px; font-size: 15px; }
.rm-level.mini .lv-track { width: 64px; }
.rm-level.mini .lv-track::before { left: calc(50% - 10px); } .rm-level.mini .lv-track::after { left: calc(50% + 8px); }
.rm-cue.go { background: rgba(61,220,132,.97); color: #04220f; font-size: clamp(20px, 3.4vw, 30px); padding: 14px 22px; }

.rm-big .n .of { font-size: .45em; opacity: .7; margin-inline-start: .06em; }
