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

:root {
    /* ── Radix-based semantic tokens (Speechmatics brand) ── */
    --bg-app: var(--sage-1);
    --bg-subtle: var(--sage-2);
    --bg-surface: #ffffff;
    --bg-overlay: var(--sage-3);

    --border-subtle: var(--sage-6);
    --border-ui: var(--sage-7);
    --border-strong: var(--sage-8);

    --text-primary: var(--sage-12);
    --text-secondary: var(--sage-11);
    --text-placeholder: var(--sage-9);

    --jade-bg: var(--jade-2);
    --jade-border: var(--jade-7);
    --jade-solid: var(--jade-9);
    --jade-solid-hover: var(--jade-10);
    --jade-text: var(--jade-11);
    --jade-high: var(--jade-12);

    --orange-bg: var(--orange-2);
    --orange-border: var(--orange-7);
    --orange-solid: var(--orange-9);
    --orange-text: var(--orange-11);

    --amber-bg: var(--amber-2);
    --amber-border: var(--amber-7);
    --amber-solid: var(--amber-9);
    --amber-text: var(--amber-11);

    --brand-solid: #0D3C48;
    --brand-text: #0D3C48;

    --font-mono: 'DM Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

    /* ── Aliases ── */
    --bg: var(--bg-app);
    --surface: var(--bg-surface);
    --border: var(--border-subtle);
    --text: var(--text-primary);
    --text-muted: var(--text-secondary);
    --accent: var(--jade-solid);
    --radius: 4px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -1px rgba(0, 0, 0, .04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.2s, color 0.2s;
}

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
/* Radix Colors' *Dark.css files scope to .dark; we mirror to [data-theme=dark]
   so both selectors work. We keep --brand-solid as dark blue in both modes so
   any surface that uses it as a background (header, buttons) stays legible with
   its inherited #fff text; the panel accent border overrides where needed. */
[data-theme="dark"],
.dark {
    --bg-surface: var(--sage-3);
    --bg-overlay: var(--sage-4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .header {
    background: var(--sage-2);
    color: var(--sage-12);
    border-bottom: 1px solid var(--sage-4);
}

/* Panel top accent — dark blue disappears against dark cards, so lift it. */
[data-theme="dark"] .panel-header {
    border-top-color: var(--sage-11);
}

/* Melia panel keeps its jade accent since jade-9 dark reads well on dark cards */
[data-theme="dark"] .panel-header--melia {
    background: color-mix(in srgb, var(--jade-9) 12%, var(--sage-3));
}

/* Header logo is a light SVG designed for a dark header. Keep as-is; the
   dark-mode header background (sage-2) is dark enough for it to remain legible. */

/* ── Theme toggle button in header ─────────────────────────────────────────── */
.theme-toggle {
    margin-left: auto;
    background: transparent;
    border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
    color: inherit;
    border-radius: var(--radius);
    padding: 6px 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: color-mix(in srgb, currentColor 12%, transparent);
    border-color: color-mix(in srgb, currentColor 50%, transparent);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 30%, transparent);
}

.theme-icon {
    width: 16px;
    height: 16px;
    display: block;
}

/* Light mode shows the moon; click → go dark */
.theme-icon--sun {
    display: none;
}

.theme-icon--moon {
    display: block;
}

/* Dark mode shows the sun; click → go light */
[data-theme="dark"] .theme-icon--sun {
    display: block;
}

[data-theme="dark"] .theme-icon--moon {
    display: none;
}

/* ── Animated background canvas ───────────────────────────────────────────── */
/* Full-viewport canvas sitting behind everything. Ported from the
   sm_speaker_id_demo AnimatedBackground component. */
#animated-bg {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    display: block;
    pointer-events: none;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
    position: relative;
    z-index: 1;
    background: var(--brand-solid);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-logo {
    height: 1em;
    width: auto;
    display: block;
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
.main {
    position: relative;
    z-index: 1;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px 24px 80px;
}

/* ── Session strip (sticky recording bar) ──────────────────────────────────── */
.session-strip {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--brand-solid);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow-md);
    /* Animated expand when a session starts. Mirrors .setup-card timing so
       the two transitions feel like one continuous motion. */
    max-height: 220px;
    opacity: 1;
    overflow: hidden;
    transition:
        max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease 0.08s,
        margin-bottom 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.42s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 12px;
}

.session-strip.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.session-strip-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.session-strip-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.session-strip-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    color: #fff;
}

.session-strip-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange-solid);
    flex-shrink: 0;
    animation: pulse-dot 1.2s ease-in-out infinite;
}

.session-strip-config {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.config-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 2px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: .04em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, .12);
    color: rgba(255, 255, 255, .85);
    border: 1px solid rgba(255, 255, 255, .18);
}

.config-chip--melia {
    background: color-mix(in srgb, var(--jade-solid) 25%, transparent);
    border-color: color-mix(in srgb, var(--jade-solid) 50%, transparent);
    color: #fff;
}

.session-strip-elapsed {
    font-size: 0.82rem;
    font-family: var(--font-mono);
    color: rgba(255, 255, 255, .75);
    min-width: 38px;
    text-align: right;
}

/* Strip mic meter */
.session-strip .mic-meter-wrap {
    display: none;
    align-items: center;
    gap: 5px;
}

.session-strip .mic-meter-wrap.visible {
    display: flex;
}

.session-strip .mic-meter {
    width: 36px;
    height: 14px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.session-strip .mic-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--jade-solid);
    border-radius: 1px;
    transition: width 0.05s linear;
}

/* ── Setup card (streamlined, guided) ──────────────────────────────────────── */
.setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Animated collapse when a session starts. max-height is capped generously
       above the natural height so the transition triggers; opacity fades a
       hair faster than the height for a "closing" feel. */
    max-height: 800px;
    opacity: 1;
    overflow: hidden;
    transition:
        max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.25s ease,
        margin-bottom 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.42s cubic-bezier(0.4, 0, 0.2, 1),
        border-width 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}

.setup-card.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-width: 0;
    border-bottom-width: 0;
    pointer-events: none;
}

/* Token row — token input left-justified (compact), Transcribe CTA
   right-justified on the same level. Wraps on narrow screens. */
.setup-token-row {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    row-gap: 14px;
}

.setup-token-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 1 360px;
    min-width: 0;
}

.setup-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.setup-label-link {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--jade-text);
    text-decoration: none;
}

.setup-label-link:hover {
    text-decoration: underline;
}

.token-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.token-input {
    flex: 1;
    padding: 12px 14px !important;
    font-family: var(--font-mono) !important;
    font-size: 0.9rem !important;
    letter-spacing: 0.02em;
    transition: box-shadow 0.2s, border-color 0.15s;
}

@keyframes token-glow {

    0%,
    100% {
        box-shadow:
            0 0 0 3px color-mix(in srgb, var(--jade-solid) 45%, transparent),
            0 0 12px 2px color-mix(in srgb, var(--jade-solid) 25%, transparent);
    }

    50% {
        box-shadow:
            0 0 0 6px color-mix(in srgb, var(--jade-solid) 70%, transparent),
            0 0 22px 6px color-mix(in srgb, var(--jade-solid) 45%, transparent);
    }
}

/* Config row — comparison columns, separated from the token/CTA row above */
.setup-config-row {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 18px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 20px;
}

.setup-config-controls {
    display: flex;
    gap: 26px;
    align-items: flex-start;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    row-gap: 14px;
}

.setup-config-controls .control-group {
    min-width: 140px;
}

.setup-cta {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
}

.setup-cta .btn-transcribe {
    flex: 1;
}

/* Responsive: stack the CTA under controls on narrow screens */
@media (max-width: 720px) {
    .setup-cta {
        width: 100%;
    }
}

/* ── Preview badge ─────────────────────────────────────────────────────────── */
.badge-preview {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: .06em;
    /* Amber: always dark text per brand rules */
    background: var(--amber-bg);
    color: var(--text-primary);
    border: 1px solid var(--amber-border);
}

/* Panel variant — slightly more visible */
.badge-preview--panel {
    font-size: 0.62rem;
}

/* ── Controls ──────────────────────────────────────────────────────────────── */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input[type="password"],
input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    width: 100%;
    background: var(--surface);
}

input:focus {
    border-color: var(--jade-solid);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-solid) 15%, transparent);
}

.select-input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    cursor: pointer;
    appearance: auto;
}

.select-input:focus {
    border-color: var(--jade-solid);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-solid) 15%, transparent);
}

/* ── Config columns (TAT-style: pinned Melia + comparison cards + add) ─────── */
.control-group--configs {
    flex: 1 1 100%;
}

.config-columns {
    display: flex;
    gap: 14px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
}

.config-col {
    flex: 1 1 275px;
    min-width: 275px;
    max-width: 400px;
    /* Match .config-col-add so the row height stays constant whether the
       add button is present or the row is full. */
    min-height: 250px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--jade-solid);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Only newly-added cards animate. Existing cards get re-rendered on every
   config change (model/language selection rebuilds the container), so we
   opt them out to prevent whole-row flicker. */
.config-col--entering {
    animation: fadeUp 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.config-col--pinned {
    background: color-mix(in srgb, var(--jade-solid) 4%, var(--surface));
}

.config-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 15px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.config-col--pinned .config-col-head {
    background: color-mix(in srgb, var(--jade-solid) 8%, var(--bg-subtle));
}

.config-col-num {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--text-primary);
    text-transform: uppercase;
}

.config-col-tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--jade-text);
    background: var(--jade-bg);
    border: 1px solid var(--jade-border);
    padding: 1px 6px;
    border-radius: 2px;
}

.config-col-remove {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-ui);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.config-col-remove:hover:not(:disabled) {
    background: var(--orange-bg);
    color: var(--orange-text);
    border-color: var(--orange-border);
}

.config-col-remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.config-col-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

.config-col-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.pinned-value {
    padding: 10px 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: .04em;
}

/* ── Custom dropdown (replaces native <select> so pickers look app-native) ──
   The menu is portalled to <body> with position: fixed at open time so it can
   escape ancestors that clip via `overflow: hidden` (setup-card, config-col). */
.col-picker {
    position: relative;
    width: 100%;
}

.col-picker-btn {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.col-picker-btn:hover,
.col-picker-btn[aria-expanded="true"] {
    border-color: var(--jade-border);
}

.col-picker-btn:focus-visible {
    border-color: var(--jade-solid);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-solid) 15%, transparent);
}

.col-picker-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-picker-label--placeholder {
    color: var(--text-muted);
}

.col-picker-chevron {
    width: 10px;
    height: 6px;
    color: var(--text-muted);
    transition: transform .12s;
    flex-shrink: 0;
}

.col-picker-btn[aria-expanded="true"] .col-picker-chevron {
    transform: rotate(180deg);
}

/* Menu is position: fixed once portalled to <body>. */
.col-picker-menu {
    position: fixed;
    z-index: 200;
    background: var(--bg-surface);
    border: 1px solid var(--border-ui);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}

.col-picker-search-wrap {
    padding: 6px 8px;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 1;
}

.col-picker-search {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.col-picker-search:focus {
    border-color: var(--jade-solid);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--jade-solid) 15%, transparent);
}

.col-picker-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.col-picker-group {
    padding: 6px 12px 3px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.col-picker-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}

.col-picker-option:hover,
.col-picker-option--highlighted {
    background: var(--bg-overlay);
}

.col-picker-option--selected {
    background: var(--jade-bg);
    color: var(--jade-text);
    font-weight: 600;
}

.col-picker-option--selected.col-picker-option--highlighted {
    background: color-mix(in srgb, var(--jade-solid) 18%, var(--surface));
}

.col-picker-option-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-picker-option-code {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-placeholder);
    flex-shrink: 0;
}

.col-picker-option--selected .col-picker-option-code {
    color: var(--jade-text);
    opacity: 0.7;
}

.col-picker-empty {
    padding: 10px 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
}

/* Add-config button — dashed placeholder matching TAT */
.config-col-add {
    flex: 1 1 275px;
    min-width: 275px;
    max-width: 400px;
    min-height: 250px;
    background: transparent;
    border: 1.5px dashed var(--border-ui);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    cursor: pointer;
    outline: none;
    color: var(--text-secondary);
    font-family: inherit;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.config-col-add:hover {
    border-color: var(--jade-solid);
    color: var(--jade-text);
    background: color-mix(in srgb, var(--jade-solid) 4%, transparent);
}

.config-col-add:focus-visible {
    border-color: var(--jade-solid);
    color: var(--jade-text);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade-solid) 20%, transparent);
}

.add-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1;
    color: inherit;
}

.add-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Transcribe CTA + Stop + mic meter ─────────────────────────────────────── */
.btn-transcribe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 26px;
    background: var(--brand-solid);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: var(--shadow);
    white-space: nowrap;
    transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
    min-width: 180px;
}

.btn-transcribe-text {
    display: inline-block;
}

.btn-transcribe-arrow {
    display: inline-block;
    font-size: 0.78em;
    line-height: 1;
    transition: transform 0.2s ease;
}

.btn-transcribe:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-solid) 88%, black);
    box-shadow: var(--shadow-md);
}

.btn-transcribe:hover:not(:disabled) .btn-transcribe-arrow {
    transform: translateX(4px);
}

.btn-transcribe:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-transcribe:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Guiding pulse — draws attention once the setup is ready to run */
.btn-transcribe:not(:disabled):not(.recording) {
    animation: transcribe-ready 1.6s ease-in-out infinite;
}

@keyframes transcribe-ready {

    0%,
    100% {
        box-shadow:
            var(--shadow),
            0 0 0 2px color-mix(in srgb, var(--jade-solid) 55%, transparent),
            0 0 18px 2px color-mix(in srgb, var(--jade-solid) 35%, transparent);
        transform: scale(1);
    }

    50% {
        box-shadow:
            var(--shadow),
            0 0 0 10px color-mix(in srgb, var(--jade-solid) 25%, transparent),
            0 0 32px 10px color-mix(in srgb, var(--jade-solid) 60%, transparent);
        transform: scale(1.035);
    }
}

.btn-transcribe.recording {
    background: var(--jade-solid);
}

.btn-stop {
    background: var(--orange-solid);
    font-size: 0.82rem;
    padding: 6px 14px;
}

.btn-stop:hover:not(:disabled) {
    background: color-mix(in srgb, var(--orange-solid) 85%, black);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 0.4;
        transform: translateY(-50%) scale(0.7);
    }
}

.mic-meter-wrap {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mic-meter-wrap.visible {
    display: flex;
}

.mic-meter {
    width: 90px;
    height: 8px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.mic-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--jade-solid);
    border-radius: 1px;
    transition: width 0.05s linear;
}

.mic-label {
    font-size: 0.7rem;
    color: var(--text-placeholder);
    font-family: var(--font-mono);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
    padding: 9px 22px;
    background: var(--brand-solid);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-solid) 85%, black);
}

.btn-primary:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-icon {
    padding: 5px 9px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1;
}

.btn-icon:hover {
    background: var(--bg-overlay);
}

.btn-icon-img {
    width: 16px;
    height: 16px;
    display: block;
    opacity: 0.6;
}

.btn-icon:hover .btn-icon-img {
    opacity: 1;
}

/* The eye SVGs ship with hardcoded near-black strokes. Invert in dark mode
   so the icon reads against the dark button surface. */
[data-theme="dark"] .btn-icon-img,
.dark .btn-icon-img {
    filter: invert(1);
}

/* ── Empty state (onboarding step cards) ───────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px 24px;
    text-align: center;
    color: var(--text-muted);
    gap: 22px;
}

.empty-state-heading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state-icon {
    font-size: 1.4rem;
    line-height: 1;
    opacity: 0.9;
}

.onboard-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 900px;
}

/* Each step card mirrors the panel/config-col idiom: sharp radius, jade
   top-accent, sage-2 head background handled via the number chip on top. */
.onboard-step {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px 16px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--jade-solid);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: left;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.onboard-step:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--jade-border);
}

.onboard-step-num {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .14em;
    color: var(--text-placeholder);
}

.onboard-step-title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--jade-text);
}

.onboard-step-body {
    font-size: 0.86rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.onboard-step-body a {
    color: var(--jade-text);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

.onboard-step-body a:hover {
    border-bottom-style: solid;
}

@media (max-width: 720px) {
    .onboard-steps {
        grid-template-columns: 1fr;
    }
}

/* ── Onboarding hover-highlight targets ────────────────────────────────────
   Hovering an .onboard-step toggles .is-highlighted on the element it
   describes. Reuses existing pulse keyframes so the cue is consistent with
   the app's other "ready" states. */
.token-input.is-highlighted {
    animation: token-glow 1.6s ease-in-out infinite;
    border-color: var(--jade-solid);
}

.btn-transcribe.is-highlighted {
    animation: transcribe-ready 1.6s ease-in-out infinite;
}

.config-col.is-highlighted,
.config-col-add.is-highlighted {
    animation: config-glow 1.6s ease-in-out infinite;
    border-color: var(--jade-solid);
}

@keyframes config-glow {

    0%,
    100% {
        box-shadow:
            var(--shadow),
            0 0 0 2px color-mix(in srgb, var(--jade-solid) 45%, transparent),
            0 0 12px 2px color-mix(in srgb, var(--jade-solid) 25%, transparent);
    }

    50% {
        box-shadow:
            var(--shadow),
            0 0 0 5px color-mix(in srgb, var(--jade-solid) 60%, transparent),
            0 0 22px 5px color-mix(in srgb, var(--jade-solid) 40%, transparent);
    }
}

/* ── Comparison panels — grid-template-columns is set inline by JS based on
   how many models are active in the current run (1, 2, or 3). ─────────────── */
.panels-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 16px;
    row-gap: 16px;
    align-items: start;
}

@media (max-width: 900px) {
    .panels-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .session-strip {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .session-strip-right {
        width: 100%;
        justify-content: flex-end;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Panel header (single row) ─────────────────────────────────────────────── */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    border-top: 3px solid var(--brand-solid);
    gap: 8px;
}

.panel-header--melia {
    border-top-color: var(--jade-solid);
    background: var(--jade-bg);
}

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

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ── Panel config chips (in header) ────────────────────────────────────────── */
.panel-config-chips {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.panel-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: .04em;
    text-transform: uppercase;
    /* default: standard chips */
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.panel-chip--melia {
    background: var(--jade-bg);
    color: var(--jade-text);
    border-color: var(--jade-border);
}

/* ── Panel status pill ─────────────────────────────────────────────────────── */
.panel-status {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.status-idle {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

.status-connecting {
    background: var(--amber-bg);
    color: var(--amber-text);
    border: 1px solid var(--amber-border);
}

.status-live {
    background: var(--jade-bg);
    color: var(--jade-text);
    border: 1px solid var(--jade-border);
}

.status-stopped {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--border-ui);
}

.status-error {
    background: var(--orange-bg);
    color: var(--orange-text);
    border: 1px solid var(--orange-border);
}

/* ── Transcript container ──────────────────────────────────────────────────── */
.transcript-container {
    padding: 16px;
    flex: 1;
    min-height: 220px;
    max-height: 540px;
    overflow-y: auto;
    line-height: 1.9;
    font-size: 0.95rem;
    background: var(--surface);
}

.transcript-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.error-banner {
    color: var(--orange-text);
    background: var(--orange-bg);
    border: 1px solid var(--orange-border);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 10px;
}

/* ── Language line (each new language starts a new visible line) ──────────── */
.lang-line {
    display: block;
    padding: 4px 8px 4px 10px;
    margin: 4px 0;
    border-left: 3px solid var(--border-strong);
    border-radius: 0 var(--radius) var(--radius) 0;
    line-height: 1.55;
}

.lang-line+.lang-line {
    margin-top: 6px;
}

.lang-line-tag {
    display: inline-block;
    padding: 1px 6px;
    margin-right: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: .06em;
    font-family: var(--font-mono);
    border: 1px solid;
    border-radius: 2px;
    vertical-align: 2px;
    color: var(--text-primary);
    line-height: 1;
}

.lang-line-words {
    display: inline;
    color: var(--text-primary);
}

/* Word tokens — finals solid, partials greyed inline so finals replace
   partial words in place without reflowing to a new line. */
.lang-line .w {
    transition: opacity 0.15s;
}

.lang-line .w-partial {
    opacity: 0.5;
}

/* ── Panel footer (metrics + legend, below transcript) ─────────────────────── */
.panel-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
}

/* ── Metrics bar ───────────────────────────────────────────────────────────── */
.metrics-bar {
    padding: 5px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 28px;
    align-items: center;
}

.metrics-bar:empty {
    display: none;
}

.metric {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.metric b {
    color: var(--text);
}

/* ── Language legend ───────────────────────────────────────────────────────── */
.lang-legend {
    padding: 4px 16px 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    font-size: 0.75rem;
}

.lang-legend:empty {
    display: none;
}

.legend-label {
    color: var(--text-muted);
    margin-right: 2px;
    font-size: 0.72rem;
}

.lang-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 2px;
    border: 1.5px solid;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .04em;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .65s linear infinite;
    flex-shrink: 0;
}

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

/* ── Site footer (socials left, copyright right) ───────────────────────────── */
/* Pinned to the bottom of the viewport so it doesn't shift when the transcript
   panels grow. Uses a translucent surface + backdrop blur so the animated
   background canvas remains visible through it. */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--border-subtle);
    background: color-mix(in srgb, var(--bg-app) 82%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    flex-wrap: wrap;
    row-gap: 6px;
}

.footer-social {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--text-muted);
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.footer-social a:hover,
.footer-social a:focus-visible {
    color: var(--jade-text);
    background: color-mix(in srgb, var(--jade-solid) 8%, transparent);
    outline: none;
}

.footer-social svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    display: block;
}

.footer-copyright {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: .04em;
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}