/* Breeze ASR 26 — Mobile-first live-caption UI
   Base styles target the phone; a min-width:901px block restores the wider layout. */

:root {
    --bg-gradient: radial-gradient(circle at top left, #0f172a, #020617);
    --card-bg: rgba(15, 23, 42, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.3);

    --primary: #6366f1;         /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #06b6d4;       /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.3);
    --accent: #a855f7;          /* Purple */

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --shell-gap: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* =========================================================================
   APP SHELL — full-height column: header / wave / panels / action-bar
   ========================================================================= */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    height: var(--app-viewport-height, 100dvh);
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 10px) 12px calc(var(--safe-bottom) + 10px);
    gap: 10px;
    overflow: hidden;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-text {
    min-width: 0;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text .subtitle {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.25);
    padding: 7px 12px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex: 0 0 auto;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    transition: var(--transition);
}

.status-dot.disconnected { background-color: var(--danger); box-shadow: 0 0 10px var(--danger); }
.status-dot.connecting { background-color: var(--warning); box-shadow: 0 0 10px var(--warning); animation: pulse 1.5s infinite alternate; }
.status-dot.listening { background-color: var(--success); box-shadow: 0 0 10px var(--success); animation: pulse 1.5s infinite alternate; }
.status-dot.speaking { background-color: var(--secondary); box-shadow: 0 0 12px var(--secondary); animation: pulse-rapid 0.6s infinite alternate; }

.status-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

/* ---------- Waveform strip ---------- */
.wave-strip {
    position: relative;
    flex: 0 0 auto;
    height: 60px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wave-strip canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.voice-ring {
    position: absolute;
    width: 96px;
    height: 12px;
    border-radius: 999px;
    border: 2px solid var(--primary-glow);
    z-index: 2;
    transition: transform 0.1s ease, border-color var(--transition);
    pointer-events: none;
    box-shadow: inset 0 0 8px var(--primary-glow);
}

.voice-ring.speaking {
    border-color: var(--secondary);
    box-shadow: inset 0 0 20px var(--secondary-glow), 0 0 18px var(--secondary-glow);
}

/* =========================================================================
   PANELS — original + translation share the flexible middle, scroll inside
   ========================================================================= */
.panels {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.caption-panel {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
    padding: 12px 14px;
    transition: border-color 0.4s ease;
}

.translation-panel {
    border-color: rgba(6, 182, 212, 0.18);
}

/* ---------- Panel header ---------- */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.panel-kicker {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    padding: 3px 9px;
    border-radius: 999px;
    flex: 0 0 auto;
}

.panel-kicker.accent {
    color: var(--secondary);
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.28);
}

.panel-title h2 {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

/* ---------- Compact selects & buttons ---------- */
.lang-select {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    max-width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.lang-select:focus { outline: none; border-color: var(--primary); }
.lang-select option { background-color: #0f172a; color: var(--text-main); }

.transcript-language-select { max-width: 190px; }
.backend-select { max-width: 130px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 32px;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover { color: var(--secondary); background: rgba(255, 255, 255, 0.12); }
.icon-btn svg { display: block; }

/* ---------- Transcript body ---------- */
.transcript-display {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.transcript-display::-webkit-scrollbar { width: 6px; }
.transcript-display::-webkit-scrollbar-track { background: transparent; }
.transcript-display::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-dark);
    text-align: center;
    padding: 20px;
    margin: auto 0;
    font-size: 13px;
    line-height: 1.6;
}

.empty-state svg { stroke: var(--text-dark); }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    color: #e2e8f0;
    padding: 2px 0 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    animation: fade-in 0.4s ease forwards;
}

.history-item.just-committed {
    animation: fade-in 0.4s ease forwards, commit-flash 1.3s ease forwards;
}

.interim-text {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.55;
    color: var(--secondary);
    font-weight: 500;
    min-height: 26px;
    padding-left: 10px;
    display: flex;
    align-items: baseline;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.interim-text.active { opacity: 1; }

.interim-body {
    font-style: italic;
    text-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
}

.interim-text.windowed {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 30px);
    mask-image: linear-gradient(to right, transparent 0, #000 30px);
}

.interim-lead { display: none; }

.live-caret {
    flex: 0 0 auto;
    align-self: center;
    width: 7px;
    height: 1.05em;
    margin-left: 3px;
    background: var(--secondary);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--secondary-glow);
    animation: caret-blink 1s steps(2, start) infinite;
}

.interim-text:not(.active) .live-caret { display: none; }

/* ---------- Translation items ---------- */
#translation-list .history-item {
    color: #cbd5e1;
    border-left: 2px solid var(--secondary-glow);
    padding-left: 10px;
}

#translation-list .history-item.tts-speaking {
    border-left-color: rgba(6, 182, 212, 0.65);
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.08), transparent 55%);
}

.tts-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.history-item.tts-speaking .tts-indicator { opacity: 0.78; }

.tts-indicator::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--secondary);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.45);
    animation: tts-soft-pulse 1.4s ease-in-out infinite;
}

/* ---------- Legend ---------- */
.stream-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    flex: 0 0 auto;
    padding-left: 2px;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
}

.stream-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.stream-legend .lg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stream-legend .lg-live i { background: var(--secondary); box-shadow: 0 0 6px var(--secondary-glow); }
.stream-legend .lg-final i { background: #e2e8f0; }

/* =========================================================================
   ACTION BAR — thumb zone
   ========================================================================= */
.action-bar {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex: 0 0 auto;
    padding: 10px 12px;
    background: rgba(2, 6, 23, 0.72);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
}

.btn {
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-label { font-size: 13px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    flex: 1 1 auto;
    font-size: 16px;
}

.btn-primary:active { transform: translateY(1px); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); background: linear-gradient(135deg, #7c3aed, #a855f7); }

.btn-primary.recording {
    background: linear-gradient(135deg, var(--danger), #f43f5e);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-primary.recording:hover { background: linear-gradient(135deg, #dc2626, #e11d48); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.06);
    flex: 0 0 auto;
    flex-direction: column;
    gap: 3px;
    padding: 10px 14px;
}

.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    flex: 0 0 auto;
    flex-direction: column;
    gap: 3px;
    padding: 10px 14px;
}

.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.btn-icon svg { display: block; }

/* =========================================================================
   HIDDEN advanced config (kept in DOM for app.js)
   ========================================================================= */
.is-hidden { display: none !important; }

.control-group { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); }

input[type="text"] {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
}

.slider-label { display: flex; justify-content: space-between; align-items: center; }
.slider-val { font-size: 13px; font-weight: 700; color: var(--secondary); font-family: var(--font-mono); }
.slider-desc { font-size: 11px; color: var(--text-dark); }

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
}

.rms-meter-container { display: flex; flex-direction: column; gap: 8px; }
.rms-track {
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.rms-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
    border-radius: 6px;
    transition: width 0.05s ease-out;
}
.rms-threshold-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--secondary);
    box-shadow: 0 0 6px var(--secondary);
    transition: left 0.1s ease;
}

/* Toggle switch (used in hidden panel + compact switches) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; gap: 4px; }
.switch-title { font-size: 14px; font-weight: 600; color: var(--text-main); }

.switch {
    display: inline-block;
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 26px;
    cursor: pointer;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    transition: 0.25s;
}

.switch-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #cbd5e1;
    border-radius: 50%;
    transition: 0.25s;
}

.switch input:checked + .switch-slider {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    box-shadow: 0 0 10px var(--primary-glow);
}

.switch input:checked + .switch-slider::before { transform: translateX(20px); background: #fff; }

.compact-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    flex: 0 0 auto;
}

.compact-switch .switch { width: 34px; height: 20px; }
.compact-switch .switch-slider::before { height: 14px; width: 14px; left: 3px; top: 2px; }
.compact-switch input:checked + .switch-slider::before { transform: translateX(14px); }

/* =========================================================================
   CONVERSATION (two-person) MODE
   ========================================================================= */
.mode-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
}

.conv-langs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.conv-langs[hidden] { display: none; }

.conv-party-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.conv-tts-switch {
    padding: 3px 0;
}

.conv-arrow {
    color: var(--text-muted);
    font-size: 14px;
}

/* Chat list: side A left / side B right */
.conv-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.conv-turn {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 14px;
    animation: fade-in 0.35s ease forwards;
    position: relative;
}

.conv-turn.side-a {
    align-self: flex-start;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-bottom-left-radius: 4px;
}

.conv-turn.side-b {
    align-self: flex-end;
    background: rgba(6, 182, 212, 0.10);
    border: 1px solid rgba(6, 182, 212, 0.28);
    border-bottom-right-radius: 4px;
}

/* Ephemeral LINE-style bubble while the current utterance is still resolving. */
.conv-turn.conv-live {
    border-style: solid;
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.08), 0 8px 24px rgba(2, 6, 23, 0.24);
    animation: conv-live-in 0.2s ease-out forwards, conv-live-breathe 1.8s ease-in-out infinite;
}

.conv-turn.side-unknown {
    align-self: flex-start;
    min-width: 92px;
    background: rgba(51, 65, 85, 0.38);
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-bottom-left-radius: 4px;
}

.conv-live-tag::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: tts-soft-pulse 1.2s ease-in-out infinite;
}

.conv-live-body {
    color: #e2e8f0;
    font-style: italic;
}

.conv-live-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 4px;
    vertical-align: -0.12em;
    border-radius: 2px;
    background: currentColor;
    animation: caret-blink 0.85s step-end infinite;
}

.conv-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 20px;
}

.conv-typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: conv-dot 1.2s ease-in-out infinite;
}

.conv-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.conv-typing-dots i:nth-child(3) { animation-delay: 0.3s; }

.conv-side-tag {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.75;
}

.conv-turn.side-a .conv-side-tag { color: var(--primary); }
.conv-turn.side-b .conv-side-tag { color: var(--secondary); }

.conv-original {
    font-size: 17px;
    line-height: 1.5;
    color: #f1f5f9;
}

.conv-translation {
    font-size: 16px;
    line-height: 1.5;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.conv-translation.pending {
    color: var(--text-dark);
    font-style: italic;
}

.conv-turn.tts-speaking {
    box-shadow: 0 0 0 1px var(--secondary-glow), 0 0 16px var(--secondary-glow);
}

/* =========================================================================
   COMPACT MOBILE SHELL — reserve nearly all height for the conversation
   ========================================================================= */
.app-shell {
    padding: calc(var(--safe-top) + 6px) 8px calc(var(--safe-bottom) + 6px);
    gap: var(--shell-gap);
}

.app-header {
    min-height: 34px;
    padding: 4px 5px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.brand-text h1 { font-size: 15px; }
.status-indicator { padding: 4px 6px; background: transparent; border: 0; }
.status-dot { width: 7px; height: 7px; }
.status-text { font-size: 11px; color: var(--text-muted); }

.wave-strip {
    height: 6px;
    border: 0;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
}
.wave-strip canvas { opacity: 0.32; }
.voice-ring { width: 72px; height: 6px; border-width: 1px; }

.panels { gap: var(--shell-gap); }
.mode-bar {
    min-height: 42px;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 5px 7px;
    border-radius: 10px;
}
.mode-bar > .compact-switch { gap: 4px; font-size: 10px; }
.mode-bar > .compact-switch .switch { width: 30px; height: 18px; }
.mode-bar > .compact-switch .switch-slider::before { width: 12px; height: 12px; }
.mode-bar > .compact-switch input:checked + .switch-slider::before { transform: translateX(12px); }

.conv-langs { flex: 1 1 auto; min-width: 0; gap: 4px; }
.conv-party-control { flex: 1 1 0; min-width: 0; gap: 3px; }
.conv-party-control .lang-select { width: 100%; min-width: 0; padding: 6px; font-size: 11px; }
.conv-tts-switch > span:first-child { display: none; }
.conv-tts-switch .switch { width: 28px; height: 18px; }
.conv-tts-switch .switch-slider::before { width: 12px; height: 12px; top: 2px; left: 2px; }
.conv-tts-switch input:checked + .switch-slider::before { transform: translateX(12px); }
.conv-arrow { font-size: 11px; }

.conversation-panel {
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0;
    gap: 0;
    border-radius: 14px;
}
.conversation-panel .panel-head { display: none; }
.conversation-panel .transcript-display {
    padding: 8px;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.18);
}
.conversation-panel .empty-state { max-width: 270px; padding: 12px; gap: 8px; font-size: 12px; }
.conversation-panel .empty-state svg { width: 30px; height: 30px; opacity: 0.65; }
.conv-list { gap: 8px; }
.conv-turn { max-width: 88%; padding: 8px 11px; }
.conv-original { font-size: 16px; }
.conv-translation { font-size: 15px; margin-top: 5px; padding-top: 5px; }

.action-bar {
    min-height: 58px;
    gap: 6px;
    padding: 5px;
    border-radius: 14px;
}
.action-bar .btn { min-height: 48px; padding: 8px 11px; border-radius: 10px; }
.action-bar .btn-label { display: none; }
.action-bar .btn-primary { font-size: 15px; }
.action-bar .btn-danger,
.action-bar .btn-secondary { width: 48px; padding: 8px; }

/* =========================================================================
   ANIMATIONS
   ========================================================================= */
@keyframes pulse {
    0% { opacity: 0.6; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1.05); }
}
@keyframes pulse-rapid {
    0% { opacity: 0.5; transform: scale(0.9); box-shadow: 0 0 5px var(--secondary-glow); }
    100% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 20px var(--secondary); }
}
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes conv-live-in {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes conv-live-breathe {
    0%, 100% { filter: brightness(0.96); }
    50% { filter: brightness(1.08); }
}
@keyframes conv-dot {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}
@keyframes caret-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.15; }
}
@keyframes commit-flash {
    0% { background: rgba(16, 185, 129, 0.14); box-shadow: inset 3px 0 0 var(--success); }
    100% { background: transparent; box-shadow: inset 0 0 0 transparent; }
}
@keyframes tts-soft-pulse {
    0%, 100% { opacity: 0.35; transform: scale(0.92); }
    50% { opacity: 0.85; transform: scale(1.08); }
}

/* =========================================================================
   WIDER SCREENS (tablet / desktop) — roomier, but same single-column flow
   ========================================================================= */
@media (min-width: 901px) {
    .app-shell {
        max-width: 900px;
        padding: 20px 20px calc(var(--safe-bottom) + 20px);
        gap: 16px;
    }
    .app-header { padding: 14px 22px; }
    .brand-text h1 { font-size: 20px; }
    .brand-text .subtitle { font-size: 12px; }
    .wave-strip { height: 72px; }
    .voice-ring { width: 140px; height: 14px; }
    .panels { gap: 16px; }
    .caption-panel { padding: 18px 20px; gap: 14px; }
    .panel-title h2 { font-size: 15px; }
    .transcript-language-select { max-width: 260px; }
    .backend-select { max-width: 190px; }
    .history-item, .interim-text { font-size: 18px; }
    .action-bar { padding: 14px 16px; }
    .btn-primary { font-size: 17px; }
}

/* Landscape phones keep the controls fixed; conversation content scrolls inside its panel. */
@media (max-height: 480px) and (orientation: landscape) {
    .wave-strip { height: 44px; }
}

/* =========================================================================
   ZENITH CLARITY — light Japanese-minimal conversation experience
   Source of truth: DESIGN.md
   ========================================================================= */
:root {
    --surface: #f8f9fa;
    --surface-container-lowest: #ffffff;
    --surface-container: #edeeef;
    --on-surface: #191c1d;
    --on-surface-variant: #42474c;
    --outline: #73787d;
    --outline-variant: #c2c7cd;
    --primary: #415f76;
    --on-primary: #ffffff;
    --secondary: #356668;
    --secondary-container: #b9ecee;
    --tertiary: #974138;
    --error: #ba1a1a;
    --error-container: #ffdad6;
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Work Sans', sans-serif;
    --text-main: var(--on-surface);
    --text-muted: var(--on-surface-variant);
    --text-dark: #73787d;
    --card-bg: var(--surface-container-lowest);
    --card-border: var(--outline-variant);
    --bg-gradient: var(--surface);
    --shell-gap: 16px;
}

body {
    background: var(--surface);
    color: var(--on-surface);
    font-family: 'Work Sans', sans-serif;
}

.app-shell {
    max-width: 720px;
    padding: calc(var(--safe-top) + 18px) 24px calc(var(--safe-bottom) + 24px);
    gap: 16px;
    overflow: hidden;
}

.app-header {
    min-height: 52px;
    padding: 0 0 14px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--outline-variant);
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}
.brand-text h1 {
    color: var(--primary);
    background: none;
    -webkit-text-fill-color: currentColor;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-family: 'Plus Jakarta Sans';
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.status-indicator {
    gap: 8px;
    padding: 7px 13px;
    background: var(--surface-container);
    border: 0;
    border-radius: 9999px;
}
.status-dot { width: 10px; height: 10px; box-shadow: none !important; }
.status-dot.disconnected { background-color: #ffc9c3; }
.status-dot.connecting { background-color: #f2c97d; }
.status-dot.listening, .status-dot.speaking { background-color: #9ecfd1; }
.status-text { color: var(--on-surface); font-size: 12px; letter-spacing: .08em; }

.wave-strip { display: none; }
.panels { gap: 24px; }
.mode-bar {
    min-height: 84px;
    padding: 16px 24px;
    gap: 16px;
    flex-wrap: nowrap;
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    box-shadow: none;
}
.mode-bar > .compact-switch {
    min-width: 88px;
    padding-right: 16px;
    border-right: 1px solid var(--outline-variant);
    gap: 10px;
    color: var(--on-surface);
    font-size: 14px;
}
.mode-bar > .compact-switch .switch { width: 58px; height: 34px; }
.mode-bar > .compact-switch .switch-slider::before { width: 26px; height: 26px; top: 3px; left: 3px; }
.mode-bar > .compact-switch input:checked + .switch-slider::before { transform: translateX(24px); }
.switch-slider { background: #d9dadb; border: 0; }
.switch-slider::before { background: #ffffff; }
.switch input:checked + .switch-slider { background: var(--secondary); box-shadow: none; }

.conv-langs { gap: 10px; margin-left: 0; }
.conv-party-control { flex: 1 1 auto; min-width: 0; }
.conv-party-control .lang-select {
    width: 100%;
    padding: 8px 4px;
    border: 0;
    border-radius: 0;
    color: var(--on-surface);
    background: transparent;
    font-family: 'Work Sans', sans-serif;
    font-size: 16px;
    font-weight: 600;
    text-align-last: center;
}
.lang-select option { background: var(--surface-container-lowest); color: var(--on-surface); }
.conv-arrow { color: var(--on-surface-variant); font-size: 22px; }
.conv-tts-switch { display: none; }

.conversation-panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}
.conversation-panel .transcript-display {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    gap: 32px;
}
.conversation-panel .empty-state {
    color: var(--on-surface-variant);
    max-width: 300px;
    font-size: 16px;
    line-height: 1.5;
}
.conversation-panel .empty-state svg { stroke: var(--primary); opacity: .55; }
.conv-list { gap: 32px; }
.conv-turn {
    max-width: 86%;
    padding: 18px 36px 20px;
    border-radius: 16px;
    box-shadow: none;
}
.conv-turn.side-a {
    background: var(--surface-container);
    border: 1px solid #d9dadb;
    border-bottom-left-radius: 4px;
}
.conv-turn.side-b {
    background: var(--secondary-container);
    border: 1px solid #a8dde0;
    border-bottom-right-radius: 4px;
}
.conv-side-tag {
    position: absolute;
    margin-top: -38px;
    color: var(--primary) !important;
    font-family: 'Work Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .05em;
    opacity: 1;
    text-transform: none;
}
.conv-turn.side-b .conv-side-tag { right: 0; color: var(--secondary) !important; }
.conv-original {
    color: var(--primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.45;
}
.conv-turn.side-b .conv-original { color: var(--secondary); }
.conv-translation {
    color: var(--on-surface-variant);
    font-family: 'Work Sans', sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.55;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dotted var(--outline-variant);
    border-bottom: 1px dotted var(--outline-variant);
}
.conv-live-body { color: var(--on-surface-variant); }
.conv-turn.conv-live { box-shadow: none; }

.action-bar {
    min-height: 78px;
    padding: 0;
    gap: 24px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.action-bar .btn { min-height: 72px; border-radius: 16px; }
.action-bar .btn-danger, .action-bar .btn-secondary {
    width: 72px;
    padding: 8px;
    flex-direction: row;
}
.action-bar .btn-danger {
    color: var(--tertiary);
    background: transparent;
    border: 1px solid var(--tertiary);
}
.action-bar .btn-secondary { color: var(--on-surface-variant); background: var(--surface-container); border: 0; }
.action-bar .btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 18px;
    box-shadow: 0 14px 28px rgba(93, 123, 147, .12);
}
.action-bar .btn-primary.recording { background: #b6584e; box-shadow: 0 14px 28px rgba(182, 88, 78, .12); }
.action-bar .btn-label { display: none; }

@media (max-width: 430px) {
    .app-shell { padding-left: 16px; padding-right: 16px; }
    /* Keep the three mode/audio switches on their own row. The language
       controls then get a full-width second row rather than being squeezed
       into overlapping icons on narrow iPhones. */
    .mode-bar { flex-wrap: wrap; padding: 12px 14px; gap: 8px; min-height: 112px; }
    .mode-bar > .compact-switch { flex: 1 1 0; min-width: 0; padding-right: 6px; font-size: 12px; justify-content: space-between; }
    .mode-bar > .compact-switch .switch { width: 46px; height: 28px; }
    .mode-bar > .compact-switch .switch-slider::before { width: 22px; height: 22px; }
    .mode-bar > .compact-switch input:checked + .switch-slider::before { transform: translateX(18px); }
    .conv-langs { order: 2; flex: 1 0 100%; width: 100%; gap: 4px; margin-left: 0; padding-top: 8px; border-top: 1px solid var(--outline-variant); }
    .conv-party-control .lang-select { font-size: 11px; }
    .conv-arrow { font-size: 18px; }
    .conv-turn { padding: 16px 20px 18px; }
    .conv-original { font-size: 18px; }
    .conv-translation { font-size: 17px; }
    .action-bar { gap: 12px; }
    .action-bar .btn-danger, .action-bar .btn-secondary { width: 58px; }
}

/* Supplied brand artwork, cropped to the microphone/wave/translation mark. */
.brand-icon {
    display: block;
    width: 58px;
    height: 36px;
    flex: 0 0 auto;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    mix-blend-mode: multiply;
}
.brand { gap: 10px; }
@media (max-width: 430px) {
    .brand-icon { width: 34px; height: 23px; }
    .brand { gap: 4px; }
    .brand-text h1 { font-size: 22px; }
    .status-indicator { padding: 7px 9px; }
}

/* Centered bilingual empty state, independent of the transcript list width. */
.conversation-panel .empty-state {
    align-self: center;
    width: min(100%, 340px);
    margin: auto;
    text-align: center;
}
.conversation-panel .empty-state p { width: 100%; }
.conversation-prompt-zh,
.conversation-prompt-en { display: block; }
.conversation-prompt-zh { color: var(--on-surface-variant); }
.conversation-prompt-en {
    margin-top: 10px;
    color: var(--outline);
    font-size: 13px;
    line-height: 1.5;
}

/* Keep the speaker control visually attached to its language picker. */
.conv-party-control { gap: 0; }
.conv-party-control .lang-select { padding-right: 0; }

/* Per-person TTS: a dark speaker means playback is enabled; a pale one is muted. */
.conv-tts-switch {
    display: inline-flex;
    position: relative;
    width: 28px;
    height: 32px;
    /* Pull the icon into the select's trailing padding so it reads as one control. */
    margin-left: -12px;
    color: var(--secondary);
    cursor: pointer;
}
.conv-tts-switch > input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.tts-icon {
    width: 22px;
    height: 22px;
    margin: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: color .2s ease, opacity .2s ease;
}
.conv-tts-switch input:not(:checked) ~ .tts-icon {
    color: var(--outline-variant);
    opacity: .7;
}
.conv-tts-switch input:focus-visible ~ .tts-icon { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
