:root {
  --bg: #06080b;
  --surface: #0f1318;
  --surface-2: #151a21;
  --line: #222a34;
  --text: #edf1f5;
  --muted: #8b97a6;
  --faint: #5b6573;
  --accent: #5fe3c3;
  --accent-ink: #04231c;
  --amber: #ffc15a;
  --violet: #a594ff;
  --red: #ff6b6b;
  --radius: 16px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Hebrew", "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  font-size: 16px; line-height: 1.45;
  overflow-x: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- main screen ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; padding: calc(var(--top) + 8px) 16px calc(var(--bottom) + 16px); max-width: 520px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; direction: ltr; }
.mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 17px;
  background: linear-gradient(145deg, #1b2a2a, #0d1515); color: var(--accent); border: 1px solid #23413b; }
.top-actions { display: flex; align-items: center; gap: 22px; }
a.icon-btn { display: inline-flex; }
.icon-btn { background: none; border: 0; padding: 10px; margin: -10px; color: var(--muted); }

.home { flex: 1; display: flex; flex-direction: column; align-items: center; padding-top: 18px; }
.orb-wrap { width: 100%; display: grid; place-items: center; padding: 18px 0 10px; }
.orb { position: relative; width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; }
.orb .halo { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--line); transition: border-color .4s, box-shadow .4s; }
.orb .core { width: 92px; height: 92px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #39424e, #151a21 70%); transition: background .4s, transform .4s; }
.orb[data-mode="waiting"] .halo, .orb[data-mode="arming"] .halo { border-color: #1f4a40; }
.orb[data-mode="waiting"] .core, .orb[data-mode="arming"] .core { background: radial-gradient(circle at 35% 30%, #7af0d4, #1c6f5d 72%); }
.orb[data-mode="asking"] .halo { border-color: var(--amber); box-shadow: 0 0 0 8px rgba(255,193,90,.08), 0 0 60px rgba(255,193,90,.18); }
.orb[data-mode="asking"] .core { background: radial-gradient(circle at 35% 30%, #ffe3ad, #d98b14 72%); transform: scale(1.08); animation: pulse 1s ease-in-out infinite; }
.orb[data-mode="thinking"] .halo { border: 2px solid transparent; border-top-color: var(--violet); border-left-color: rgba(165,148,255,.35); animation: spin 1s linear infinite; }
.orb[data-mode="thinking"] .core { background: radial-gradient(circle at 35% 30%, #d4ccff, #5a48c9 72%); }
.orb[data-mode="speaking"] .halo { border-color: var(--accent); box-shadow: 0 0 0 10px rgba(95,227,195,.07), 0 0 70px rgba(95,227,195,.18); }
.orb[data-mode="speaking"] .core { background: radial-gradient(circle at 35% 30%, #b9ffee, #12a383 72%); animation: talk .5s ease-in-out infinite alternate; }
.orb[data-mode="error"] .core { background: radial-gradient(circle at 35% 30%, #ffb3b3, #9c2a2a 72%); }
@keyframes breathe { 0%,100% { box-shadow: 0 0 0 0 rgba(95,227,195,.0); } 50% { box-shadow: 0 0 0 12px rgba(95,227,195,.07); } }
@keyframes pulse { 50% { transform: scale(1.14); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.1); } }

.state { font-size: 22px; font-weight: 650; margin-top: 6px; text-align: center; }
.hint { color: var(--muted); font-size: 14.5px; text-align: center; min-height: 21px; margin-top: 2px; padding: 0 8px; }
.live { margin-top: 12px; width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line);
  color: var(--faint); font-size: 14px; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live b { color: var(--amber); font-weight: 600; }

.primary { width: 100%; margin-top: 22px; height: 56px; border-radius: 16px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700; }
.primary.stop { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.primary:disabled { opacity: .5; }
.row { display: flex; gap: 10px; width: 100%; margin-top: 10px; }
.row > * { flex: 1; }
.row .primary { margin-top: 0; height: 48px; font-size: 16px; }
.ghost { height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15.5px; padding: 0 12px; }
.ghost.wide { width: 100%; margin-top: 10px; }
.link { background: none; border: 0; color: var(--accent); font-size: 15px; padding: 8px 4px; }
.guard-btn { color: var(--muted); }
.guard-btn.on { color: var(--accent); border-color: #2f6e60; background: #0d1f1b; }
.replay { margin-top: 10px; }
.small { height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; }

.card { width: 100%; margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 6px; }
.card .q { color: var(--muted); font-size: 14.5px; margin-bottom: 6px; }
.card .q::before { content: "שאלת: "; color: var(--faint); }
.card .a { font-size: 16.5px; line-height: 1.6; -webkit-user-select: text; user-select: text; }
.card-actions { display: flex; gap: 14px; justify-content: flex-start; }

/* «add to home screen»: once, in a browser tab */
.a2hs { width: 100%; margin-top: auto; padding: 14px 16px 6px; border-radius: var(--radius); background: #0d1f1b; border: 1px solid #23413b; text-align: right;
  -webkit-user-select: text; user-select: text; }
.home > .guard-btn { margin-bottom: 22px; }
.a2hs-head { display: flex; align-items: center; gap: 10px; }
.a2hs-head img { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.a2hs-head b { font-size: 15.5px; font-weight: 650; }
.a2hs p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.a2hs .a2hs-os { color: var(--text); }
.a2hs .a2hs-os span { display: block; color: var(--accent); font-size: 13px; font-weight: 600; }
.a2hs .link { display: block; margin: 4px 0 0 auto; min-height: 44px; padding: 8px 2px; font-weight: 600; }

.foot { margin-top: auto; padding-top: 18px; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.codes { color: var(--faint); font-size: 13px; flex: 1; min-width: 0; }
.codes b { color: var(--muted); font-weight: 500; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--top) + 6px) 16px 8px; background: rgba(6,8,11,.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-body { max-width: 520px; margin: 0 auto; padding: 12px 16px calc(var(--bottom) + 40px); }
.sheet-body.narrow { padding-top: calc(var(--top) + 48px); text-align: center; }
.setup-mark { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; font-size: 40px; font-weight: 800;
  background: linear-gradient(145deg, #1b2a2a, #0d1515); color: var(--accent); border: 1px solid #23413b; }
.sheet h1 { margin: 0; font-size: 28px; direction: ltr; }
.lead { color: var(--muted); margin: 8px 0 22px; }
.tips { margin-top: 28px; text-align: right; color: var(--muted); font-size: 14px; display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tips b { color: var(--text); }
.err { margin-top: 12px; color: var(--red); font-size: 14.5px; }

.group { padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.note { color: var(--faint); font-size: 13.5px; margin: 10px 0 0; }
.note b { color: var(--muted); font-weight: 600; }
em { font-style: normal; font-size: 12px; color: var(--amber); border: 1px solid rgba(255,193,90,.35); border-radius: 6px; padding: 0 5px; margin-inline-start: 6px; }

.field { display: grid; gap: 6px; margin-top: 10px; text-align: right; }
.field span { font-size: 14px; color: var(--muted); }
.field input, .field select, .add-row input {
  width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 14px; font-size: 16px; outline: none; }
.field input:focus, .add-row input:focus { border-color: #2f6e60; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 14px; border-radius: 19px; background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; }
.chip small { color: var(--faint); font-size: 12px; }
.chip button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: #222a34; color: var(--muted); font-size: 16px; line-height: 1; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; min-width: 0; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-top: 6px; }
.toggle span { flex: 1; font-size: 15.5px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { flex: none; position: relative; width: 50px; height: 30px; border-radius: 15px; background: #2a323d; transition: background .2s; }
.toggle i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #e9eef3; transition: transform .2s; }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(-20px); }

.range { display: grid; gap: 2px; margin-top: 12px; font-size: 15px; }
.range b { color: var(--accent); font-weight: 600; }
/* A large thumb, and the whole track answers a touch: an iPhone moves a native slider only when its small thumb is
   dragged (Nov 22, «מהירות הקול לא מגיב»). The touches go to .rng (app.js, bindRanges); the page still scrolls. */
.rng { display: block; position: relative; height: 52px; touch-action: pan-y; cursor: pointer; }
.rng input[type=range] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 52px; margin: 0; padding: 0;
  background: transparent; pointer-events: none; --p: 50%;
}
.rng input[type=range]:focus { outline: none; }
.rng input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(95, 227, 195, .45), 0 2px 8px rgba(0, 0, 0, .5); }
.rng input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 5px;
  background: linear-gradient(to left, var(--accent) var(--p), #2c3541 var(--p));
}
.rng input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 36px; height: 36px; margin-top: -13px; border: 0; border-radius: 50%;
  background: #f4f7fa; box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.rng input[type=range]::-moz-range-track { height: 10px; border-radius: 5px; background: #2c3541; }
.rng input[type=range]::-moz-range-progress { height: 10px; border-radius: 5px; background: var(--accent); }
.rng input[type=range]::-moz-range-thumb { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f4f7fa; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.rng.drag input[type=range]::-webkit-slider-thumb { transform: scale(1.12); }

.seg { display: flex; gap: 6px; margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 15px; display: grid; place-items: center; padding: 6px 4px; line-height: 1.2; }
.seg button small { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px #2f3a47; }
.seg button.on small { color: var(--muted); }
.seg.dim { opacity: .45; pointer-events: none; }
.dim-group { opacity: .45; }

.shot-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.shot-row img { width: 46px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.file-btn { position: relative; display: inline-grid; place-items: center; flex: 1; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }

.train-card { margin-top: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); padding: 18px 14px; text-align: center; }
.train-say { font-size: 24px; font-weight: 650; min-height: 34px; }
.train-heard { color: var(--muted); font-size: 14.5px; min-height: 22px; margin-top: 8px; text-align: center; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.dots span { width: 9px; height: 9px; border-radius: 50%; background: #2a323d; }
.dots span.ok { background: var(--accent); }
.dots span.now { background: var(--amber); }
.read-me { margin: 12px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 16px; line-height: 1.7; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: 14px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }

#historyList .item { padding: 14px 0; border-bottom: 1px solid var(--line); }
#historyList .when { color: var(--faint); font-size: 12.5px; }
#historyList .q { color: var(--muted); font-size: 14.5px; margin: 2px 0 4px; }
#historyList .a { font-size: 15.5px; line-height: 1.6; -webkit-user-select: text; user-select: text; }
#historyList .empty { color: var(--faint); text-align: center; padding: 40px 0; }

.toast { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(var(--bottom) + 20px); margin: 0 auto; max-width: 480px;
  background: #1c232c; border: 1px solid #2c3642; color: var(--text); padding: 12px 16px; border-radius: 14px; font-size: 15px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.5); }

/* ---------- disguise ---------- */
#disguise { position: fixed; inset: 0; z-index: 50; background: #000; touch-action: none; overflow: hidden; }
#shotCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#fakeHome { position: absolute; inset: 0; color: #fff; overflow: hidden;
  background:
    radial-gradient(120% 70% at 85% 10%, #3a5bd9 0%, rgba(58,91,217,0) 60%),
    radial-gradient(110% 80% at 10% 95%, #d2557a 0%, rgba(210,85,122,0) 55%),
    linear-gradient(170deg, #1a2050 0%, #2b1f4d 55%, #3a1838 100%); }
.fh-grid { position: absolute; left: 0; right: 0; top: calc(var(--top) + 26px); display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 22px; padding: 0 18px; direction: ltr; }
.fh-app { display: grid; justify-items: center; gap: 6px; }
.fh-icon { width: var(--ic, 60px); height: var(--ic, 60px); border-radius: 23%; display: grid; place-items: center; transition: transform .12s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.fh-icon svg { width: 56%; height: 56%; }
.fh-app.press .fh-icon { transform: scale(.9); filter: brightness(.85); }
.fh-label { font-size: 11.5px; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.4); white-space: nowrap; direction: rtl; }
.fh-cal { background: #fff; color: #111; display: grid; grid-template-rows: auto 1fr; justify-items: center; padding-top: 7px; }
.fh-cal .d { font-size: 10px; color: #e0463a; font-weight: 600; }
.fh-cal .n { font-size: calc(var(--ic, 60px) * .48); font-weight: 300; line-height: 1; margin-top: 1px; }
.fh-search { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom) + 118px); height: 30px; padding: 0 14px; border-radius: 15px;
  background: rgba(255,255,255,.18); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); display: flex; align-items: center; gap: 6px; font-size: 13px; }
.fh-dock { position: absolute; left: 10px; right: 10px; bottom: calc(var(--bottom) + 14px); height: 92px; border-radius: 34px; background: rgba(255,255,255,.2);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; justify-items: center; padding: 0 8px; direction: ltr; }

/* ---------- account ---------- */
#authTabs { margin: 0 0 6px; }
#authForm .field[hidden] { display: none !important; }
.ok-msg { margin-top: 12px; color: var(--accent); font-size: 14.5px; }
.acct { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; font-size: 16px; }
.acct span { color: var(--muted); font-size: 14.5px; }
.acct span.warn { color: var(--amber); }
details.pw { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 12px; background: var(--surface); }
details.pw summary { cursor: pointer; padding: 10px 0 4px; color: var(--muted); font-size: 15px; list-style: none; }
details.pw summary::-webkit-details-marker { display: none; }
.link-btn { display: grid; place-items: center; text-decoration: none; }

/* show / hide password */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-left: 52px; }
.pw-wrap .eye { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 10px; }
.pw-wrap .eye:active { color: var(--text); }
