:root {
  --teal: #5ce0e5;
  --blue: #024caf;
  --gold: #f7c224;
  --aubergine: #2a1b30;
  --rose: #8b3e68;
  --bg: #160e1a;
  --card: #2a1b30;
  --card-2: #34233c;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f1f8;
  --muted: #b9a9c2;
  --good: #4fd1a5;
  --warn: #f7c224;
  --bad: #ff7a8a;
  --gradient: linear-gradient(120deg, var(--teal), var(--blue));
  --radius: 16px;
  --font-ar: "Tajawal", system-ui, sans-serif;
  --font-en: "Poppins", system-ui, sans-serif;
  --font-display: "Bebas Neue", "Poppins", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
html[lang="en"] body { font-family: var(--font-en); font-size: 15px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(22, 14, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--font-display);
  font-size: 32px; letter-spacing: 1px; line-height: 1;
  text-decoration: none;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.lang-toggle {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 14px; color: var(--muted);
}
.lang-toggle:hover { color: var(--text); border-color: var(--teal); }

main { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- shared ---------- */
h1, h2, h3 { margin: 0; line-height: 1.25; }
.hero h1 {
  font-size: 28px; font-weight: 700;
}
html[lang="en"] .hero h1 { font-family: var(--font-display); font-size: 40px; font-weight: 400; letter-spacing: 0.5px; }
.hero p { color: var(--muted); margin: 8px 0 0; }
.section { margin-top: 24px; }
.label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin-top: 8px; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 22px; font-weight: 600;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #24170a; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--teal); }
.btn-block { width: 100%; }

/* ---------- setup ---------- */
.scenarios { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .scenarios { grid-template-columns: 1fr; } }
.scenario {
  text-align: start; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.scenario[aria-pressed="true"] { border-color: var(--teal); background: var(--card-2); }
.scenario .title { font-weight: 700; font-size: 17px; }
.scenario .who { color: var(--muted); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--gradient) border-box; border-color: transparent; color: #fff; font-weight: 600; }

.toggle { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 14px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--teal); }

textarea.goal, .composer textarea, .retry textarea {
  width: 100%; resize: vertical; min-height: 64px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
textarea:focus { border-color: var(--teal); outline: none; }

.start-row { margin-top: 28px; }

/* ---------- chat ---------- */
.chat-head {
  position: sticky; top: 57px; z-index: 4;
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--gradient);
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .name { font-weight: 700; }
.chat-head .meta { color: var(--muted); font-size: 13px; }

.messages { display: flex; flex-direction: column; gap: 10px; padding: 16px 0 140px; }
.msg {
  max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word;
}
.msg.persona { align-self: flex-start; background: var(--card-2); border-start-start-radius: 4px; }
.msg.learner { align-self: flex-end; background: var(--rose); border-start-end-radius: 4px; }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 14px; background: var(--card-2); border-radius: 18px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  background: rgba(22, 14, 26, 0.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.composer-inner { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; max-height: 140px; resize: none; }
.composer .send { flex: none; padding: 12px 18px; }
.closed-banner { max-width: 720px; margin: 0 auto; display: flex; gap: 12px; align-items: center; justify-content: space-between; }

/* ---------- scoring ---------- */
.scoring { text-align: center; padding: 60px 0; }
.spinner {
  width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%;
  border: 4px solid var(--card-2); border-top-color: var(--teal); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- scorecard ---------- */
.score-hero { display: flex; gap: 20px; align-items: center; }
.ring { width: 112px; height: 112px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .value {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 40px; letter-spacing: 1px;
}
.ring .value small { font-family: var(--font-en); font-size: 12px; color: var(--muted); display: block; margin-top: -6px; }
.score-hero .summary { flex: 1; }
@media (max-width: 480px) { .score-hero { flex-direction: column; text-align: center; } }

.criteria { display: flex; flex-direction: column; gap: 14px; }
.criterion .row { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.bar { height: 8px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--gradient); }
.criterion details { margin-top: 6px; }
.criterion summary { color: var(--teal); font-size: 14px; cursor: pointer; }
.criterion p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

.moment { display: flex; flex-direction: column; gap: 10px; }
.quote { border-inline-start: 3px solid var(--rose); padding-inline-start: 12px; font-style: normal; }
.issue { color: var(--muted); }
.better { background: rgba(92, 224, 229, 0.08); border: 1px solid rgba(92, 224, 229, 0.25); border-radius: 12px; padding: 10px 12px; }
.better .tag, .quote .tag { display: block; font-size: 12px; color: var(--teal); margin-bottom: 2px; }
.quote .tag { color: #e3a3c6; }

.strengths { margin: 0; padding-inline-start: 20px; }
.strengths li { margin: 4px 0; }

.retry { border: 2px solid var(--gold); }
.retry h3 { color: var(--gold); }
.verdict { margin-top: 12px; padding: 12px; border-radius: 12px; }
.verdict.good { background: rgba(79, 209, 165, 0.12); border: 1px solid rgba(79, 209, 165, 0.4); }
.verdict.bad { background: rgba(247, 194, 36, 0.1); border: 1px solid rgba(247, 194, 36, 0.4); }

.stack > * + * { margin-top: 16px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.actions .btn { flex: 1; min-width: 160px; }

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

/* ---------- voice ---------- */
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); font-size: 18px; line-height: 1;
}
.icon-btn[aria-pressed="true"] { border-color: var(--teal); }
.msg.persona { position: relative; padding-inline-end: 40px; }
.replay {
  position: absolute; inset-inline-end: 8px; bottom: 8px;
  width: 26px; height: 26px; border-radius: 50%; border: 0; font-size: 11px;
  background: rgba(92, 224, 229, 0.15); color: var(--teal);
}
.replay:hover { background: rgba(92, 224, 229, 0.3); }
.msg.pending { opacity: 0.7; font-style: italic; }

.mic {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--gradient); display: grid; place-items: center;
  box-shadow: 0 0 0 0 rgba(92, 224, 229, 0.5);
}
.mic[disabled] { opacity: 0.5; }
.mic-icon {
  width: 14px; height: 22px; border: 3px solid #fff; border-radius: 8px; position: relative;
}
.mic-icon::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 2px; height: 6px; background: #fff; transform: translateX(-50%);
}

.composer-inner.recording { align-items: center; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); animation: pulse 1s infinite; flex: none; }
.rec-label { flex: 1; color: var(--muted); }
.rec-time { font-variant-numeric: tabular-nums; color: var(--text); min-width: 40px; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); } }

/* =========================================================
   Interview call (video-call style)
   ========================================================= */
body.in-call { overflow: hidden; }
body.in-call .topbar { display: none; }
body.in-call main { max-width: none; padding: 0; }

.call {
  position: fixed; inset: 0; z-index: 30; overflow: hidden;
  display: block; color: #fff; background: #120c16;
  font-family: inherit;
}

/* ---- scenes ---- */
.scene { position: absolute; inset: 0; filter: blur(1.5px); transform: scale(1.03); }
.scene > div { position: absolute; }
.scene-office .scene {
  background:
    radial-gradient(120% 80% at 50% 35%, #4b3a57 0%, #2a1d33 55%, #170f1c 100%);
}
.scene-office .scene-a { /* window with blinds */
  top: 8%; inset-inline-start: 6%; width: 34%; height: 46%; border-radius: 6px;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.10) 0 10px, rgba(255,255,255,0.02) 10px 18px),
    linear-gradient(160deg, #8fd3e8 0%, #3d7fa8 100%);
  opacity: 0.55; box-shadow: 0 0 0 10px rgba(255,255,255,0.05);
}
.scene-office .scene-b { /* shelf */
  top: 20%; inset-inline-end: 6%; width: 26%; height: 34%;
  background:
    linear-gradient(180deg, transparent 0 31%, #3b2a46 31% 34%, transparent 34% 64%, #3b2a46 64% 67%, transparent 67%),
    linear-gradient(90deg, #5a3e6b 0 8%, transparent 8% 14%, #2f6f78 14% 22%, transparent 22% 30%, #8b3e68 30% 36%, transparent 36%);
  opacity: 0.6;
}
.scene-office .scene-c { /* desk edge */
  bottom: 0; left: 0; right: 0; height: 9%;
  background: linear-gradient(180deg, #3a2a2a, #241818); opacity: 0.9;
}
.scene-shop .scene {
  background: radial-gradient(120% 80% at 50% 30%, #3e4f63 0%, #22303f 55%, #121a24 100%);
}
.scene-shop .scene-a, .scene-shop .scene-b { /* shelves with products */
  top: 10%; width: 36%; height: 58%;
  background:
    linear-gradient(180deg, transparent 0 22%, #cfd8e3 22% 24%, transparent 24% 48%, #cfd8e3 48% 50%, transparent 50% 74%, #cfd8e3 74% 76%, transparent 76%),
    repeating-linear-gradient(90deg, #f7c224 0 9%, transparent 9% 12%, #5ce0e5 12% 19%, transparent 19% 23%, #ff7a8a 23% 30%, transparent 30% 34%, #ffffff 34% 40%, transparent 40% 45%);
  opacity: 0.32;
}
.scene-shop .scene-a { inset-inline-start: 2%; }
.scene-shop .scene-b { inset-inline-end: 2%; }
.scene-shop .scene-c { bottom: 0; left: 0; right: 0; height: 10%; background: linear-gradient(180deg, #2b3746, #18212c); }

/* ---- character ---- */
.char-host {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  /* Phones: large enough that the face sits around mid-screen, above the captions. */
  height: 84dvh; aspect-ratio: 400 / 520;
  display: flex; align-items: flex-end;
}
.char-host .character { width: 100%; height: 100%; display: block; overflow: visible; }
.c-head, .c-back { transform-box: view-box; transform-origin: 200px 330px; animation: sway 6s ease-in-out infinite; }
.c-eyes { transform-box: fill-box; transform-origin: center; transition: transform 70ms ease; }
.c-irises { transition: transform 300ms ease; }
.char-host.blink .c-eyes { transform: scaleY(0.08); }
.char-host[data-mode="thinking"] .c-irises { transform: translate(-6px, -4px); }
.char-host[data-mode="listening"] .c-head,
.char-host[data-mode="listening"] .c-back { animation: nod 2.4s ease-in-out infinite; }
.char-host[data-mode="speaking"] .c-head,
.char-host[data-mode="speaking"] .c-back { animation: talk 3.2s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(0.4deg); } }
@keyframes nod { 0%, 100% { transform: rotate(-1.5deg) translateY(0); } 50% { transform: rotate(-1.5deg) translateY(4px); } }
@keyframes talk { 0%, 100% { transform: rotate(0deg); } 30% { transform: rotate(0.8deg) translateY(-2px); } 70% { transform: rotate(-0.6deg); } }

/* ---- top bar ---- */
.call-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, rgba(10, 6, 12, 0.65), transparent);
}
.brand-mini {
  font-family: var(--font-display); font-size: 26px; letter-spacing: 1px; line-height: 1;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.45); font-variant-numeric: tabular-nums; font-family: var(--font-en); font-size: 14px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(79, 209, 165, 0.25); }

.name-tag {
  position: absolute; z-index: 2; inset-inline-start: 16px; top: calc(64px + env(safe-area-inset-top));
  padding: 8px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px);
}
.nt-name { font-weight: 700; }
.nt-meta { font-size: 13px; color: #d8cce0; }

.self-view {
  position: absolute; z-index: 3; inset-inline-end: 16px; top: calc(64px + env(safe-area-inset-top));
  width: 104px; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35); background: #000; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.self-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self-label { position: absolute; bottom: 4px; inset-inline-start: 6px; font-size: 11px; text-shadow: 0 1px 2px #000; }

/* ---- bottom: caption, status, controls ---- */
/* Realistic video persona: fills the stage; the illustrated one hides once it plays. */
.avatar-stage { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.avatar-video {
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: center 30%;
  opacity: 0; transition: opacity 0.5s ease;
}
.call.has-video .avatar-video { opacity: 1; }
.call.has-video .char-host { visibility: hidden; }
.call.has-video .scene { visibility: hidden; }
.call.has-video { background: #0e0a12; }
.call-bottom {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(10, 6, 12, 0.92) 0%, rgba(10, 6, 12, 0.7) 60%, transparent 100%);
}
.caption {
  max-width: 640px; width: 100%; text-align: center; font-size: 18px; line-height: 1.55;
  padding: 10px 16px; border-radius: 14px; background: rgba(0, 0, 0, 0.55);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.caption.off { display: none; }
.call-status { min-height: 22px; font-size: 14px; color: #d8cce0; text-align: center; }
.call[data-phase="your-turn"] .call-status { color: var(--gold); font-weight: 600; }
.call[data-phase="listening"] .call-status { color: var(--teal); }
.call-error { max-width: 640px; text-align: center; font-size: 14px; color: #ffd0d6; background: rgba(255, 122, 138, 0.18); padding: 8px 12px; border-radius: 10px; }

.controls { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: nowrap; }
.ctrl {
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.14); color: #fff; flex: none;
}
.ctrl svg { width: 22px; height: 22px; }
.ctrl:hover { background: rgba(255, 255, 255, 0.24); }
.ctrl[aria-pressed="true"] { background: rgba(92, 224, 229, 0.28); color: var(--teal); }
.ctrl.small { width: 40px; height: 40px; background: rgba(0, 0, 0, 0.45); }
.ctrl.end { background: #e5484d; }
.ctrl.end:hover { background: #f05358; }
.ctrl.end svg { transform: rotate(135deg); }
.mic-wrap { position: relative; }
.mic-main {
  width: 72px; height: 72px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--gradient); color: #fff; box-shadow: 0 8px 24px rgba(2, 76, 175, 0.45);
}
.mic-main svg { width: 30px; height: 30px; }
.mic-main[disabled] { opacity: 0.45; }
.call[data-phase="your-turn"] .mic-main:not([disabled]) { animation: ready 1.8s ease-in-out infinite; }
.mic-main.recording { background: var(--gold); color: #24170a; animation: none; box-shadow: 0 0 0 8px rgba(247, 194, 36, 0.25); }
@keyframes ready { 0%, 100% { box-shadow: 0 0 0 0 rgba(92, 224, 229, 0.55); } 50% { box-shadow: 0 0 0 14px rgba(92, 224, 229, 0); } }
.ctrl.cancel { position: absolute; top: -10px; inset-inline-end: -14px; width: 32px; height: 32px; background: #e5484d; }
.ctrl.cancel svg { width: 16px; height: 16px; }

.type-bar { display: flex; gap: 8px; width: 100%; max-width: 640px; align-items: flex-end; }
.type-bar textarea {
  flex: 1; min-height: 48px; max-height: 120px; resize: none; padding: 12px;
  border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.5); color: #fff;
}

/* ---- finished + transcript ---- */
.finished {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 6, 12, 0.6); backdrop-filter: blur(4px);
}
.finished-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-align: center; }
.finished-card h2 { margin-bottom: 6px; }
.finished-card .btn { margin-top: 18px; }

.sheet {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; max-height: 70%;
  display: flex; flex-direction: column; background: var(--card); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head .btn { padding: 8px 14px; }
.sheet-body { overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.t-line { display: flex; flex-direction: column; gap: 2px; }
.t-who { font-size: 12px; color: var(--teal); }
.t-line.learner .t-who { color: #e3a3c6; }

@media (min-width: 700px) {
  .char-host { height: min(88dvh, 820px); }
  .caption { font-size: 20px; }
}

/* Hands-free mic: armed = listening for the learner, paused = off until tapped. */
.mic-main.armed { box-shadow: 0 0 0 0 rgba(92, 224, 229, 0.55); animation: listen-ring 1.6s ease-out infinite; }
.mic-main.paused { background: #3a2e40; color: #b9a9c2; }
@keyframes listen-ring { 0% { box-shadow: 0 0 0 0 rgba(92, 224, 229, 0.5); } 100% { box-shadow: 0 0 0 18px rgba(92, 224, 229, 0); } }
@media (prefers-reduced-motion: reduce) { .mic-main.armed { animation: none; box-shadow: 0 0 0 3px rgba(92, 224, 229, 0.6); } }

/* Access-code gate (private beta) */
.gate { display: grid; gap: 12px; max-width: 420px; margin-top: 20px; }
.gate .error:empty { display: none; }
.gate input { font: inherit; font-size: 18px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: inherit; letter-spacing: 0.04em; }
.gate input:focus { outline: 2px solid var(--teal); outline-offset: 2px; }
