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

body {
    font-family: system-ui, sans-serif;
    background: #0f0f0f;
    color: #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 28px;
}

h1 {
    font-size: 1.3rem;
    font-weight: 400;
    color: #666;
    letter-spacing: 0.05em;
}

/* Mode selector */
.mode-selector {
    display: flex;
    gap: 0;
    border-radius: 9999px;
    border: 1px solid #2a2a2a;
    overflow: hidden;
}

.mode-btn {
    padding: 8px 24px;
    background: transparent;
    color: #555;
    border: none;
    border-radius: 0;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    letter-spacing: 0.04em;
}

.mode-btn:hover {
    background: #1a1a1a;
}

.mode-btn.active-realtime {
    background: #0f2a1a;
    color: #4ade80;
}

.mode-btn.active-pipeline {
    background: #0a1a2a;
    color: #60a5fa;
}

/* Orb — pulses when the agent speaks */
#orb {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: #161616;
    border: 2px solid #2a2a2a;
    transition: background 0.4s, border-color 0.4s, box-shadow 0.4s;
}

/* Idle state per mode */
#orb.realtime {
    border-color: #1a3a25;
}

#orb.pipeline {
    border-color: #1a2a3a;
}

/* Speaking states */
#orb.realtime.speaking {
    background: radial-gradient(circle, #4ade8030, #4ade8008);
    border-color: #4ade80;
    box-shadow: 0 0 32px #4ade8050;
}

#orb.pipeline.speaking {
    background: radial-gradient(circle, #60a5fa30, #60a5fa08);
    border-color: #60a5fa;
    box-shadow: 0 0 32px #60a5fa50;
}

/* Mode label under orb */
#mode-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.3s, color 0.3s;
}

#mode-label.realtime { color: #4ade80; opacity: 1; }
#mode-label.pipeline { color: #60a5fa; opacity: 1; }

#status {
    font-size: 0.85rem;
    color: #444;
    min-height: 1.2em;
}

#status.connected {
    color: #4ade80;
}

#status.error {
    color: #f87171;
}

.buttons {
    display: flex;
    gap: 12px;
}

button {
    padding: 12px 36px;
    border-radius: 9999px;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#btn-connect {
    background: #4ade80;
    color: #000;
    font-weight: 600;
}

#btn-connect:hover {
    background: #22c55e;
}

#btn-connect:disabled {
    background: #222;
    color: #555;
    cursor: not-allowed;
}

#btn-disconnect {
    background: #222;
    color: #f87171;
    display: none;
}

#btn-disconnect:hover {
    background: #2d2d2d;
}

#log {
    font-size: 0.75rem;
    color: #444;
    max-width: 420px;
    width: 100%;
    text-align: center;
    line-height: 1.6;
    min-height: 2.5em;
}

#access-token-input {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 9999px;
    color: #eee;
    font-size: 0.85rem;
    padding: 10px 20px;
    width: 260px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

#access-token-input::placeholder { color: #444; }
#access-token-input:focus { border-color: #555; }

/* ── Data Messages panel ── */
.data-panel {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.data-panel-header span {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #444;
}

#btn-clear-log {
    padding: 4px 14px;
    background: transparent;
    border: 1px solid #2a2a2a;
    border-radius: 9999px;
    color: #444;
    font-size: 0.7rem;
    cursor: pointer;
}

#btn-clear-log:hover { border-color: #444; color: #888; }

#data-log {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    height: 260px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
}

#data-log:empty::after {
    content: "Aucun message pour l'instant…";
    color: #2a2a2a;
    font-style: italic;
}

.msg-entry { display: flex; flex-direction: column; gap: 2px; }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.msg-time { color: #333; }

.msg-dir {
    font-weight: 600;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 3px;
}

.msg-entry.sent    .msg-dir { background: #2a2000; color: #fbbf24; }
.msg-entry.received .msg-dir { background: #1a1a2a; color: #818cf8; }

.msg-type {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.type-queue_update   { background: #0a1a2a; color: #60a5fa; }
.type-phase_change   { background: #1a0a2a; color: #a78bfa; }
.type-handover       { background: #2a0a0a; color: #f87171; }
.type-speaker_turn   { background: #0a2a10; color: #4ade80; }
.type-session_info   { background: #1a1a1a; color: #9ca3af; }
.type-raise_hand     { background: #2a1a00; color: #fb923c; }
.type-request_handover { background: #2a0a0a; color: #f87171; }
.type-join_session   { background: #0a1a1a; color: #34d399; }
.type-raw            { background: #1a1a1a; color: #666; }

.msg-json {
    color: #444;
    padding-left: 16px;
    white-space: pre-wrap;
    word-break: break-all;
    cursor: pointer;
    user-select: text;
}

.msg-json.collapsed {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;
    color: #333;
}

/* ── Send controls ── */
.send-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.send-controls input[type="text"] {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 9999px;
    color: #eee;
    font-size: 0.8rem;
    padding: 8px 16px;
    width: 200px;
    outline: none;
    transition: border-color 0.2s;
}

.send-controls input[type="text"]::placeholder { color: #444; }
.send-controls input[type="text"]:focus { border-color: #555; }

.send-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-send {
    padding: 7px 18px;
    border-radius: 9999px;
    border: 1px solid #2a2a2a;
    background: #111;
    color: #888;
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-send:hover:not(:disabled) { border-color: #555; color: #eee; background: #1a1a1a; }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── LiveKit Logs panel ── */
.lk-panel {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 40px;
}

.lk-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.lk-panel-header > span {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #444;
}

.lk-panel-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#lk-level-filter {
    appearance: none;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 9999px;
    color: #555;
    font-size: 0.7rem;
    padding: 3px 12px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

#lk-level-filter:hover { border-color: #444; }

#btn-clear-lk {
    padding: 4px 14px;
    background: transparent;
    border: 1px solid #2a2a2a;
    border-radius: 9999px;
    color: #444;
    font-size: 0.7rem;
    cursor: pointer;
}

#btn-clear-lk:hover { border-color: #444; color: #888; }

#lk-log {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    height: 300px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
}

#lk-log:empty::after {
    content: "Aucun log LiveKit pour l'instant…";
    color: #2a2a2a;
    font-style: italic;
}

.lk-entry {
    display: flex;
    align-items: baseline;
    gap: 7px;
    line-height: 1.5;
}

.lk-time { color: #2a2a2a; flex-shrink: 0; font-size: 0.68rem; }

.lk-level {
    font-weight: 600;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.lk-level-trace { background: #1a1a1a; color: #444; }
.lk-level-debug { background: #0f1a2a; color: #3b82f6; }
.lk-level-info  { background: #0a2010; color: #4ade80; }
.lk-level-warn  { background: #2a1800; color: #fb923c; }
.lk-level-error { background: #2a0a0a; color: #f87171; }
.lk-level-event { background: #1a0a2a; color: #a78bfa; }

.lk-msg { color: #4a4a4a; word-break: break-word; flex: 1; }

.lk-ctx {
    color: #333;
    cursor: pointer;
    margin-left: 4px;
    transition: color 0.15s;
}

.lk-ctx:hover { color: #555; }

.lk-ctx.collapsed {
    display: inline-block;
    max-width: 340px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}