:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #eef0f8; --text: #161b33; --muted: #5b6382; --line: #dde1ee;
  --brand: #1e2a5a; --accent: #12a386; --accent-ink: #ffffff; --accent-soft: #dff5ef;
  --good: #12825f; --mid: #b7791f; --bad: #c2413a; --bad-soft: #fde8e6;
  --call: #0f1530; --call-tile: #1b2347; --call-text: #eef1ff;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 27, 60, .06), 0 6px 24px rgba(20, 27, 60, .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1222; --surface: #161b30; --surface-2: #1e2440; --text: #e9ecf8; --muted: #a2a9c6; --line: #2b3254;
    --brand: #c9d2ff; --accent: #3dd6b5; --accent-ink: #0b1a17; --accent-soft: #143a33;
    --good: #4cd3a0; --mid: #e8b24d; --bad: #ff7b72; --bad-soft: #3a1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1222; --surface: #161b30; --surface-2: #1e2440; --text: #e9ecf8; --muted: #a2a9c6; --line: #2b3254;
  --brand: #c9d2ff; --accent: #3dd6b5; --accent-ink: #0b1a17; --accent-soft: #143a33;
  --good: #4cd3a0; --mid: #e8b24d; --bad: #ff7b72; --bad-soft: #3a1d1d;
}
html[dir="rtl"] { --font: "Noto Sans Arabic", "Inter", system-ui, sans-serif; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
main { max-width: 920px; margin: 0 auto; padding: 0 16px 48px; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.err { color: var(--bad); background: var(--bad-soft); padding: .6rem .8rem; border-radius: 10px; margin: .5rem 0; }
[hidden] { display: none !important; }

/* header + steps */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 920px; margin: 0 auto; padding: 14px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); font-weight: 700; text-decoration: none; }
.lang select { padding: 6px 10px; }
.steps { display: flex; gap: 6px; list-style: none; max-width: 920px; margin: 0 auto 18px; padding: 0 16px; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .875rem; min-width: 0; }
.steps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps li b { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--line); color: var(--text); font-size: .75rem; }
.steps li.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.steps li.on b, .steps li.done b { background: var(--accent); color: var(--accent-ink); }

/* cards + forms */
.hero { padding: 8px 0 18px; } .hero p { color: var(--muted); max-width: 60ch; margin: 0; font-size: 1.05rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
label { display: block; margin-bottom: 14px; font-weight: 500; }
label > span:first-child, .label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.more { margin: 4px 0 14px; } .more summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.cv { margin-bottom: 14px; } .cv-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.last { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 18px; border: 1px solid transparent; cursor: pointer; margin: 0; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { padding: 14px 24px; font-size: 1.05rem; width: 100%; margin-top: 4px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

/* test */
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 3px 12px; font-size: .82rem; color: var(--muted); }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.q .qn { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.q p.qt { font-weight: 600; margin: 4px 0 12px; white-space: pre-wrap; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; font-weight: 400; cursor: pointer; }
.opt input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.q .opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.q .opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
/* AI-written text can be in another script than the page (e.g. English inside the Arabic site): each paragraph picks its own direction */
.q .qt, .opt span, .verdict, .caption, #report-body p, #report-body li, #report-body h2, #report-body summary, .better, .bar b, .chip { unicode-bidi: plaintext; }
.verdict { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .94rem; }
.verdict b.ok { color: var(--good); } .verdict b.no { color: var(--bad); }
.scorebox { display: flex; align-items: center; gap: 18px; }
.big-score { font-size: 2.4rem; font-weight: 700; color: var(--brand); }

/* call */
.lobby-video { position: relative; aspect-ratio: 16 / 9; background: var(--call); border-radius: var(--radius); overflow: hidden; margin: 14px 0; }
.lobby-video video, .tile video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.meter { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 6px; background: rgba(255, 255, 255, .2); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: #3dd6b5; transition: width .08s; }
.meter.small { left: auto; width: 70px; bottom: 14px; right: 14px; }
.room { background: var(--call); color: var(--call-text); border-radius: 18px; padding: 14px; margin: 0 -4px; }
.room-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .9rem; margin-bottom: 12px; }
.room-bar .muted { color: #a8b0d6; }
.live { display: flex; align-items: center; gap: 8px; font-weight: 600; } .live i { width: 9px; height: 9px; border-radius: 50%; background: #ff5a5a; animation: pulse 1.6s infinite; }
.clock { font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; aspect-ratio: 4 / 3; background: var(--call-tile); border-radius: 14px; overflow: hidden; display: grid; place-items: center; }
.tile.ai { background: radial-gradient(circle at 50% 35%, #34407a, #1b2347 70%); }
.tile .tag { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, .45); padding: 3px 10px; border-radius: 8px; font-size: .82rem; }
html[dir="rtl"] .tile .tag { left: auto; right: 10px; } html[dir="rtl"] .meter.small { right: auto; left: 14px; }
.tile .state { position: absolute; top: 10px; right: 10px; font-size: .78rem; background: rgba(0, 0, 0, .4); padding: 2px 9px; border-radius: 8px; }
html[dir="rtl"] .tile .state { right: auto; left: 10px; }
.avatar { width: 62%; max-width: 260px; }
.avatar .eyes { animation: blink 5s infinite; transform-origin: 100px 94px; }
.tile.ai.talking .mouth { animation: talk .22s infinite alternate; transform-origin: 100px 122px; }
.ring { position: absolute; inset: 8px; border-radius: 12px; border: 3px solid transparent; transition: border-color .2s; }
.tile.ai.talking .ring { border-color: #3dd6b5; }
.tile.me.listening { box-shadow: inset 0 0 0 3px #3dd6b5; }
.no-cam { width: 110px; height: 110px; border-radius: 50%; background: #34407a; display: grid; place-items: center; font-size: 2.6rem; font-weight: 700; }
.caption { min-height: 4.2em; margin: 12px 2px 4px; padding: 10px 14px; background: rgba(255, 255, 255, .06); border-radius: 12px; font-size: 1.05rem; line-height: 1.5; }
.caption .who { display: block; font-size: .78rem; color: #a8b0d6; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.typed textarea { background: rgba(255, 255, 255, .08); color: var(--call-text); border-color: rgba(255, 255, 255, .2); margin-top: 6px; }
.controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ctl { font: inherit; font-weight: 600; font-size: .92rem; border: 0; border-radius: 999px; padding: 10px 16px; background: rgba(255, 255, 255, .12); color: var(--call-text); cursor: pointer; }
.ctl:hover { background: rgba(255, 255, 255, .2); } .ctl:disabled { opacity: .45; cursor: default; }
.ctl.primary { background: #3dd6b5; color: #0b1a17; } .ctl.danger { background: #e5484d; color: #fff; }

/* report */
.rep-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.ring-score { --p: 0; width: 120px; height: 120px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring-score span { width: 94px; height: 94px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.9rem; font-weight: 700; }
.bar { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 40px; gap: 10px; align-items: center; margin: 8px 0 2px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; } .bar .track i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar + p { margin: 0 0 8px; color: var(--muted); font-size: .92rem; }
ul.clean { padding-inline-start: 1.2em; margin: 0; } ul.clean li { margin-bottom: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
details.ans { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; background: var(--surface); }
details.ans summary { cursor: pointer; font-weight: 600; }
.better { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.transcript p { margin: 0 0 8px; } .transcript b { color: var(--brand); }

/* overlays */
.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 82%, transparent); display: grid; place-content: center; justify-items: center; gap: 12px; z-index: 20; text-align: center; padding: 16px; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 16px 28px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes talk { from { transform: scaleY(.6); } to { transform: scaleY(2.6) scaleX(.85); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 640px) {
  .row2, .row3, .two { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .tile.me { position: absolute; width: 34%; aspect-ratio: 3 / 4; top: 52px; right: 22px; z-index: 2; border: 2px solid rgba(255, 255, 255, .25); }
  html[dir="rtl"] .tile.me { right: auto; left: 22px; }
  .room { position: relative; }
  .tile.me .tag, .tile.me .meter { display: none; }
  .steps li span { display: none; } .steps li { justify-content: center; }
  .bar { grid-template-columns: 1fr 1.4fr 34px; }
}
@media print {
  .top, .steps, .foot, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; } .card, details.ans { box-shadow: none; break-inside: avoid; }
  details.ans { display: block; } details.ans > *:not(summary) { display: block; }
}
