:root {
    /* Rgeeb brand (rgeeb.com) */
    --bg: #0d1b37;              /* deep navy */
    --surface: #13264a;
    --surface-2: #1a3366;       /* brand primary */
    --border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #ffa500;          /* brand amber */
    --accent-hover: #ff8c00;
    --accent-soft: rgba(255, 165, 0, 0.14);
    --orb-face: #ffffff;
    --listen: #22c55e;          /* listening */
    --think: #f59e0b;           /* thinking */
    --speak: #3b82f6;           /* speaking */
    --danger: #ef5a5a;
    --radius: 18px;
    --state-color: var(--muted);
    --level: 0;
}

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

html, body { height: 100%; }

body {
    font-family: 'Cairo', system-ui, sans-serif;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(45, 90, 138, 0.55), transparent 70%),
        var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--orb-face);   /* white bar, as on rgeeb.com, so the navy wordmark stays readable */
    box-shadow: 0 1px 0 rgba(13, 27, 55, 0.08), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 56px; width: auto; display: block; }
.brand-sub {
    color: var(--surface-2);
    font-size: 0.95rem; font-weight: 600;
    padding-inline-start: 12px;
    border-inline-start: 1px solid #e2e8f0;
}

.conn {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; color: #64748b;
    padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 999px;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
body.connected .conn-dot { background: var(--listen); }
body.connected .conn { color: var(--surface-2); }

/* ---------- Layout ---------- */
.layout {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    align-content: start;
}

.stage, .transcript {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ---------- Stage ---------- */
.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px 32px;
    min-height: 520px;
}

body[data-state="listening"]    { --state-color: var(--listen); }
body[data-state="thinking"]     { --state-color: var(--think); }
body[data-state="speaking"]     { --state-color: var(--speak); }
body[data-state="connecting"],
body[data-state="initializing"] { --state-color: var(--muted); }

.orb {
    position: relative;
    width: 188px; height: 188px;
    border: none; border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 28px;
}
.orb:disabled { cursor: default; }
.orb:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.orb-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid var(--state-color);
    opacity: 0.55;
    transform: scale(calc(1 + var(--level) * 0.22));
    transition: transform 80ms linear, border-color 300ms;
}
.orb-core {
    position: absolute; inset: 18px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--orb-face);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 60px -10px var(--state-color);
    transition: box-shadow 300ms;
}
.orb-logo { height: 84px; width: auto; }

body[data-state="idle"] .orb:hover .orb-core { box-shadow: 0 0 70px -6px var(--accent); }
body[data-state="idle"] .orb-ring { border-color: var(--accent); animation: breathe 3.2s ease-in-out infinite; }

body[data-state="connecting"] .orb-ring,
body[data-state="initializing"] .orb-ring {
    border-color: transparent;
    border-top-color: var(--text);
    opacity: 0.8;
    animation: spin 1s linear infinite;
}
body[data-state="thinking"] .orb-ring { animation: breathe 1.1s ease-in-out infinite; }

/* Level meter replaces the logo while in a call */
.meter { display: none; align-items: center; gap: 6px; height: 56px; }
.meter i {
    width: 7px; height: 100%;
    border-radius: 4px;
    background: var(--state-color);
    transform: scaleY(0.12);
    transition: transform 70ms linear, background 300ms;
}
body.in-call .orb-logo { display: none; }
body.in-call .meter { display: flex; }

@keyframes breathe { 50% { transform: scale(1.06); opacity: 0.25; } }
@keyframes spin { to { transform: rotate(360deg); } }

.state-label { font-size: 1.4rem; font-weight: 600; color: var(--text); min-height: 2.2rem; }
.state-hint { color: var(--muted); max-width: 34ch; margin-top: 6px; }
body.in-call .state-hint { visibility: hidden; }

.controls { display: none; gap: 12px; margin-top: auto; padding-top: 32px; }
body.in-call .controls { display: flex; }

.ctrl {
    display: inline-flex; align-items: center; gap: 8px;
    font: inherit; font-weight: 500;
    padding: 12px 22px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: background 150ms, border-color 150ms;
}
.ctrl:hover { border-color: var(--accent); }
.ctrl .icon-off { display: none; }
.ctrl[aria-pressed="true"] { background: rgba(239, 90, 90, 0.14); border-color: rgba(239, 90, 90, 0.4); }
.ctrl[aria-pressed="true"] .icon-on { display: none; }
.ctrl[aria-pressed="true"] .icon-off { display: block; }
.ctrl-end { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctrl-end:hover { background: #d94848; border-color: #d94848; }

.play-audio {
    margin-top: 16px;
    font: inherit;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.error {
    margin-top: 20px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(239, 90, 90, 0.1);
    border: 1px solid rgba(239, 90, 90, 0.35);
    color: #ffb4b4;
    font-size: 0.95rem;
}

/* ---------- Transcript ---------- */
.transcript { display: flex; flex-direction: column; height: 520px; }
.transcript h2 {
    font-size: 0.95rem; font-weight: 600; color: var(--muted);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.lines {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 12px;
}
.lines .empty { color: var(--muted); text-align: center; margin: auto 0; }

.line { max-width: 88%; display: flex; flex-direction: column; gap: 2px; }
.line .who { font-size: 0.75rem; color: var(--muted); }
.line .text {
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
/* RTL: user on the right (start), agent on the left (end) */
.line.user  { align-self: flex-start; }
.line.user .text { background: var(--accent-soft); border-color: rgba(255, 165, 0, 0.35); }
.line.agent { align-self: flex-end; }
.line.interim .text { opacity: 0.6; }

/* ---------- Message composer ---------- */
.composer {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.composer input {
    flex: 1;
    min-width: 0;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 16px;
    outline: none;
    transition: border-color 150ms;
}
.composer input::placeholder { color: var(--muted); }
.composer input:focus { border-color: var(--accent); }
.composer button {
    flex: none;
    width: 44px; height: 44px;
    border: none;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent);
    color: var(--bg);
    cursor: pointer;
    transition: background 150ms, opacity 150ms;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:disabled { opacity: 0.45; cursor: default; }
.composer .icon { transform: scaleX(-1); }   /* point the arrow the RTL way */

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
    .stage { min-height: 0; padding: 32px 16px 24px; }
    .transcript { height: 360px; }
    .topbar { padding: 10px 16px; }
    .brand-logo { height: 44px; }
    .brand-sub { display: none; }
    .orb { width: 160px; height: 160px; }
    .orb-logo { height: 70px; }
}
