:root {
    /* Smicos Brand Colors */
    --bg-base: #f8fafc;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --accent: #3EAEF0;            /* Smicos Cyan/Blue */
    --accent-glow: rgba(62, 174, 240, 0.4);
    --accent-2: #2dd4bf;          /* teal (listening) */
    --danger: #E84545;            /* Smicos Coral/Red */
    --danger-glow: rgba(232, 69, 69, 0.4);
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(15, 23, 42, 0.06);
    --success: #10b981;
    --shadow: 0 10px 40px rgba(30, 41, 59, 0.08);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    height: 100vh; height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.app-wrapper {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1.1fr) auto;
    position: relative;
    background:
        radial-gradient(1000px 680px at 50% 0%, rgba(62,174,240,0.12), transparent 60%),
        radial-gradient(780px 560px at 100% 100%, rgba(62,174,240,0.05), transparent 55%);
    min-height: 0;
}

/* ── Header ─────────────────────────────────────────────── */
.header { padding: 1.25rem 1.5rem; z-index: 10; }
.header-content { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.status-pill {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    font-size: 0.78rem; font-weight: 600;
    display: flex; align-items: center; gap: 0.5rem;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    color: var(--text-primary);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); transition: 0.3s; }
.status-pill.success .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-pill.error   .status-dot { background: var(--danger);  box-shadow: 0 0 8px var(--danger); }
.status-pill.loading .status-dot { background: var(--accent);  animation: pulse-dot 1s infinite; }
.status-pill.info    .status-dot { background: var(--text-muted); }
@keyframes pulse-dot {
    0% { transform: scale(0.7); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.7); opacity: 0.5; }
}

.metrics-pill {
    display: flex; align-items: center; gap: 9px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}
.sig { display: flex; gap: 3px; align-items: flex-end; height: 13px; }
.sig i { width: 3px; border-radius: 2px; background: var(--accent-2); display: block; }
.sig i:nth-child(1){ height: 5px; } .sig i:nth-child(2){ height: 9px; } .sig i:nth-child(3){ height: 13px; }

.latency-display {
    font-size: 0.74rem; font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    white-space: nowrap;
    display: flex; align-items: center; gap: 7px;
}
.latency-display.has-value { color: var(--text-primary); }
.latency-display .sep { width: 1px; height: 13px; background: var(--glass-border); display: inline-block; }
.latency-display .metric { display: inline-flex; align-items: center; gap: 4px; }
.latency-display svg { width: 13px; height: 13px; opacity: 0.7; }

.icon-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 1.1rem; cursor: pointer; transition: color 0.2s;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
}
.icon-btn:hover { color: var(--text-primary); background: rgba(0,0,0,0.05); }

/* ── Orb stage ──────────────────────────────────────────── */
.orb-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2.25rem; position: relative; z-index: 5; overflow: hidden; min-height: 0;
}
.ai-orb {
    position: relative;
    width: 300px; height: 300px;
    display: flex; align-items: center; justify-content: center;
    animation: float 8s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#orb-canvas { position: relative; z-index: 2; }
.ai-orb .ring { position: absolute; border-radius: 50%; border: 1px solid rgba(62,174,240,0.12); }
.ai-orb .ring.r1 { width: 300px; height: 300px; }
.ai-orb .ring.r2 { width: 232px; height: 232px; }
.ai-orb .ring.r3 { width: 168px; height: 168px; }

.transcription-live {
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--text-muted); text-align: center; font-weight: 600;
    max-width: 85%; transition: opacity 0.3s ease; margin-top: 0.5rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Transcript ─────────────────────────────────────────── */
.transcript-wrapper { width: 100%; min-height: 0; padding: 0 1.5rem; position: relative; z-index: 10; overflow: hidden; }
.transcript {
    height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.7rem;
    padding-bottom: 1rem; scroll-behavior: smooth;
    max-width: 680px; margin: 0 auto;
    -ms-overflow-style: none; scrollbar-width: none;
    mask-image: linear-gradient(to bottom, white 0%, white 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, white 0%, white 90%, transparent 100%);
}
.transcript::-webkit-scrollbar { display: none; }

.message { display: flex; flex-direction: column; max-width: 85%; animation: slideUp 0.3s ease forwards; }
.message.you { align-self: flex-end; align-items: flex-end; }
.message.ai { align-self: flex-start; align-items: flex-start; }
.message.system { align-self: center; align-items: center; max-width: 100%; }

.bubble {
    padding: 0.7rem 1rem; border-radius: 16px;
    font-size: 0.92rem; line-height: 1.45; word-wrap: break-word;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}
.message.you .bubble {
    background: #ffffff; color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-bottom-right-radius: 5px;
}
.message.ai .bubble {
    background: rgba(62, 174, 240, 0.10);
    color: var(--text-primary);
    border: 1px solid rgba(62, 174, 240, 0.22);
    border-bottom-left-radius: 5px;
}
.message.system .bubble {
    background: transparent; color: var(--text-muted);
    font-size: 0.75rem; padding: 0.2rem; box-shadow: none; backdrop-filter: none;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Feedback row */
.feedback-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-left: 4px; }
.feedback-btn {
    background: transparent; border: none; border-radius: 50%;
    color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.feedback-btn:hover:not(:disabled) { background: rgba(0,0,0,0.05); color: var(--text-primary); }
.feedback-btn:active:not(:disabled) { transform: scale(0.95); }
.feedback-btn:disabled { cursor: default; opacity: 0.5; }
.feedback-btn.selected-up { color: var(--success); background: rgba(16,185,129,0.1); opacity: 1; }
.feedback-btn.selected-down { color: var(--danger); background: rgba(232,69,69,0.1); opacity: 1; }
.feedback-confirm { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); opacity: 0; margin-left: 4px; transition: opacity 0.3s; }
.feedback-confirm.visible { opacity: 1; }

/* Typing / thinking indicator */
.typing-indicator {
    display: flex; align-items: center; gap: 5px;
    padding: 0.7rem 1rem; background: rgba(62,174,240,0.10);
    border: 1px solid rgba(62,174,240,0.22);
    border-radius: 16px; border-bottom-left-radius: 5px; width: fit-content;
}
.typing-indicator span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: typing-bounce 1.2s infinite ease-in-out; }
.typing-indicator span:nth-child(1){ animation-delay: 0s; }
.typing-indicator span:nth-child(2){ animation-delay: 0.2s; }
.typing-indicator span:nth-child(3){ animation-delay: 0.4s; }
@keyframes typing-bounce { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* Markdown inside AI bubbles */
.message.ai .bubble p { margin: 0 0 0.5em; } .message.ai .bubble p:last-child { margin-bottom: 0; }
.message.ai .bubble a { color: var(--accent); word-break: break-all; text-decoration: underline; }
.message.ai .bubble a:hover { opacity: 0.8; }
.message.ai .bubble ul, .message.ai .bubble ol { padding-left: 1.2em; margin: 0.4em 0; }
.message.ai .bubble li { margin-bottom: 0.25em; }
.message.ai .bubble strong { font-weight: 700; } .message.ai .bubble em { font-style: italic; }
.message.ai .bubble code { background: rgba(62,174,240,0.12); border-radius: 4px; padding: 0.1em 0.35em; font-size: 0.85em; font-family: 'Courier New', monospace; }

/* ── Controls ───────────────────────────────────────────── */
.controls-area {
    padding: 1rem 1.5rem 1.5rem;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    z-index: 20; flex-shrink: 0;
    background: linear-gradient(to top, var(--bg-base) 70%, transparent);
}
.active-controls { display: flex; gap: 1rem; width: 100%; max-width: 520px; align-items: center; justify-content: center; }
.control-btn {
    padding: 0.85rem 1.6rem; border-radius: 100px; border: none;
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 0.5rem; transition: all 0.2s ease; color: white;
}
.control-btn i { font-size: 0.9rem; }
.control-btn.primary {
    background: linear-gradient(135deg, #68c7f5, var(--accent));
    box-shadow: 0 10px 28px var(--accent-glow);
    width: 100%; max-width: 320px; justify-content: center;
}
.control-btn.primary:hover { transform: translateY(-2px); }
.control-btn.primary:active { transform: scale(0.98); }
.control-btn.danger { background: white; border: 1px solid var(--glass-border); color: var(--danger); box-shadow: var(--shadow); }
.control-btn.danger:active { background: rgba(232,69,69,0.1); }
.control-btn.icon-only { padding: 0; width: 54px; height: 54px; justify-content: center; border-radius: 50%; flex-shrink: 0; }

/* VAD status */
.vad-status {
    flex: 1; height: 54px; border-radius: 100px;
    border: 1px solid var(--glass-border); background: var(--card-bg);
    display: flex; align-items: center; padding: 0 0.5rem; box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}
.vad-icon-wrapper {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--bg-base); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; margin-right: 1rem; transition: all 0.3s ease;
}
#vad-status-text { font-size: 0.92rem; font-weight: 600; color: var(--text-muted); transition: color 0.3s ease; }
.vad-status.detecting .vad-icon-wrapper { background: var(--accent-2); color: white; box-shadow: 0 4px 15px rgba(45,212,191,0.4); animation: vad-pulse 1s infinite; }
.vad-status.detecting #vad-status-text { color: var(--accent-2); }
@keyframes vad-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }

.hidden { display: none !important; }

/* ── Developer Settings Modal ───────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 1; transition: opacity 0.2s; }
.modal.hidden { opacity: 0; pointer-events: none; }
.modal-content { background: white; width: 90%; max-width: 700px; height: 85vh; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); display: flex; flex-direction: column; overflow: hidden; transform: scale(1); transition: transform 0.2s; }
.modal.hidden .modal-content { transform: scale(0.95); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }
.dev-header-tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 4px; border-radius: 8px; }
.dev-tab { background: transparent; border: none; padding: 6px 12px; font-size: 0.9rem; font-weight: 500; color: var(--text-muted); border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.dev-tab.active { background: white; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.modal-body { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.dev-view { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.dev-view.hidden { display: none; }
.form-row { display: flex; gap: 16px; } .form-row .form-group { flex: 1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.form-group .required { color: var(--danger); }
.form-group input, .form-group textarea, .form-group select { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.9rem; font-family: inherit; transition: border-color 0.2s; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); }
#yaml-editor { flex: 1; width: 100%; font-family: 'Courier New', Courier, monospace; font-size: 13px; line-height: 1.4; padding: 12px; border: 1px solid #ccc; border-radius: 6px; resize: none; background: #fdfdfd; color: #333; }
#yaml-editor:focus { outline: none; border-color: var(--accent); }
.dev-message { font-size: 0.85rem; min-height: 1.2rem; }
.dev-message.success { color: var(--success); } .dev-message.error { color: var(--danger); }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--glass-border); display: flex; justify-content: flex-end; align-items: center; gap: 12px; background: #fafafa; }
.dev-api-key-input { margin-right: auto; padding: 8px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.85rem; width: 220px; }
.dev-api-key-input:focus { outline: none; border-color: var(--accent); }
.secondary-btn, .primary-btn { padding: 8px 16px; border-radius: 6px; font-size: 0.9rem; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; }
.secondary-btn { background: white; border: 1px solid #ccc; color: var(--text-primary); }
.secondary-btn:hover { background: #f0f0f0; }
.primary-btn { background: var(--accent); color: white; }
.primary-btn:hover { background: #3299d6; } .primary-btn:active { transform: scale(0.97); }
