/* VoicePipe — Dark-mode minimal UI */

:root {
    --bg: #0f0f13;
    --surface: #1a1a24;
    --text: #e4e4ed;
    --text-dim: #8888a0;
    --accent: #6c63ff;
    --recording: #ef4444;
    --success: #22c55e;
    --radius: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 480px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

#connection-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
}
#connection-status.connected    { background: #22c55e22; color: var(--success); }
#connection-status.disconnected { background: #ef444422; color: var(--recording); }

/* ── Main / Mic Button ───────────────────────────────────────────────────── */

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

#mic-btn {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.15s;
}
#mic-btn:active { transform: scale(0.95); }
#mic-btn svg { fill: var(--text); transition: fill 0.3s; }

/* Pulse ring (recording state) */
#pulse-ring {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid var(--recording);
    opacity: 0;
    pointer-events: none;
}

/* Spinner (processing state) */
#spinner {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--accent);
    opacity: 0;
    pointer-events: none;
}

/* ── State: idle ─────────────────────────────────────────────────────────── */
#mic-btn.idle { background: var(--surface); }

/* ── State: recording ────────────────────────────────────────────────────── */
#mic-btn.recording { background: var(--recording); }
#mic-btn.recording svg { fill: #fff; }
#mic-btn.recording #pulse-ring {
    opacity: 1;
    animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ── State: processing ───────────────────────────────────────────────────── */
#mic-btn.processing { background: var(--surface); cursor: wait; }
#mic-btn.processing #spinner {
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── State: playing ──────────────────────────────────────────────────────── */
#mic-btn.playing { background: var(--accent); }
#mic-btn.playing svg { fill: #fff; }

#status-text {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-align: center;
    min-height: 1.4em;
}

/* ── Interrupt button ────────────────────────────────────────────────────── */

#interrupt-btn {
    padding: 10px 24px;
    border-radius: 999px;
    border: 1px solid var(--recording);
    background: transparent;
    color: var(--recording);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
#interrupt-btn:hover { background: #ef444418; }
#interrupt-btn[hidden] { display: none; }

/* ── Toggle text ─────────────────────────────────────────────────────────── */

#toggle-text {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    margin-bottom: 12px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Text area ───────────────────────────────────────────────────────────── */

#text-area {
    width: 100%;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}
#text-area.hidden { display: none; }

.label {
    font-weight: 600;
    color: var(--accent);
    margin-right: 6px;
}

#user-text, #ai-text {
    word-wrap: break-word;
}
