/* frontend/css/style.css */

/* --- THEME & FONT DEFINITIONS --- */
:root {
    --blue-dark: #001f3f;
    --blue-primary: #0074D9;
    --red-primary: #FF4136;
    --white-primary: #FFFFFF;
    --white-off: #F0F0F0;
    --grey-dark: #111111;
    --text-primary: var(--white-off);
    --text-secondary: #c4c4c4;   /* raised from #AAAAAA for WCAG-AA over variable glass */
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --player-height: 80px;

    /* One promoted brand accent */
    --accent: #0074D9;
    --accent-hover: #2a90ee;

    /* Glass surfaces + borders */
    --surface: rgba(0, 0, 0, 0.2);
    --surface-2: rgba(0, 0, 0, 0.5);
    --border: rgba(255, 255, 255, 0.12);
    --btn-bg: rgba(255, 255, 255, 0.08);
    --btn-bg-hover: rgba(255, 255, 255, 0.16);
    --glass-blur: 8px;

    /* Semantic status colors */
    --status-live: #4ade80;
    --status-busy: #4ade80;
    --status-warn: #ffd166;
    --status-error: #FF4136;

    /* Radius scale */
    --r-sm: 6px;
    --r-md: 12px;
    --r-pill: 999px;

    /* Elevation */
    --shadow-1: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.55);

    /* z-index scale */
    --z-debug: 90;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* --- Accessibility: visible keyboard focus + reduced-motion --- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
button:focus-visible, .station-item:focus-visible, .tab-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- GLOBAL RESETS & BODY LAYOUT --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100vh;
    height: 100dvh; /* dynamic viewport so the player bar isn't hidden behind mobile browser chrome */
    overflow: hidden;
    background-color: var(--blue-dark);
}

body {
    font-family: var(--font-main);
    color: var(--text-primary);
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

#dynamic-background {
    position: fixed;
    top: -5%; left: -5%;
    width: 110%; height: 110%;
    background-size: cover;
    background-position: center;
    filter: blur(40px) brightness(0.4);
    z-index: 0;
    transition: background-image 0.8s ease-in-out;
}

/* --- HEADER --- */
#main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    flex-shrink: 0;
}

h1 {
    font-size: 1.2rem;
}

#open-station-modal-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#open-station-modal-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- MAIN CONTENT (TRANSCRIPT) --- */
#main-content {
    flex-grow: 1;
    padding: 0 1rem 1rem 1rem;
    min-height: 0; /* Flexbox overflow fix */
    display: flex;
}

#transcript-container {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 1.8em;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scroll-behavior: smooth;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#transcript-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.utterance {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-in;
    border-left: 4px solid var(--blue-primary);
    overflow-wrap: anywhere;   /* long URLs / CJK can't overflow the glass card */
}
.utterance.final {
    border-left-color: var(--red-primary);
}
.utterance.summarized {
    /* IMPROVED: Use a subtle yellow left border instead of a heavy background */
    background: rgba(255, 220, 115, 0.1); /* A very faint, translucent yellow glow */
    transition: background-color 0.5s ease-in-out;
    border-left-color: #FFDC73; /* Bright yellow border for clear marking */
}
.highlight {
    color: var(--white-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

/* --- FOOTER (PLAYER BAR) --- */
#player-bar {
    height: var(--player-height);
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.player-station-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.station-logo {
    height: 50px;
    width: 50px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--grey-dark);
}

#player-station-name {
    font-size: 1.1rem;
    font-weight: bold;
}
.sub-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
}

/* ASR engine picker — sits inline in .sub-info alongside plain text spans, so it should
   look like one, not like a stray form control. */
#asr-engine-select {
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    max-width: 46vw;
    text-overflow: ellipsis;
}
#asr-engine-select:hover, #asr-engine-select:focus { color: var(--text-primary); }

/* Performance Mode Indicator */
#performance-mode-indicator {
    font-weight: bold;
    font-family: monospace;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: help;
    transition: all 0.3s ease;
}

#performance-mode-indicator:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.4);
}

#player-controls {
    display: flex;
    align-items: center;
}

#player-controls button {
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--white-primary);
    cursor: pointer;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    transition: background-color 0.2s, transform 0.1s;
}
#player-controls button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
#player-controls button:active {
    transform: scale(0.9);
}
#player-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- STATION SELECTION MODAL --- */
#station-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: var(--z-modal);
}

#station-modal.visible {
    display: flex;
}

.modal-content {
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--r-md);
    max-width: 900px;
    max-height: 80vh;
    width: 90%;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
}

.modal-content h2 {
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
    text-align: center;
    font-size: 1.8rem;
}

/* Station Browser Tabs */
.station-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.tab-btn:hover {
    background: var(--btn-bg-hover);
    border-color: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white-primary);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search and Filters */
.search-filters {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.search-row, .filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-row:last-child, .filter-row:last-child {
    margin-bottom: 0;
}

#station-search {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-primary);
    font-size: 1rem;
}

#station-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 116, 217, 0.3);
}

#search-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    color: var(--white-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

#search-btn:hover {
    background: var(--accent-hover);
}

.filter-row select {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filter-row select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Search Results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
}

#loading-indicator {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.station-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.station-item:hover {
    background: var(--btn-bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-1);
}

.station-item .station-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--grey-dark);
    flex-shrink: 0;
}

.station-item .station-info {
    flex: 1;
    min-width: 0;
}

.station-item .station-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-item .station-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.station-item .station-tag {
    background: rgba(0, 116, 217, 0.25);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    padding: 0.1rem 0.5rem;
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 500;
}

.station-item .language-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #1d7a35;   /* darkened for WCAG-AA on small uppercase text */
    color: var(--white-primary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-sm);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.station-item .unsupported-language {
    background: #b02a37;   /* darkened red for AA */
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #444;
    color: #fff;
}

/* --- SUMMARY PANEL --- */
#summary-panel {
    flex-shrink: 0;
    padding: 0 1rem 1rem 1rem;
}

.summary-content {
    background: var(--surface);
    backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--r-md);
    padding: 1rem 1.5rem;
    border: 1px solid var(--border);
    max-height: 32vh;       /* cap the footer band so a long summary never crushes the transcript */
    overflow-y: auto;
}

.summary-content h3 {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-time-ago {
    float: right;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 4px;
}

/* --- Reasoning panel (chain-of-thought, shown separately from the summary) --- */
#summary-reasoning {
    margin: 0.25rem 0 0.5rem;
    font-size: 0.8rem;
}
#summary-reasoning > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-style: italic;
    user-select: none;
}
#summary-reasoning > summary::-webkit-details-marker { display: none; }
#summary-reasoning > summary::before {
    content: '▸';
    transition: transform 0.15s ease;
    font-style: normal;
}
#summary-reasoning[open] > summary::before { transform: rotate(90deg); }
#summary-reasoning-text {
    margin-top: 0.4rem;
    max-height: 9rem;
    overflow-y: auto;
    white-space: pre-wrap;
    color: var(--text-secondary);
    opacity: 0.85;
    font-size: 0.78rem;
    line-height: 1.45;
    padding-left: 0.6rem;
    border-left: 2px solid rgba(255, 255, 255, 0.15);
}
.reasoning-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    flex: 0 0 auto;
}
.summary-content.streaming .reasoning-dot {
    background: #4ade80;
    animation: reasoning-pulse 1s ease-in-out infinite;
}
.summary-thinking { color: var(--text-secondary); font-style: italic; }
.summary-content.streaming #summary-text { opacity: 0.95; }
@keyframes reasoning-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* --- UTILITY & DEBUG STYLES (REDESIGNED) --- */

#debug-toggle {
    /* Style for the new icon button in the player bar */
    order: -1; /* Places it at the beginning of the station info flex container */
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-secondary);
    background-color: transparent;
    border: 1px solid var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0;
    position: relative;
}
/* extend the clickable area to ~44px without growing the visual button (WCAG 2.5.5) */
#debug-toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
}

#debug-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white-primary);
}

#debug-panel {
    /* The new slide-up panel */
    position: fixed;
    bottom: var(--player-height);
    left: 0;
    width: 100%;
    max-height: 40vh;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: var(--z-debug);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    
    /* Animation for sliding in and out */
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
    visibility: hidden;
}

#debug-panel.visible {
    transform: translateY(0);
    visibility: visible;
}

/* Reset old positioning and integrate into the new panel */
.sync-control-container, #debug-box {
    position: static;
    background-color: transparent;
    width: 100%;
    padding: 0;
}

.sync-control-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

#debug-box {
    flex-grow: 1; /* Allows the message list to take available space */
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#debug-box h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

#debug-box ul {
    overflow-y: auto; /* Make the message list scrollable */
    list-style: none;
    font-size: 0.9rem;
    flex-grow: 1;
}

audio { display: none; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 600px) {
    h1 { font-size: 1rem; }
    #transcript-container { font-size: 1.2rem; padding: 1rem; }
    .station-logo { height: 40px; width: 40px; }
    #player-station-name { font-size: 0.9rem; max-width: 38vw; }
    .sub-info { font-size: 0.7rem; }
    /* Keep play/stop/mute at a comfortable touch size (>=44px) */
    #player-controls button { font-size: 1.3rem; width: 44px; height: 44px; }
    /* Volume slider eats width on a phone; rely on the device volume + mute */
    #volumeSlider { display: none; }

    /* --- Station modal: make it actually usable on a phone --- */
    .modal-content { padding: 1rem; width: 95%; max-height: 90vh; }
    .station-tabs { flex-wrap: wrap; gap: 0.5rem; padding-bottom: 0.75rem; }
    .tab-btn { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
    .search-filters { padding: 1rem; }
    .search-row, .filter-row { flex-direction: column; gap: 0.5rem; }
    /* Horizontal station cards: one per row on narrow screens */
    .station-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}

/* --- VOLUME CONTROLS --- */
#volume-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem; /* Add some space from the play/stop buttons */
}

#muteBtn {
    font-size: 1.2rem; /* Slightly smaller than play/stop for a better look */
}

#volumeSlider {
    -webkit-appearance: none; /* Override default CSS */
    appearance: none;
    width: 100px; /* Or whatever width you prefer */
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

#volumeSlider:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- SLIDER THUMB STYLING (for Chrome/Safari/Edge) --- */
#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--white-off);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

#volumeSlider::-webkit-slider-thumb:hover {
    background: var(--white-primary);
}

/* --- SLIDER THUMB STYLING (for Firefox) --- */
#volumeSlider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--white-off);
    border-radius: 50%;
    cursor: pointer;
    border: none; /* Firefox adds a border by default */
    transition: background 0.2s;
}

#volumeSlider::-moz-range-thumb:hover {
    background: var(--white-primary);
}

/* Language fallback notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    max-width: 400px;
}

.language-fallback-notification {
    background: rgba(255, 165, 0, 0.95);
    border: 1px solid #ff8c00;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #000;
}

.notification-icon {
    font-size: 18px;
    margin-right: 10px;
}

.notification-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
/* Models-in-use line under the live summary */
.model-info {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    color: #9aa0a6;
    letter-spacing: 0.2px;
}
.model-info b { color: #cfd3d8; font-weight: 600; }

/* --- Live engine-activity pill (what the LLM/detector is doing right now) --- */
.engine-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.llm-activity {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.2);
}
.llm-activity .llm-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-secondary); flex: 0 0 auto;
}
.llm-activity.idle { opacity: 0.7; }
.llm-activity.busy { color: #cfd3d8; border-color: rgba(74, 222, 128, 0.4); }
.llm-activity.busy .llm-dot { background: #4ade80; animation: llm-pulse 0.9s ease-in-out infinite; }
@keyframes llm-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* --- Player status pill + transcript placeholder + overflow safety (UX polish) --- */
.player-status {
    display: none;
    align-items: center;
    gap: 6px;
    width: fit-content;
    margin: 2px 0;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}
.player-status.live {
    color: #6bcf7f;
    background: rgba(107, 207, 127, 0.14);
}
.player-status.live::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #6bcf7f;
    animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Keep a long station name from pushing the controls off-screen */
.player-station-info, .station-text { min-width: 0; }
#player-station-name {
    display: block;
    max-width: 42vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#transcript-container { position: relative; }
#transcript-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none;
}

/* --- Header actions + export + jump-to-live (free features) --- */
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
#export-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#export-btn:hover { background-color: rgba(255, 255, 255, 0.18); }

#jump-live-btn {
    display: none;
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--red-primary);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
#jump-live-btn:hover { filter: brightness(1.1); }

/* --- Now-playing (ICY metadata) line in the player bar --- */
.now-playing {
    display: none;
    max-width: 42vw;
    margin: 1px 0;
    font-size: 0.75rem;
    color: #6bcf7f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Live translation --- */
/* --- Parallel translation column --- */
.u-trans { display: none; }   /* hidden until translation is on */
#transcript-content.translating .utterance {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.25rem;
    align-items: start;
}
#transcript-content.translating .u-trans {
    display: block;
    font-size: 0.82em;
    color: #8fd0ff;
    font-style: italic;
    border-left: 2px solid rgba(143, 208, 255, 0.35);
    padding-left: 0.9rem;
    overflow-wrap: anywhere;
}
#transcript-content.translating .u-trans:empty::before {
    content: '…';   /* placeholder while the translation streams in */
    opacity: 0.4;
}
/* Side-by-side is too cramped on a phone — stack translation under the original */
@media (max-width: 768px) {
    #transcript-content.translating .utterance { grid-template-columns: 1fr; }
    #transcript-content.translating .u-trans {
        border-left: none;
        border-top: 1px dashed rgba(255, 255, 255, 0.15);
        padding-left: 0;
        padding-top: 6px;
        margin-top: 4px;
    }
}
#translate-select {
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white-primary);
    border-radius: 20px;
    cursor: pointer;
    max-width: 9rem;
}
#translate-select option { background: #1a1a1a; color: #fff; }
@media (max-width: 600px) { #translate-select { max-width: 7rem; font-size: 0.75rem; } }


/* --- Responsive layout: summary side-panel, landscape, player-bar wrap --- */
/* Wide screens: lay transcript + summary side by side (CSS grid areas, no DOM change)
   so the summary stops eating transcript height (review #9). */
@media (min-width: 1024px) {
    #app-container {
        display: grid;
        grid-template-columns: 1fr 340px;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header  header"
            "main    summary"
            "player  player";
    }
    #main-header  { grid-area: header; }
    #main-content { grid-area: main; min-height: 0; }
    #summary-panel { grid-area: summary; min-height: 0; padding: 0 1rem 1rem 0; display: flex; }
    #player-bar   { grid-area: player; }
    .summary-content { max-height: none; height: 100%; flex: 1; }
}

/* Short/landscape viewports (e.g. phone landscape): give the transcript the room.
   Shrink the player bar, tighten the header, and cap the summary band hard. */
@media (max-height: 480px) {
    :root { --player-height: 60px; }
    #main-header { padding: 0.4rem 1rem; }
    h1 { font-size: 1rem; }
    .summary-content { max-height: 22vh; }
}

/* Player bar must survive very narrow widths without its right cluster overflowing. */
#player-bar { flex-wrap: wrap; row-gap: 4px; }
.player-station-info { min-width: 0; flex: 1 1 auto; }
.station-text { min-width: 0; }
#player-station-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sub-info { flex-wrap: wrap; }
#player-controls { flex-shrink: 0; }
@media (max-width: 360px) {
    .player-station-info { gap: 0.5rem; }
    .station-logo { height: 40px; width: 40px; }
}

/* --- Station cards (Favorites / News / Popular / Discover) ---
   .station-card is a <button>; buttons don't inherit font/color/text-align by default,
   which .station-item (a <div>, styled this way originally) never had to account for. */
.station-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
}
.station-card:hover {
    background: var(--btn-bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-1);
}
.station-card .station-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--grey-dark);
    flex-shrink: 0;
}
.station-card .station-info { flex: 1; min-width: 0; }
.station-card .station-name {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.station-card .station-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.station-card .station-tag {
    background: rgba(0, 116, 217, 0.25);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    padding: 0.1rem 0.5rem;
    border-radius: var(--r-pill);
    font-size: 0.7rem;
    font-weight: 500;
}
.station-card .language-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #1d7a35;   /* darkened for WCAG-AA on small uppercase text */
    color: var(--white-primary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-sm);
    font-size: 0.65rem;
    font-weight: 600;
}
.station-card .language-badge.unsupported-language {
    background: #b02a37;   /* darkened red for AA */
}
.station-card.station-blocked {
    opacity: 0.5;
    border-color: var(--status-error);
}
.discover-empty {
    color: var(--text-secondary);
    padding: 1rem;
    font-size: 0.9em;
}
