:root {
    --bg-color: #000510;
    /* Cinematic deep blue-black — richer depth */
    --text-color: #d4ffff;

    /* Primary 1982 Neon Palette */
    --accent-cyan: #00f3ff;
    /* Classic Program Cyan */
    --accent-cyan-dark: #008a91;
    --accent-orange: #ff6a10;
    /* MCP/Sark Orange-Red — slightly warmer */
    --accent-orange-dark: #b33c00;
    --accent-red: #ff2a00;
    --accent-purple: #bc13fe;
    --accent-emerald: #00ff8e;

    /* Layered Glows (Enhanced Vintage Bloom) */
    --border-glow:
        0 0 6px var(--accent-cyan),
        0 0 15px rgba(0, 243, 255, 0.5),
        0 0 30px rgba(0, 243, 255, 0.15),
        inset 0 0 10px rgba(0, 243, 255, 0.2);

    --text-glow:
        0 0 10px rgba(0, 243, 255, 0.9),
        0 0 20px rgba(0, 243, 255, 0.4),
        0 0 40px rgba(0, 243, 255, 0.15);

    --user-glow:
        0 0 10px rgba(255, 106, 16, 0.7),
        0 0 20px rgba(255, 106, 16, 0.35);

    --hover-glow:
        0 0 18px var(--accent-cyan),
        0 0 35px rgba(0, 243, 255, 0.5),
        inset 0 0 15px rgba(0, 243, 255, 0.25);

    /* Panel & Grid System */
    --grid-color: rgba(0, 243, 255, 0.22);
    --panel-bg: rgba(0, 8, 18, 0.92);
    --panel-border: 1px solid rgba(0, 243, 255, 0.45);
    --circuit-line: rgba(0, 243, 255, 0.15);

    /* Functional Colors */
    --bit-yes: var(--accent-cyan);
    --bit-no: var(--accent-red);
    --photon-color: rgba(0, 243, 255, 0.9);

    /* Glassmorphism & Depth — deeper, richer */
    --glass-bg: rgba(0, 8, 18, 0.78);
    --glass-border: 1px solid rgba(0, 243, 255, 0.35);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.85), 0 0 60px rgba(0, 243, 255, 0.04);
    --glass-blur: blur(14px);

    /* Typography */
    --message-font-size: 1.1rem;
    --header-font: 'Orbitron', sans-serif;
    --body-font: 'Share Tech Mono', monospace;
    /* Technical readout look */
    --ui-font: 'VT323', monospace;
}

@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes heartbeat {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

@keyframes scanline-move {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

@keyframes photon-flow {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* ====== NEW TRON ENHANCEMENT ANIMATIONS ====== */

@keyframes energy-flow {
    0% { box-shadow: inset 0 0 8px rgba(0, 243, 255, 0.15), 0 0 5px rgba(0, 243, 255, 0.1); }
    50% { box-shadow: inset 0 0 15px rgba(0, 243, 255, 0.25), 0 0 12px rgba(0, 243, 255, 0.2); }
    100% { box-shadow: inset 0 0 8px rgba(0, 243, 255, 0.15), 0 0 5px rgba(0, 243, 255, 0.1); }
}

@keyframes border-breathe {
    0%, 100% { border-color: rgba(0, 243, 255, 0.35); }
    50% { border-color: rgba(0, 243, 255, 0.6); }
}

@keyframes horizon-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.75; }
}

@keyframes data-stream {
    0% { background-position: 0 0; }
    100% { background-position: 0 200px; }
}

@keyframes input-trace {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

@keyframes scroll-btn-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--accent-cyan), inset 0 0 5px rgba(0, 243, 255, 0.15); }
    50% { box-shadow: 0 0 20px var(--accent-cyan), 0 0 40px rgba(0, 243, 255, 0.2), inset 0 0 10px rgba(0, 243, 255, 0.25); }
}

.photon-pulse {
    position: relative;
    overflow: hidden;
}

.photon-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(0, 243, 255, 0) 40%,
            rgba(0, 243, 255, 0.2) 50%,
            rgba(0, 243, 255, 0) 60%,
            transparent 100%);
    animation: photon-flow 4s infinite linear;
    pointer-events: none;
    z-index: 5;
}

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Share+Tech+Mono&family=VT323&family=Inter:wght@300;400;500&family=Noto+Emoji:wght@300..700&display=swap');

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

body {
    font-family: var(--body-font);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(ellipse 120% 40% at 50% 105%, rgba(0, 243, 255, 0.12) 0%, transparent 60%);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    letter-spacing: 0.1px;
}

/* Vignette Overlay — draws eye to center */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.5) 100%);
    pointer-events: none;
    z-index: 48;
}

/* CRT Scanlines and Vector Flicker Overlay */
body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(to bottom,
            rgba(18, 16, 16, 0) 50%,
            rgba(0, 20, 30, 0.25) 50%);
    background-size: 100% 3px;
    z-index: 50; /* Lower than container (100) to prevent touch interception */
    pointer-events: none;
    opacity: 0.35;
    animation: flicker 0.1s infinite;
}

/* Holographic Noise Overlay */
.hologram-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiIHZpZXdCb3g9IjAgMCA0IDQiPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InJnYmEoMCwyNTUsMjU1LDAuMDUpIi8+PC9zdmc+');
    opacity: 0.1;
    z-index: 49;
    pointer-events: none;
}

.scanline-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.25), transparent);
    opacity: 0.4;
    pointer-events: none;
    z-index: 100;
    animation: scanline-move 6s linear infinite;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
}

@keyframes flicker {

    0%,
    100% {
        opacity: 0.28;
    }

    33% {
        opacity: 0.31;
    }

    66% {
        opacity: 0.25;
    }

    77% {
        opacity: 0.35;
    }

    88% {
        opacity: 0.22;
    }
}

button,
.settings-btn,
#send-btn {
    font-family: var(--header-font);
    text-transform: uppercase;
    letter-spacing: 2px;
    border: 1px solid var(--accent-cyan);
    background: rgba(0, 243, 255, 0.08);
    color: var(--accent-cyan);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    overflow: hidden;
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
    touch-action: manipulation;
    min-height: 32px; /* Ensure 44px hit target on mobile via media query */
}

button:hover,
.settings-btn:hover,
#send-btn:hover {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: var(--hover-glow);
    text-shadow: 0 0 10px #fff;
    transform: translateY(-1px);
}

.settings-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s infinite linear;
    pointer-events: none;
}

button.active,
.settings-btn.active {
    background: rgba(0, 243, 255, 0.3);
    box-shadow: var(--border-glow);
    color: #fff;
    border-color: #fff;
}

button:active,
.settings-btn:active,
#send-btn:active {
    transform: translateY(1px);
    background: rgba(0, 243, 255, 0.4);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Custom Webkit Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 5, 12, 0.8);
    border-left: 1px solid rgba(0, 243, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--accent-cyan-dark), var(--accent-cyan));
    box-shadow: 0 0 10px var(--accent-cyan);
    border-radius: 4px;
    border: 2px solid rgba(0, 0, 0, 0.5);
}

/* TRON Grid Background — Enhanced */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 80px 80px;
    background-position: center bottom;
    transform: perspective(600px) rotateX(65deg) translateY(-200px) scale(4);
    z-index: -1;
    animation: grid-move 16s linear infinite;
    opacity: 0.8;
}

.grid-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 100%, transparent 20%, var(--bg-color) 85%);
    z-index: 1;
}

.grid-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, var(--accent-cyan) 0%, transparent 10%);
    opacity: 0.2;
    pointer-events: none;
}

/* Circuit Traces Background */
.circuit-traces-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.2;
    /* Subtle */
    background-image:
        radial-gradient(circle at 10% 10%, var(--circuit-line) 1px, transparent 1px),
        radial-gradient(circle at 90% 90%, var(--circuit-line) 1px, transparent 1px);
    background-size: 300px 300px;
    animation: circuit-move 60s linear infinite;
}

.circuit-traces-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(45deg, var(--circuit-line) 0, var(--circuit-line) 1px, transparent 0, transparent 50px),
        repeating-linear-gradient(-45deg, var(--circuit-line) 0, var(--circuit-line) 1px, transparent 0, transparent 50px);
    opacity: 0.1;
}

@keyframes circuit-move {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 300px 300px;
    }
}

/* The Bit Mascot */
.bit-container {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    z-index: 1000;
    cursor: help;
    filter: drop-shadow(0 0 10px var(--accent-cyan));
    animation: bit-float 4s ease-in-out infinite;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
    overflow: hidden; /* Prevent text blowout */
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
    margin-left: auto;
    flex-shrink: 0;
    padding-right: 0; /* Flush to edge */
}

.header-left .bit-container {
    position: relative;
    top: auto;
    right: auto;
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 0 5px var(--accent-cyan));
    animation: bit-float 4s ease-in-out infinite;
    flex-shrink: 0;
}

.bit-shape {
    width: 100%;
    height: 100%;
    background: var(--bit-yes);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    /* Base poly */
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: bit-pulse 1.5s infinite alternate;
    box-shadow: 0 0 15px var(--bit-yes);
}

/* Bit States */
.bit-container.no .bit-shape {
    background: var(--bit-no);
    clip-path: polygon(50% 0%, 70% 30%, 100% 50%, 70% 70%, 50% 100%, 30% 70%, 0% 50%, 30% 30%);
}

.bit-container.loading .bit-shape {
    animation: bit-spin 0.8s infinite linear, bit-pulse 0.4s infinite alternate;
    clip-path: polygon(50% 10%, 90% 50%, 50% 90%, 10% 50%);
}

@keyframes bit-float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-3px) rotate(5deg);
    }
}

@keyframes bit-pulse {
    from {
        transform: scale(0.9);
        opacity: 0.8;
    }

    to {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes bit-spin {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(360deg);
    }
}

@keyframes grid-move {
    0% {
        background-position: center 0;
    }

    100% {
        background-position: center 1000px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    position: relative;
    z-index: 100;
}

header {
    flex-shrink: 0;
    background: var(--glass-bg);
    padding: 0;
    min-height: 32px;
    height: auto;
    border-radius: 0;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: var(--glass-blur);
    position: relative;
    box-shadow: var(--glass-shadow);
    border: var(--panel-border);
    z-index: 101; /* Above container to ensure clean taps */
}

.header-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 1rem;
    height: 32px;
    flex-shrink: 0;
}

header::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            var(--accent-cyan) 20%,
            var(--accent-cyan) 80%,
            transparent 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
    opacity: 0.5;
}

header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: photon-pulse 5s linear infinite;
}

@keyframes photon-pulse {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }

    5%,
    15% {
        opacity: 1;
    }

    20% {
        transform: translateX(100%);
        opacity: 0;
    }

    21%,
    100% {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Header Expansion */
.header-expand-btn {
    transition: transform 0.3s ease;
    margin-right: -4px; /* Slight negative margin to offset button internal padding */
}

.header-expand-btn.active {
    transform: rotate(180deg);
}

.header-extra-row {
    width: 100%;
    padding: 0.4rem 1rem;
    border-top: 1px solid rgba(0, 243, 255, 0.25);
    animation: slideDown 0.3s ease-out;
    background: rgba(0, 243, 255, 0.08); /* Slightly more distinct */
    box-shadow: inset 0 1px 10px rgba(0, 243, 255, 0.05);
}

.header-quick-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
    padding-right: 0; /* Flush to edge */
}

@media (max-width: 768px) {
    .header-quick-controls {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .header-extra-row {
        height: auto !important;
        padding: 0.5rem;
    }
    .header-quick-controls .collapse-btn {
        position: absolute;
        top: 0;
        right: 0;
    }
}

.header-quick-controls .collapse-btn {
    margin-left: auto;
    margin-right: -4px; /* Flush to edge */
    color: var(--accent-orange);
    border-color: var(--accent-orange);
    font-size: 1rem;
    padding: 0 8px;
    font-weight: bold;
}

.header-quick-controls .collapse-btn:hover {
    background: rgba(255, 106, 16, 0.2);
    box-shadow: 0 0 15px var(--accent-orange);
    border-color: var(--accent-orange);
}

.header-quick-controls::-webkit-scrollbar {
    display: none;
}

.header-select {
    background: rgba(0, 5, 12, 0.8);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-family: var(--ui-font);
    font-size: 0.8rem;
    padding: 2px 5px;
    height: 24px;
    outline: none;
    cursor: pointer;
    max-width: 120px;
}

.header-action-btns {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.header-q-btn {
    font-size: 0.7rem;
    padding: 2px 8px;
    min-height: 24px !important;
    letter-spacing: 1px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-q-btn.active {
    background: rgba(0, 243, 255, 0.3);
    box-shadow: 0 0 8px var(--accent-cyan);
    color: #fff;
    border-color: #fff !important;
}

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

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, transparent 50%, var(--accent-cyan) 50%);
    opacity: 0.1;
    pointer-events: none;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    text-shadow: var(--text-glow);
    font-size: 1.5rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: glitch 5s infinite;
}

/* Header Navigation */
.header-nav {
    display: flex;
    gap: 0.5rem;
    margin-left: 1.5rem;
    align-items: center;
    flex-shrink: 0;
}

.nav-btn {
    font-size: 0.7rem;
    padding: 2px 14px;
    min-height: 24px !important;
    background: rgba(0, 243, 255, 0.05) !important;
    border: 1px solid rgba(0, 243, 255, 0.3) !important;
    color: var(--accent-cyan) !important;
    text-shadow: 0 0 5px var(--accent-cyan);
    clip-path: polygon(10% 0%, 100% 0%, 90% 100%, 0% 100%);
    transition: all 0.2s cubic-bezier(0.19, 1, 0.22, 1);
    letter-spacing: 1px !important;
}

.nav-btn.active {
    background: rgba(0, 243, 255, 0.2) !important;
    border-color: var(--accent-cyan) !important;
    color: #fff !important;
    box-shadow: 0 0 10px var(--accent-cyan) !important;
    text-shadow: 0 0 10px #fff;
}

.nav-btn:hover {
    background: rgba(0, 243, 255, 0.15) !important;
    transform: translateY(-1px);
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.3);
}

/* Voice Area Styles */
.voice-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: rgba(0, 5, 15, 0.6);
    border-radius: 0;
    border: 1px solid rgba(0, 243, 255, 0.15);
    overflow-y: auto;
    animation: slideDown 0.3s ease-out;
    position: relative;
    backdrop-filter: blur(10px);
}

.voice-controls-container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- VOICES TABS --- */
/* Hide old tab navigation */
.voice-tab-nav, .voice-tabs {
    display: none !important;
}

/* Mobile-Friendly Tab Nav (Legacy) */
.voice-tab-nav-legacy {
    display: flex;
    gap: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for cleaner look */
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.voice-tab-nav::-webkit-scrollbar {
    display: none;
}

.voice-tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-family: var(--header-font);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.voice-tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.voice-tab-btn.active {
    color: var(--accent-cyan);
}

.voice-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
}

.voice-tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

.voice-tab-content.active {
    display: flex;
}

/* Voice Cards Grid */
.voice-cards-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 2rem;
    padding: 0 4px;
}

/* Advanced Settings Styling */
.voice-advanced-settings {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-top: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.voice-settings-header {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    user-select: none;
}

.voice-settings-header:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.voice-settings-toggle {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.voice-advanced-settings.collapsed .voice-settings-toggle {
    transform: rotate(-90deg);
}

.voice-settings-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-advanced-settings.collapsed .voice-settings-content {
    display: none;
}

.voice-setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.voice-setting-row label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    justify-content: space-between;
}

.voice-setting-row span {
    color: var(--accent-color, #00f2ff);
    font-family: monospace;
}

.voice-presets-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.voice-presets-row label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    display: block;
}

.voice-preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.voice-preset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.voice-preset-btn.active {
    background: var(--accent-color, #00f2ff22);
    border-color: var(--accent-color, #00f2ff);
    color: var(--accent-color, #00f2ff);
}

.voice-preset-btn.reset {
    margin-left: auto;
    background: rgba(255, 100, 100, 0.1);
    border-color: rgba(255, 100, 100, 0.2);
    color: rgba(255, 150, 150, 0.8);
}

.voice-preset-btn.reset:hover {
    background: rgba(255, 100, 100, 0.2);
    color: #ff8888;
}

.voice-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.voice-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 100%);
    pointer-events: none;
}

.voice-card:hover {
    background: rgba(0, 243, 255, 0.05);
    border-color: rgba(0, 243, 255, 0.3);
    transform: translateY(-3px);
}

.voice-card.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan);
    animation: fadeIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.voice-card[data-persona="seven"].active::after { color: #fce1a6; text-shadow: 0 0 10px #fce1a6; }
.voice-card[data-persona="computer"].active::after { color: #9999ff; text-shadow: 0 0 10px #9999ff; }
.voice-card[data-persona="lcars"].active::after { color: #ff9933; text-shadow: 0 0 10px #ff9933; }
.voice-card[data-persona="mcp"].active::after { color: #ff2a00; text-shadow: 0 0 10px #ff2a00; }


.voice-card-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle, rgba(0, 243, 255, 0.1) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.voice-card.active .voice-card-glow {
    opacity: 1;
}

.voice-card-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.1));
    transition: transform 0.3s;
}

.voice-card:hover .voice-card-icon {
    transform: scale(1.1);
}

.voice-card-info {
    text-align: center;
}

.voice-card-name {
    font-family: var(--header-font);
    font-size: 0.85rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.voice-card-desc {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 0.2rem;
    font-family: var(--body-font);
}

/* Specific Persona Accent Colors */
.voice-card[data-persona="seven"].active { border-color: #fce1a6; }
.voice-card[data-persona="seven"].active .voice-card-name { color: #fce1a6; }

.voice-card[data-persona="computer"].active { border-color: #9999ff; }
.voice-card[data-persona="computer"].active .voice-card-name { color: #9999ff; }

.voice-card[data-persona="lcars"].active { border-color: #ff9933; }
.voice-card[data-persona="lcars"].active .voice-card-name { color: #ff9933; }

.voice-card[data-persona="mcp"].active { border-color: #ff2a00; }
.voice-card[data-persona="mcp"].active .voice-card-name { color: #ff2a00; }

.voice-text-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.voice-text-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-text-section label {
    font-family: var(--header-font);
    font-size: 0.7rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

#voice-text {
    width: 100%;
    min-height: 150px;
    background: rgba(0, 3, 8, 0.8);
    border: 1px solid rgba(0, 243, 255, 0.3);
    color: #fff;
    font-family: var(--body-font);
    font-size: 1.1rem;
    padding: 1rem;
    outline: none;
    resize: vertical;
    box-shadow: inset 0 0 15px rgba(0, 243, 255, 0.05);
    transition: all 0.3s ease;
}

#voice-text:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.1), inset 0 0 10px rgba(0, 243, 255, 0.05);
}

.voice-text-preview-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.voice-text-preview-section label {
    font-family: var(--header-font);
    font-size: 0.65rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

#voice-clone-text-preview {
    width: 100%;
    min-height: 80px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--body-font);
    font-size: 0.9rem;
    padding: 0.75rem;
    outline: none;
    resize: none;
    cursor: default;
}

/* Advanced Params */
.voice-advanced-params {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.param-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-container-enhanced {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.slider-qualitative-labels {
    display: flex;
    justify-content: space-between;
    width: 100px;
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 2px;
}

/* Slider Reset Button */
.slider-reset-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 5px;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-reset-btn:hover {
    color: var(--accent-cyan);
    transform: rotate(-180deg);
}

.param-group label {
    font-family: var(--header-font);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.slider-wrapper input[type="range"] {
    width: 100px;
    accent-color: var(--accent-cyan);
    height: 4px;
    cursor: pointer;
}

.slider-wrapper span {
    font-family: var(--ui-font);
    font-size: 0.75rem;
    color: var(--accent-cyan);
    min-width: 35px;
}

/* Enhanced Custom Section */
.voice-custom-section-enhanced {
    background: rgba(255, 106, 16, 0.02);
    border: 1px solid rgba(255, 106, 16, 0.15);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    animation: fadeIn 0.4s ease-out;
}

.voice-custom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-custom-label {
    font-family: var(--header-font);
    font-size: 0.85rem;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.custom-voice-status {
    font-family: var(--ui-font);
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.custom-voice-status.active {
    color: var(--accent-orange);
    border-color: var(--accent-orange);
    background: rgba(255, 106, 16, 0.1);
    animation: status-pulse 1.5s infinite alternate;
}

.voice-custom-main {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: 1.5rem;
}

.voice-custom-drop-zone {
    position: relative;
    border: 1px dashed rgba(255, 106, 16, 0.2);
    transition: all 0.3s;
    border-radius: 4px;
}

.voice-custom-drop-zone.drag-over {
    border-color: var(--accent-orange);
    background: rgba(255, 106, 16, 0.05);
    box-shadow: inset 0 0 20px rgba(255, 106, 16, 0.1);
}

.drop-zone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 10;
}

.voice-custom-drop-zone.drag-over .drop-zone-overlay {
    opacity: 1;
}

.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: bounce 1s infinite;
}

.drop-zone-text {
    font-family: var(--header-font);
    font-size: 0.75rem;
    color: var(--accent-orange);
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.voice-custom-visualizer {
    height: 140px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 106, 16, 0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#voice-sample-waveform {
    width: 100%;
    height: 100%;
}

.visualizer-overlay {
    position: absolute;
    font-family: var(--header-font);
    font-size: 0.6rem;
    color: rgba(255, 106, 16, 0.2);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.voice-custom-controls-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.voice-action-btn {
    padding: 0.7rem;
    font-family: var(--header-font);
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.voice-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.voice-action-btn.record-btn { border-color: #ff4d4d; color: #ff4d4d; }
.voice-action-btn.record-btn:hover { background: rgba(255, 77, 77, 0.1); }
.voice-action-btn.play-btn { border-color: var(--accent-emerald); color: var(--accent-emerald); }
.voice-action-btn.play-btn:hover { background: rgba(0, 255, 142, 0.1); }
.voice-action-btn.upload-btn { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.voice-action-btn.upload-btn:hover { background: rgba(0, 243, 255, 0.1); }

.voice-ref-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 106, 16, 0.2);
    padding: 0.8rem;
    color: #fff;
    font-family: var(--body-font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.voice-ref-input:focus {
    border-color: var(--accent-orange);
}

/* History Tab */
.voice-history-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.4s ease-out;
}

.voice-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-history-header label {
    font-family: var(--header-font);
    font-size: 0.85rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.voice-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan) transparent;
}

.voice-history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.voice-history-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 243, 255, 0.2);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.history-item-speaker {
    font-family: var(--header-font);
    font-size: 0.6rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

.history-item-text {
    font-family: var(--body-font);
    font-size: 0.9rem;
    color: #fff;
}

.history-item-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.2);
    margin-top: 0.2rem;
}

.history-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.history-item-reference {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
    background: rgba(0, 243, 255, 0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    width: fit-content;
}

.history-ref-play-btn {
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
}

.history-ref-play-btn:hover {
    color: #fff;
    text-shadow: 0 0 5px var(--accent-cyan);
}

.history-item-ref-text {
    font-style: italic;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-params {
    color: var(--accent-orange);
    font-family: var(--header-font);
    font-weight: bold;
}

.history-load-btn, .history-play-btn, .history-download-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-load-btn:hover {
    background: rgba(255, 155, 0, 0.2);
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(255, 155, 0, 0.3);
}

.history-play-btn:hover {
    background: rgba(0, 243, 255, 0.2);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.history-download-btn:hover {
    background: rgba(175, 45, 255, 0.2);
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(175, 45, 255, 0.3);
}

/* --- Phase 3: Mobile Optimization Overrides --- */
@media (max-width: 768px) {
    .voice-area {
        padding: 1rem;
    }

    .voice-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.8rem;
    }

    .voice-custom-main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .voice-custom-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .voice-advanced-params {
        flex-direction: column;
        align-items: stretch;
        gap: 1.2rem;
    }

    .slider-container-enhanced {
        width: 100%;
    }

    .slider-wrapper {
        justify-content: space-between;
    }

    .slider-wrapper input[type="range"] {
        flex: 1;
        width: auto;
    }
}

@media (max-width: 480px) {
    .voice-tab-btn {
        padding: 0.6rem 0.5rem;
        font-size: 0.65rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .voice-card {
        padding: 0.8rem;
    }

    .voice-card-icon {
        font-size: 1.5rem;
    }

    .voice-card-name {
        font-size: 0.75rem;
    }

    .voice-custom-section-enhanced {
        padding: 1rem;
    }

    .voice-custom-visualizer {
        height: 100px;
    }

    .voice-primary-btn {
        width: 100%;
        padding: 1rem 0;
        text-align: center;
    }
}

.voice-secondary-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.8rem;
    font-family: var(--header-font);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s;
}

.voice-secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.voice-secondary-btn.danger-btn {
    color: #ff4d4d;
    border-color: rgba(255, 77, 77, 0.2);
}

.voice-secondary-btn.danger-btn:hover {
    background: rgba(255, 77, 77, 0.1);
    border-color: #ff4d4d;
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.2);
}

/* Footer & Suggestion */
.voice-footer-actions {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    border-top: 1px solid rgba(0, 243, 255, 0.1);
    padding-top: 2rem;
}

.suggestion-trigger-row {
    display: flex;
    gap: 1rem;
}

.suggestion-box {
    background: rgba(0, 255, 142, 0.05);
    border-left: 3px solid var(--accent-emerald);
    padding: 1.2rem;
    font-family: var(--body-font);
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    font-size: 1rem;
    box-shadow: inset 0 0 15px rgba(0, 255, 142, 0.05);
}

.voice-primary-btn {
    align-self: flex-end;
    background: transparent;
    border: 1.5px solid var(--accent-orange);
    color: var(--accent-orange);
    padding: 1rem 3rem;
    font-family: var(--header-font);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 4px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

.voice-primary-btn:hover {
    background: var(--accent-orange);
    color: #000;
    box-shadow: 0 0 40px rgba(255, 157, 0, 0.4);
    transform: translateY(-2px);
}

.voice-primary-btn:active {
    transform: translateY(0);
}

.btn-glow {
    position: absolute;
    top: 50%;
    left: -100%;
    width: 80px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: translateY(-50%) skewX(-20deg);
    animation: btn-shine 4s infinite;
}

@keyframes btn-shine {
    0% { left: -100%; }
    15% { left: 180%; }
    100% { left: 180%; }
}

.status-metrics {
    flex-shrink: 0;
    background: rgba(0, 10, 20, 0.9);
    backdrop-filter: blur(25px);
    padding: 0.6rem 1rem;
    border-radius: 0;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--header-font);
    font-size: 0.7rem;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%);
    border-left: 3px solid var(--accent-cyan);
    box-shadow: -10px 0 20px rgba(0, 243, 255, 0.1);
    min-height: 90px;
}

.status-metrics::before {
    display: none;
    /* Remove old complex mask border */
}

.metrics-grid {
    display: flex;
    gap: 0.75rem;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar for clean look */
    padding-bottom: 2px;
    background: rgba(0, 243, 255, 0.03);
    border-radius: 4px;
}

.metrics-grid::-webkit-scrollbar {
    display: none;
}

.metric {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent-cyan);
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.5);
    white-space: nowrap;
    padding: 0.2rem 0.4rem;
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.metric::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.2), transparent);
    animation: metric-scan 3s infinite linear;
}

@keyframes metric-scan {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.metric-icon {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 3px currentColor);
}

.metric span {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
    margin-left: 0.1rem;
    font-weight: 700;
    display: inline-block;
    min-width: 2.2rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.metric.status-col {
    background: rgba(0, 229, 255, 0.15);
    border-color: var(--accent-cyan);
    padding: 0.2rem 0.6rem;
}

.metric.status-col span {
    letter-spacing: 1px;
}

.metric.sys-cpu,
.metric.sys-cpu .metric-icon {
    color: #00f3ff;
}

.metric.sys-ram,
.metric.sys-ram .metric-icon {
    color: #0070ff;
}

.metric.llm-cpu,
.metric.llm-cpu .metric-icon {
    color: #ff8c00;
}

.metric.llm-ram,
.metric.llm-ram .metric-icon {
    color: #ff00ff;
}

.metric.stt-cpu,
.metric.stt-cpu .metric-icon {
    color: #00ff00;
}

.metric.stt-ram,
.metric.stt-ram .metric-icon {
    color: #ffff00;
}

.graph-container {
    height: 35px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 229, 255, 0.1);
    border-radius: 0;
    position: relative;
    overflow: hidden;
    width: 100%;
    flex: 1 1 100%;
    /* Force to new line in flex-wrap */
}

.kill-btn {
    background: transparent;
    border: 1px solid #ff4444;
    color: #ff4444;
    padding: 0.1rem 0.5rem;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    transition: all 0.2s;
    margin-left: auto;
}

.kill-btn:hover {
    background: #ff4444;
    color: #000;
    box-shadow: 0 0 10px #ff4444;
}

/* Monochrome Emoticons - Using Noto Emoji Font */
.mono-emoji {
    font-family: 'Noto Emoji', sans-serif;
    color: var(--accent-cyan);
    text-shadow: var(--text-glow);
    display: inline-block;
    transition: all 0.2s ease;
    font-size: 1.1em;
    vertical-align: middle;
    line-height: 1.4;
}

.quota-list-container {
    background: rgba(0, 243, 255, 0.05);
    border: 1px solid rgba(0, 243, 255, 0.2);
    padding: 8px;
    margin-top: 5px;
    font-family: 'Inter', sans-serif;
    border-radius: 4px;
}
.quota-header {
    font-weight: bold;
    color: #00f3ff;
    border-bottom: 1px solid rgba(0, 243, 255, 0.3);
    margin-bottom: 5px;
    padding-bottom: 3px;
    font-size: 0.8em;
}
.quota-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    padding: 2px 0;
}
.quota-key {
    color: #a0a0a0;
}
.quota-val {
    color: #ff9d00;
    font-weight: bold;
}

.message.user .mono-emoji {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}


header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    text-shadow: var(--text-glow);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-metrics {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-metrics .metric {
    min-height: auto;
    font-size: 0.75rem;
    padding: 2px 10px;
    background: rgba(0, 243, 255, 0.05);
    border: 1px solid rgba(0, 243, 255, 0.3);
    clip-path: polygon(10% 0%, 100% 0%, 90% 100%, 0% 100%);
    box-shadow: inset 0 0 8px rgba(0, 243, 255, 0.1);
    color: var(--accent-cyan);
    text-shadow: 0 0 5px var(--accent-cyan);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-speech-controls,
.header-text-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(0, 243, 255, 0.05);
    padding: 2px 8px;
    border: 1px solid rgba(0, 243, 255, 0.1);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: 'VT323', monospace;
    color: var(--accent-cyan);
    white-space: nowrap;
}

#header-status, #header-status-metrics {
    display: inline-block;
    min-width: 90px; /* Fixed width to prevent shifting */
    text-align: center;
}

#status-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff2a00;
    box-shadow: 0 0 5px #ff2a00;
    transition: all 0.3s ease;
    flex-shrink: 0;
    animation: heartbeat 2s infinite;
}

@media (max-width: 900px) {
    header {
        height: auto;
        min-height: 32px;
        padding: 0 0.5rem;
    }

    header h1 {
        display: none !important;
    }

    .header-left {
        gap: 0.5rem;
    }

    .header-right {
        gap: 0.4rem;
    }

    #connection-indicator {
        padding: 1px 4px;
        font-size: 0.6rem;
    }

    .header-metrics .metric {
        font-size: 0.6rem;
        padding: 0.05rem 0.2rem;
    }
}

#model-select,
#voice-select,
.stt-engine-select {
    background: #000;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 0.3rem 0.6rem;
    border-radius: 2px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    outline: none;
    box-shadow: 0 0 5px var(--accent-cyan);
}


.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-cyan);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.chat-area-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    background: rgba(0, 5, 12, 0.35);
    backdrop-filter: blur(10px);
    margin-bottom: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan) transparent;
    border-radius: 0;
    position: relative;
    border: var(--panel-border);
    box-shadow: inset 0 0 50px rgba(0, 243, 255, 0.06);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 25px), calc(100% - 25px) 100%, 0 100%);
    animation: energy-flow 6s ease-in-out infinite, border-breathe 4s ease-in-out infinite;
}

.chat-box::before {
    display: none;
}

.message {
    margin-bottom: 0.75rem;
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: message-appear 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    padding: 0.5rem 0;
    transition: transform 0.25s ease, filter 0.25s ease;
}

.message:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.message.bot {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

/* Premium System Alert Styling */
.message.system-alert {
    align-self: center;
    max-width: 90%;
    margin: 1.5rem 0;
    padding: 1rem 2rem;
    background: rgba(255, 94, 0, 0.05);
    border: 1px solid rgba(255, 94, 0, 0.3);
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(255, 94, 0, 0.1), inset 0 0 15px rgba(255, 94, 0, 0.05);
    text-align: center;
    position: relative;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.message.system-alert::before {
    content: '! SYSTEM ALERT !';
    display: block;
    font-size: 0.65rem;
    color: var(--accent-orange);
    margin-bottom: 0.5rem;
    opacity: 0.8;
    text-shadow: 0 0 10px var(--accent-orange);
}

.message.system-alert .message-meta {
    display: none; /* Hide default meta for alerts */
}

.message.system-alert .message-content {
    color: var(--accent-orange);
    font-size: 0.9rem;
    text-shadow: 0 0 15px rgba(255, 94, 0, 0.5);
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Retrying Status */
#header-status.retrying {
    color: #ff9d00;
    text-shadow: 0 0 10px #ff9d00;
    animation: status-pulse 1.5s infinite;
}

@keyframes status-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* CRT Mode Overrides for System Alerts */
body.terminal-mode .message.system-alert {
    display: flex !important;
    flex-direction: row !important;
    align-self: flex-start !important;
    max-width: 100% !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important; /* High density */
    text-align: left !important;
    font-family: var(--header-font) !important;
    gap: 0.5rem !important;
    align-items: baseline !important;
}

body.terminal-mode .message.system-alert .message-time {
    order: -2 !important;
    color: #ffcc00 !important;
    opacity: 0.8 !important;
    margin: 0 !important;
}

body.terminal-mode .message.system-alert .message-time::before {
    content: '[';
}

body.terminal-mode .message.system-alert .message-time::after {
    content: ']';
}

body.terminal-mode .message.system-alert::before {
    content: '[SYSTEM]' !important;
    order: -1 !important;
    display: inline !important;
    font-size: inherit !important;
    margin: 0 !important;
    color: #ffcc00 !important;
    opacity: 0.9 !important;
}

body.terminal-mode .message.system-alert .message-meta {
    display: none !important;
}

body.terminal-mode .message.system-alert .message-content {
    display: inline !important;
    color: #ffcc00 !important;
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.5) !important;
    padding: 0 !important;
    margin: 0 !important;
}

.message.user {
    align-self: flex-end;
}

.message-meta {
    font-size: 0.8em;
    margin-bottom: 0.1rem;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.message-time {
    opacity: 0.7;
    font-size: 0.85em;
}

.message.user .message-meta {
    flex-direction: row-reverse;
    color: var(--accent-orange);
    text-shadow: var(--user-glow);
}

.message.bot .message-meta {
    color: var(--accent-cyan);
    font-weight: 500;
}

.model-tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 600px) {
    .message.bot .message-meta {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.4rem;
    }

    .message-icon {
        flex-shrink: 0;
        width: 18px;
        height: 18px;
    }

    .model-tags-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
        line-height: 1;
    }

    .model-tag,
    .thinking-time-tag,
    .persona-tag,
    .auto-reply-tag {
        font-size: 0.5rem !important;
        padding: 0 3px !important;
        margin: 0 !important;
        min-width: unset !important;
        width: fit-content !important;
        background: rgba(0, 243, 255, 0.05) !important;
        border: 1px solid rgba(0, 243, 255, 0.2) !important;
        height: 10px;
        display: inline-flex;
        align-items: center;
        letter-spacing: 0.5px;
    }

    .message.bot .message-meta .thinking-time-tag {
        border-color: rgba(255, 157, 0, 0.3) !important;
        color: var(--accent-orange) !important;
    }

    .auto-reply-text {
        display: none;
    }

    .auto-reply-icon {
        display: block;
    }

    .message-time {
        font-size: 0.65rem !important;
        opacity: 0.5;
    }

    .model-size {
        display: none !important;
    }
}

/* --- TERMINAL MODE (TRON 1982 COMPACT) --- */
body.terminal-mode {
    --panel-border: 1px solid #11aa33;
    --accent-cyan: #33ff33;
    /* Switch core accent to Green for terminal feel */
    --accent-glow: 0 0 10px rgba(51, 255, 51, 0.4);
    font-family: 'Share Tech Mono', monospace !important;
}

body.terminal-mode .container {
    background: #000 !important;
    clip-path: none !important;
}

body.terminal-mode header,
body.terminal-mode .chat-box,
body.terminal-mode .input-area {
    clip-path: none !important;
    border-radius: 0 !important;
}

body.terminal-mode .message {
    padding: 2px 5px !important;
    margin-bottom: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100%;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important; /* Changed from baseline to prevent "too high" look */
    gap: 0 !important;
}

body.terminal-mode .message-time {
    order: 1 !important;
    font-size: 0.7rem !important;
    opacity: 0.6;
    margin-right: 0.2rem !important;
    white-space: nowrap !important;
}

body.terminal-mode .message-time::before {
    content: '[';
}

body.terminal-mode .message-time::after {
    content: ']';
}

body.terminal-mode .message-meta {
    font-size: 0.7rem !important;
    gap: 0.3rem !important;
    opacity: 0.6;
    display: inline-flex !important;
    align-items: center !important; /* Changed from baseline to prevent stretching */
    white-space: normal !important;
    cursor: help;
    order: 2 !important;
    overflow: visible !important;
    flex-wrap: wrap !important;
}

body.terminal-mode .message-icon,
body.terminal-mode .persona-tag,
body.terminal-mode .model-tags-wrapper,
body.terminal-mode .user-label,
body.terminal-mode .auto-reply-tag {
    order: 5 !important;
}

body.terminal-mode .message-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    order: 2 !important;
    margin-left: 0.2rem;
    opacity: 0.8;
}

body.terminal-mode .message.bot .message-icon {
    color: #33ff33;
}

body.terminal-mode .message.user .message-icon {
    color: var(--accent-orange);
}

body.terminal-mode .tts-btn {
    order: 3 !important;
    display: inline-flex !important;
    margin-left: 0.1rem !important;
    height: 14px !important; 
    min-height: 0 !important; /* Override global button min-height */
    line-height: 14px !important; /* Force tight line-height */
    padding: 0 4px !important;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem !important;
}

/* .persona-tag shown by default now */

body.terminal-mode .model-tags-wrapper {
    display: inline-flex !important;
    vertical-align: middle;
}

body.terminal-mode .auto-reply-tag {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    font-size: 0.7rem !important;
    color: var(--accent-orange) !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 0 0 0.5rem !important;
}

body.terminal-mode .auto-reply-tag::before {
    content: '[AUTO]';
}

body.terminal-mode .auto-reply-icon,
body.terminal-mode .auto-reply-text {
    display: none !important;
}

body.terminal-mode .model-tag,
body.terminal-mode .user-label {
    display: none !important;
}

body.terminal-mode .persona-tag {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    color: var(--accent-cyan) !important;
    font-weight: bold;
    font-size: 0.7rem !important;
    margin-left: 0.5rem !important;
}

body.terminal-mode .persona-tag::before {
    content: '[';
}

body.terminal-mode .persona-tag::after {
    content: ']';
}

body.terminal-mode .thinking-time-tag {
    display: none !important;
    font-size: 0.6rem !important;
    padding: 0 4px !important;
    min-width: unset !important;
    margin-left: 0.2rem !important;
    margin-right: 0.2rem !important;
    height: 14px !important;
    min-height: 0 !important;
    line-height: 14px !important;
    border-color: rgba(51, 255, 51, 0.4) !important;
    color: #33ff33 !important;
    order: 2.1 !important;
    align-items: center;
    justify-content: center;
}

body.terminal-mode .message-meta:hover .model-tag,
body.terminal-mode .message-meta:active .model-tag,
body.terminal-mode .message-meta:active .model-tag,
body.terminal-mode .message-meta:hover .user-label,
body.terminal-mode .message-meta:active .user-label,
body.terminal-mode .message-meta:hover .thinking-time-tag,
body.terminal-mode .message-meta:active .thinking-time-tag {
    display: inline-flex !important;
    margin-left: 0.3rem !important;
    order: 2.5 !important;
}

body.terminal-mode .cancel-msg-btn {
    display: inline-flex !important;
    background: rgba(51, 255, 51, 0.1) !important;
    border: 1px solid rgba(51, 255, 51, 0.4) !important;
    color: #33ff33 !important;
    padding: 0 4px !important;
    margin-left: 0.5rem !important;
    opacity: 0.8;
    cursor: pointer;
    vertical-align: middle;
    order: 4 !important;
    height: 14px !important;
    min-height: 0 !important;
    line-height: 14px !important;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem !important;
}

body.terminal-mode .message.user .tts-btn {
    background: rgba(255, 140, 0, 0.1) !important;
    border-color: rgba(255, 140, 0, 0.4) !important;
    color: var(--accent-orange) !important;
}

body.terminal-mode .tts-btn svg {
    width: 12px !important;
    height: 12px !important;
}

/* Time and Meta labels are handled above in CRT mode */

body.terminal-mode .message.bot .message-meta::after,
body.terminal-mode .message.user .message-meta::after {
    content: '';
}

body.terminal-mode .message-content {
    font-size: 0.85rem !important;
    line-height: 1.3 !important;
    padding: 0 0 0 0.1rem !important;
    color: #33ff33 !important;
    text-shadow: 0 0 5px rgba(51, 255, 51, 0.5);
    background: transparent !important;
    border: none !important;
    display: inline !important;
    clip-path: none !important;
    order: 3 !important;
    overflow: visible !important;
}

body.terminal-mode .message.user .message-content {
    color: var(--accent-orange) !important;
    text-shadow: 0 0 5px rgba(255, 140, 0, 0.5);
}

body.terminal-mode .chat-box {
    padding: 0.3rem !important;
    gap: 0 !important;
    overflow-x: visible !important;
}

body.terminal-mode header {
    padding: 0 0.5rem !important;
    height: auto !important;
    min-height: 24px !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
}

body.terminal-mode h1 {
    font-size: 0.75rem !important;
}

body.terminal-mode .header-left .bit-container {
    width: 16px;
    height: 16px;
    transform: scale(0.8);
}

body.terminal-mode .input-area {
    padding: 0.3rem !important;
    background: #000 !important;
    border-top: 1px solid #11aa33 !important;
}

body.terminal-mode #user-input {
    background: transparent !important;
    border: none !important;
    color: #33ff33 !important;
    font-family: 'Share Tech Mono', monospace !important;
}

body.terminal-mode .bit-container {
    transform: scale(0.6);
}

/* Subtle CRT scanline effect for terminal mode */
body.terminal-mode::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 50; /* Keep below interactive layers */
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    opacity: 0.1;
}

.cancel-msg-btn {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #ff4444;
    color: #ff4444;
    padding: 0 4px;
    font-size: 0.6rem;
    cursor: pointer;
    border-radius: 2px;
    margin-right: 0.5rem;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

.cancel-msg-btn:hover {
    background: #ff4444;
    color: #000;
}

.model-tag,
.auto-reply-tag,
.persona-tag {
    font-size: 0.75em;
    padding: 1px 4px;
    border-radius: 2px;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    border: 1px solid currentColor;
    background: rgba(0, 0, 0, 0.3);
}

.model-tag {
    color: var(--accent-cyan);
    opacity: 0.8;
}

.persona-tag {
    margin-left: 0;
    font-weight: 700;
}

.message-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.message.bot .message-icon {
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 3px var(--accent-cyan));
}

.message.user .message-icon {
    color: var(--accent-orange);
    filter: drop-shadow(0 0 3px var(--accent-orange));
}

.message-icon svg {
    display: block;
}

.persona-seven {
    border-color: #fce1a6;
    color: #fce1a6;
    box-shadow: 0 0 5px #fce1a6;
}

.persona-computer {
    border-color: #9999ff;
    color: #9999ff;
    box-shadow: 0 0 5px #9999ff;
}

.persona-mcp {
    border-color: #ff2a00;
    color: #ff2a00;
    box-shadow: 0 0 5px #ff2a00;
}

.persona-lcars {
    border-color: #ff9933;
    color: #ff9933;
    box-shadow: 0 0 5px #ff9933;
}

.thinking-time-tag {
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 2px;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    border: 1px solid rgba(255, 157, 0, 0.4);
    background: rgba(255, 157, 0, 0.05);
    color: var(--accent-orange);
    box-shadow: 0 0 5px rgba(255, 157, 0, 0.2);
    min-width: 95px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.auto-reply-tag {
    color: var(--accent-orange);
    box-shadow: 0 0 5px var(--accent-orange);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.auto-reply-icon {
    display: none;
}

.message.user .auto-reply-tag {
    border-color: var(--accent-orange);
}

.message-content {
    padding: 1rem 1.5rem;
    line-height: 1.6;
    font-size: var(--message-font-size);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    font-family: var(--body-font);
    color: var(--text-color);
    position: relative;
    border-radius: 0;
    border: var(--glass-border);
    box-shadow: var(--glass-shadow), inset 0 0 20px rgba(0, 243, 255, 0.06);
    clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message.user .message-content {
    background: rgba(40, 15, 0, 0.65);
    border-color: rgba(255, 106, 16, 0.45);
    box-shadow: 0 8px 32px rgba(255, 106, 16, 0.12), 0 0 30px rgba(255, 106, 16, 0.06);
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}

.tts-status-tag {
    font-size: 0.65rem;
    color: var(--accent-orange);
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    opacity: 0.8;
    margin-left: 0.5rem;
    animation: flash 2s infinite alternate;
}

@keyframes flash {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

/* data-tts-status styling removed as we use class on the button itself now */

.tts-play-btn:hover,
.tts-download-link:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 8px var(--accent-cyan);
}

.tts-play-btn svg {
    flex-shrink: 0;
}

.tts-history-entry {
    background: rgba(0, 243, 255, 0.05);
    border: 1px solid rgba(0, 243, 255, 0.2);
    padding: 6px 8px;
    margin-bottom: 4px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%);
}

.tts-history-entry.timeout {
    border-color: var(--accent-orange);
    background: rgba(255, 157, 0, 0.05);
}

.tts-history-entry.cancelled {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    opacity: 0.8;
}

.tts-history-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.tts-history-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.tts-history-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.tts-history-play {
    cursor: pointer;
    color: var(--accent-cyan);
    opacity: 0.7;
}

.tts-history-play:hover {
    opacity: 1;
}

.tts-retry-btn, .tts-retry-30m-btn {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 1px 4px;
    font-size: 0.55rem;
    cursor: pointer;
    text-transform: uppercase;
    font-family: inherit;
}

.tts-retry-btn:hover, .tts-retry-30m-btn:hover {
    background: var(--accent-cyan);
    color: #000;
}

.tts-history-metrics-row {
    display: flex;
    gap: 8px;
    opacity: 0.6;
    font-size: 0.55rem;
}

.m-val {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    padding-right: 8px;
}

.m-val:last-child {
    border-right: none;
}
.tts-queue-container {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.tts-queue-item {
    background: rgba(255, 140, 0, 0.05);
    border: 1px solid rgba(255, 140, 0, 0.3);
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    animation: slide-in 0.3s ease-out;
}

.tts-queue-item.processing {
    border-color: var(--accent-cyan);
    background: rgba(0, 243, 255, 0.05);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.tts-queue-item .info {
    flex: 1;
    overflow: hidden;
}

.tts-queue-item .text-preview {
    font-family: 'Inter', sans-serif;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tts-queue-item .meta {
    font-family: 'Orbitron', sans-serif;
    color: var(--accent-orange);
    font-size: 0.6rem;
    text-transform: uppercase;
}

.tts-queue-item.processing .meta {
    color: var(--accent-cyan);
}

.tts-cancel-btn {
    background: transparent;
    border: 1px solid #ff4444;
    color: #ff4444;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 2px;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

.tts-cancel-btn:hover {
    background: #ff4444;
    color: #000;
    box-shadow: 0 0 8px #ff4444;
}

@keyframes slide-in {
    from {
        transform: translateX(-10px);
        opacity: 0;
    }

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


.message-content::before {
    display: none;
}

.message.user .message-content {
    color: #fff;
    background: rgba(255, 157, 0, 0.15);
    border-color: rgba(255, 157, 0, 0.4);
    box-shadow: 0 4px 15px rgba(255, 157, 0, 0.1);
    border-bottom-right-radius: 2px;
}

.message.bot .message-content {
    border-bottom-left-radius: 2px;
}

.message.user .message-content::before {
    background: var(--accent-orange);
}

.message.bot .message-content::before {
    border-left: 3px solid var(--accent-cyan);
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    box-shadow: 0 0 8px var(--accent-cyan), 0 0 15px rgba(0, 243, 255, 0.3);
}

.thinking-block {
    margin: 0.5rem 0;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 157, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.thinking-block summary {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    color: var(--accent-orange);
    cursor: pointer;
    background: linear-gradient(90deg, rgba(255, 157, 0, 0.1), transparent);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thinking-block summary::before {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.thinking-block[open] summary::before {
    transform: rotate(90deg);
}

.thinking-block .thinking-content {
    padding: 0.8rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    border-top: 1px solid rgba(255, 157, 0, 0.1);
    white-space: pre-wrap;
    font-family: 'Share Tech Mono', monospace;
}

.message.bot .message-content::selection {
    background: var(--accent-cyan);
    color: #000;
    text-shadow: none;
}

.message[data-speaking] .message-content {
    border-left-color: #fff;
    border-right-color: #fff;
    box-shadow: inset 0 0 12px rgba(0, 243, 255, 0.3), 0 0 12px rgba(0, 243, 255, 0.4);
    animation: speaking-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes speaking-pulse {
    from {
        box-shadow: inset 0 0 8px rgba(0, 243, 255, 0.2), 0 0 4px rgba(0, 243, 255, 0.3);
    }

    to {
        box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.5), 0 0 15px rgba(0, 243, 255, 0.6);
    }
}

.tts-btn {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 2px 4px;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

.tts-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    opacity: 1;
    box-shadow: 0 0 10px var(--accent-cyan);
}

.tts-btn svg {
    filter: drop-shadow(0 0 2px var(--accent-cyan));
}

.tts-btn.tts-queued {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
    animation: tts-queued-flash 1s infinite alternate;
}

.tts-btn.tts-processing {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.tts-btn.tts-ready {
    border-color: var(--accent-cyan);
    color: #fff;
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 10px var(--accent-cyan);
    opacity: 1;
}

@keyframes tts-queued-flash {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

@keyframes tts-processing-pulse {
    from {
        box-shadow: 0 0 5px var(--accent-orange);
        transform: scale(0.95);
    }

    to {
        box-shadow: 0 0 15px var(--accent-orange);
        transform: scale(1.05);
    }
}

/* Settings Row */
.settings-row {
    flex-shrink: 0;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.4rem;
    padding: 0 0.4rem;
}

.divider {
    width: 1px;
    height: 12px;
    background: var(--accent-cyan);
    opacity: 0.3;
    margin: 0 0.2rem;
}

.settings-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-btn {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 243, 255, 0.4);
    color: var(--accent-cyan);
    padding: 0.15rem 0.4rem;
    font-size: 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 22px;
}

.settings-btn:hover {
    background: rgba(0, 243, 255, 0.15);
    box-shadow: 0 0 10px var(--accent-cyan), inset 0 0 5px var(--accent-cyan);
    transform: translateY(-1px);
}

.settings-btn.active {
    background: rgba(0, 243, 255, 0.35);
    border: 2px solid var(--accent-cyan);
    color: #fff;
    text-shadow: 0 0 10px var(--accent-cyan), 0 0 25px rgba(0, 243, 255, 0.5);
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.5), 0 0 50px rgba(0, 243, 255, 0.15), inset 0 0 20px rgba(0, 243, 255, 0.3);
    font-weight: 800;
    transform: translateY(-1px) scale(1.02);
}

#log-toggle.active {
    background: var(--accent-orange);
    color: #000 !important;
    text-shadow: none !important;
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange);
}

#custom-personality {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--accent-orange);
    border-radius: 2px;
    padding: 0.2rem 0.6rem;
    color: #fff;
    font-size: 0.75rem;
    outline: none;
    box-shadow: inset 0 0 5px var(--accent-orange);
    font-family: 'Inter', sans-serif;
}

.input-area {
    flex-shrink: 0;
    display: flex;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    background: rgba(0, 10, 20, 0.96);
    border-radius: 0;
    border: var(--panel-border);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.85), 0 0 15px rgba(0, 243, 255, 0.04);
    backdrop-filter: blur(30px);
    position: relative;
    overflow: visible;
    clip-path: polygon(0 0, calc(100% - 25px) 0, 100% 25px, 100% 100%, 0 100%);
    z-index: 100;
    animation: border-breathe 5s ease-in-out infinite;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-area.osk-docked #send-btn {
    display: none !important;
}

.input-area.osk-docked {
    flex-wrap: nowrap !important;
}

.input-area.osk-docked .input-wrapper {
    order: 2 !important;
    width: auto !important;
    min-width: 0 !important;
    margin-bottom: 0 !important;
    flex: 1 !important;
}

.input-area.osk-docked .mic-group {
    order: 1 !important;
}

.input-area.osk-docked #auto-reply-btn {
    order: 3 !important;
}

.mic-group {
    display: flex;
    align-items: stretch;
    position: relative;
    z-index: 1;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
}

.input-area.photon-pulse::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: photon-pulse 5s linear forwards;
    z-index: 10;
}

.input-area::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 5px;
    width: 15px;
    height: 15px;
    border-bottom: 2px solid var(--accent-cyan);
    border-left: 2px solid var(--accent-cyan);
    opacity: 0.5;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    border: 1px solid rgba(0, 243, 255, 0.2);
}

.mic-waveform {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
}

.mic-waveform.active {
    opacity: 0.5;
}

input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.3rem 0.6rem;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    caret-color: var(--accent-cyan);
}

.input-area::before {
    content: '';
    position: absolute;
    top: 0.75rem;
    left: calc(0.75rem + 18px + 1.2rem);
    /* roughly matching input position after mic group */
    right: 0.75rem;
    /* roughly to send button */
    bottom: 0.75rem;
    pointer-events: none;
    z-index: 2;
}

/* Simplified for input to avoid interaction issues */
input[type="text"] {
    border: 1px solid rgba(0, 229, 255, 0.2);
}

input[type="text"]:focus {
    background: rgba(0, 229, 255, 0.08);
    border-color: var(--accent-cyan);
    box-shadow: inset 0 0 15px rgba(0, 229, 255, 0.2), 0 0 12px rgba(0, 229, 255, 0.35);
    border-image: linear-gradient(90deg, var(--accent-cyan), rgba(0, 243, 255, 0.3), var(--accent-cyan)) 1;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    border-radius: 0;
    color: var(--accent-cyan);
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
    box-shadow: 0 0 5px var(--accent-cyan), inset 0 0 5px rgba(0, 255, 255, 0.2);
}

.icon-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px var(--accent-cyan);
}

/* 3-State Mic Button */
/* .mic-manual base looks (handled by base icon-btn) */

.mic-auto {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange), inset 0 0 5px rgba(255, 94, 0, 0.2);
}

.mic-auto::after {
    content: 'MCP';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mic-disabled {
    filter: grayscale(1);
    opacity: 0.2;
    cursor: default;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.mic-disabled:hover {
    background: transparent;
    box-shadow: none;
}

.icon-btn.active {
    background: rgba(0, 243, 255, 0.15);
    border-color: #fff;
    color: #fff;
    box-shadow: 0 0 25px var(--accent-cyan), inset 0 0 15px rgba(0, 243, 255, 0.3);
    transform: scale(1.1);
    animation: neon-pulse 2s infinite ease-in-out;
}

@keyframes neon-pulse {

    0%,
    100% {
        box-shadow: 0 0 15px var(--accent-cyan), inset 0 0 5px rgba(0, 243, 255, 0.2);
    }

    50% {
        box-shadow: 0 0 35px var(--accent-cyan), inset 0 0 15px rgba(0, 243, 255, 0.4);
    }
}

.icon-btn.loading {
    animation: flash-cyan 1s infinite alternate;
    background: rgba(0, 243, 255, 0.2);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
    cursor: wait;
}

@keyframes flash-cyan {
    from {
        opacity: 0.6;
        box-shadow: 0 0 5px var(--accent-cyan);
    }

    to {
        opacity: 1;
        box-shadow: 0 0 20px var(--accent-cyan);
    }
}

.stop-btn {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid #ff4444;
    color: #ff4444;
    padding: 2px 8px;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    text-transform: uppercase;
    transition: all 0.2s;
    margin-right: 0.5rem;
}

.stop-btn:hover {
    background: #ff4444;
    color: #000;
    box-shadow: 0 0 10px #ff4444;
}

.stop-btn.playing {
    animation: flash-red 1s infinite alternate;
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff0000;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

@keyframes flash-red {
    from {
        opacity: 0.6;
        box-shadow: 0 0 5px #ff0000;
    }

    to {
        opacity: 1;
        box-shadow: 0 0 20px #ff0000;
    }
}

.icon-btn.processing {
    animation: flash-orange 0.8s infinite alternate;
    background: rgba(255, 140, 0, 0.2);
    border-color: var(--accent-orange);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
}

@keyframes flash-orange {
    from {
        opacity: 0.7;
        box-shadow: 0 0 5px var(--accent-orange);
    }

    to {
        opacity: 1;
        box-shadow: 0 0 20px var(--accent-orange);
    }
}

#cachebust-btn {
    background: rgba(255, 140, 0, 0.1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

#cachebust-btn:hover {
    background: rgba(255, 140, 0, 0.2);
    box-shadow: 0 0 15px var(--accent-orange);
}

.stt-mode-btn {
    background: rgba(0, 200, 100, 0.1);
    border: 1px solid #00c864;
    color: #00c864;
    padding: 2px 8px;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    transition: all 0.2s;
}

.stt-mode-btn:hover {
    background: #00c864;
    color: #000;
    box-shadow: 0 0 10px #00c864;
}

.stt-mode-btn.offline {
    background: rgba(0, 243, 255, 0.1);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.stt-mode-btn.offline:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 10px var(--accent-cyan);
}


#send-btn {
    background: var(--accent-cyan);
    color: #000;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: none;
    border-radius: 0;
    padding: 0 1rem;
    font-size: 0.8rem;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 12px var(--accent-cyan), 0 0 25px rgba(0, 243, 255, 0.2);
}

#send-btn:hover {
    box-shadow: 0 0 25px var(--accent-cyan), 0 0 50px rgba(0, 243, 255, 0.3), inset 0 0 10px #fff;
    background: #fff;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px var(--accent-cyan);
}

#send-btn {
    position: relative;
    z-index: 1;
    min-width: 80px;
    flex-shrink: 0;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--accent-cyan);
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 4px;
    bottom: 3px;
    box-shadow: 0 0 5px var(--accent-cyan);
}

/* Auto-Reply Panel (Restructured as a row) */
.auto-reply-panel {
    width: 100%;
    background: rgba(40, 30, 10, 0.4);
    /* Dark amber theme */
    border-top: 1px solid rgba(255, 140, 0, 0.2);
    border-bottom: 1px solid rgba(255, 140, 0, 0.2);
    backdrop-filter: blur(15px);
    padding: 0.75rem 1rem;
    z-index: 5;
    display: none;
    /* Toggled via JS to flex */
    flex-direction: column;
    gap: 0.75rem;
    box-sizing: border-box;
    margin-top: -0.25rem;
    margin-bottom: 0.5rem;
}

.auto-reply-panel .settings-btn.active {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange);
    color: #000;
}

#auto-reply-btn.lit {
    background: rgba(255, 140, 0, 0.25) !important;
    border-color: var(--accent-orange) !important;
    color: var(--accent-orange) !important;
    box-shadow: 0 0 15px var(--accent-orange), inset 0 0 5px rgba(255, 140, 0, 0.3) !important;
    text-shadow: 0 0 5px var(--accent-orange);
}

.auto-reply-panel .settings-btn.active {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange);
    color: #000;
}

/* Orange Switch for Auto-Reply */
#auto-reply-panel .switch input:checked+.slider {
    background-color: rgba(255, 140, 0, 0.3);
    border-color: var(--accent-orange);
}

#auto-reply-panel .switch input:checked+.slider:before {
    background-color: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange);
    transform: translateX(18px);
}

input:checked+.slider {
    background-color: rgba(0, 243, 255, 0.2);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

/* Status Bar */
.status {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
}

.status.connected {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    box-shadow: 0 0 5px var(--accent-cyan);
    border-radius: 3px;
}

/* Message Content & Scanning Indicator */
.message-content {
    position: relative;
    min-height: 1.2rem;
}

.message-content.processing::after {
    content: "THINKING...";
    display: inline-block;
    color: var(--accent-orange);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 2px;
    animation: scan-pulse 1.5s infinite;
    opacity: 0.8;
}

@keyframes scan-pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: translateX(0);
    }

    50% {
        opacity: 1;
        transform: translateX(5px);
    }
}

/* Thinking / Reasoning Block */
.thinking-block {
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255, 200, 50, 0.2);
    border-radius: 4px;
    background: rgba(40, 30, 0, 0.3);
    box-shadow: inset 0 0 10px rgba(255, 200, 50, 0.05);
    overflow: hidden;
    font-family: var(--body-font);
    font-size: 0.9rem;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}

.thinking-block summary {
    padding: 0.3rem 0.6rem;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8em;
    color: rgba(255, 200, 50, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.thinking-block summary::before {
    content: '▶ ';
    font-size: 0.7em;
    transition: transform 0.2s;
    display: inline-block;
}

.thinking-block[open] summary::before {
    transform: rotate(90deg);
}

.thinking-content {
    padding: 0.4rem 0.7rem;
    font-size: 0.9em;
    color: rgba(255, 220, 100, 0.65);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    border-top: 1px solid rgba(255, 200, 50, 0.15);
    max-height: 200px;
    overflow-y: auto;
}

.bot .message-content p {
    margin-bottom: 0.5rem;
}

.bot .message-content *:last-child {
    margin-bottom: 0;
}

.bot .message-content h1,
.bot .message-content h2,
.bot .message-content h3 {
    color: var(--accent-cyan);
    font-family: 'Orbitron', sans-serif;
    margin: 0.5rem 0 0.3rem 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
}

.bot .message-content code {
    background: rgba(0, 5, 10, 0.85);
    color: var(--accent-orange);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 157, 0, 0.35);
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    text-shadow: 0 0 5px rgba(255, 157, 0, 0.3);
}

.bot .message-content pre {
    background:
        linear-gradient(rgba(0, 243, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.02) 1px, transparent 1px),
        rgba(0, 5, 10, 0.92);
    background-size: 20px 20px, 20px 20px, 100% 100%;
    padding: 1rem;
    border: 1px solid var(--accent-cyan-dark);
    border-left: 3px solid var(--accent-cyan);
    border-radius: 4px;
    margin: 1rem 0;
    overflow-x: auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 243, 255, 0.03);
}

.bot .message-content pre code {
    background: transparent;
    border: none;
    padding: 0;
}

.tts-highlight {
    text-decoration: underline;
    text-decoration-color: var(--accent-orange);
    text-underline-offset: 4px;
    background: rgba(255, 140, 0, 0.1);
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }    header {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        gap: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
        min-height: 32px !important;
    }
    
    .header-select {
        max-width: 80px !important;
        font-size: 0.75rem !important;
    }

    .header-quick-controls {
        gap: 0.25rem !important;
    }

    .header-action-btns {
        gap: 0.2rem !important;
    }

    .header-q-btn {
        padding: 2px 4px !important;
        letter-spacing: 0 !important;
        font-size: 0.65rem !important;
    }

    header h1 {
        display: none !important;
    }

    .header-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .header-controls>* {
        font-size: 0.7rem;
    }

    .status-metrics {
        gap: 1rem;
        padding: 0.4rem;
    }

    .metrics-grid {
        gap: 0.5rem;
    }

    .message {
        max-width: 95%;
    }

    .settings-row {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.3rem;
    }

    .settings-btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.55rem;
    }

    #user-input {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .icon-btn, button, .settings-btn {
        min-height: 44px; /* Standard accessible touch target */
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .log-tab {
        padding: 0.6rem 1rem !important; /* Even more generous hit area */
        min-height: 44px;
    }

    .header-metrics {
        display: none !important; 
    }

    @media (max-width: 480px) {
        #header-status {
            display: none !important; /* Hide text, keep only LED */
        }
        
        .header-left {
            gap: 0.2rem !important;
        }

        .header-left .bit-container {
            width: 14px;
            height: 14px;
        }
    }
}

/* Log Panel Styles — Enhanced */
.log-panel {
    background: rgba(0, 10, 20, 0.96);
    border: var(--panel-border);
    border-radius: 0;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    height: 280px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 243, 255, 0.04);
    backdrop-filter: blur(30px);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.19, 1, 0.22, 1), border-breathe 5s ease-in-out infinite;
    flex-shrink: 0;
    transition: height 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    clip-path: polygon(25px 0, 100% 0, 100% 100%, 0 100%, 0 25px);
    position: relative; /* For floating scroll button */
}

.log-panel.totally-collapsed {
    height: 32px !important;
    min-height: 32px !important;
    cursor: default;
    background: rgba(0, 10, 20, 0.98);
}

.log-panel.totally-collapsed .log-header,
.log-panel.minimized .log-header {
    height: 100%;
    min-height: 32px;
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
}

.log-panel.minimized .log-header {
    height: 32px;
}

.log-panel.totally-collapsed .log-tabs,
.log-panel.minimized .log-tabs {
    display: flex !important;
    height: 32px;
    justify-content: flex-start !important;
    gap: 0 !important;
}

.log-panel.totally-collapsed .log-tab,
.log-panel.minimized .log-tab {
    padding: 0 0.5rem;
    height: 32px;
    font-size: 0.6rem;
    letter-spacing: 0.5px;
}

.log-panel.totally-collapsed .tab-icon,
.log-panel.minimized .tab-icon {
    width: 12px;
    height: 12px;
}

.log-panel.totally-collapsed .tab-text,
.log-panel.totally-collapsed .log-collapse-toggle,
.log-panel.minimized .tab-text {
    display: none !important;
}


.log-panel.minimized .log-tab,
.log-panel.totally-collapsed .log-tab {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Ensure all tab icons are visible in minimized state */
.log-panel.minimized .log-tab {
    display: flex !important;
}

.log-panel.totally-collapsed .log-panel-close,
.log-panel.minimized .log-panel-close,
.log-panel.minimized .log-collapse-toggle {
    height: 32px;
    padding: 0 0.8rem;
    border-left: 1px solid rgba(0, 243, 255, 0.1);
}

.log-panel.minimized .log-panel-close {
    border-right: 1px solid rgba(0, 243, 255, 0.1);
    border-left: none;
}

.log-panel.totally-collapsed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    opacity: 0.5;
    animation: scanline 2s linear infinite;
}

@media (max-width: 768px) {
    .log-panel-close,
    .log-collapse-toggle {
        height: 32px !important;
        padding: 0 0.5rem !important;
    }
    
    .log-panel-close {
        font-size: 1rem !important;
    }
    
    .log-collapse-toggle svg {
        width: 12px;
        height: 12px;
    }
}

.log-panel.minimized {
    height: 64px;
}

.log-panel.hidden {
    display: none !important;
}

.restore-log-btn {
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 5px var(--accent-cyan));
    width: 24px;   /* Fixed size to reserve space */
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.restore-log-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px var(--accent-cyan));
}

.log-panel.minimized .log-content-settings {
    padding: 0.2rem 0.5rem !important;
}

.log-panel.minimized .settings-row {
    margin-bottom: 0.2rem !important;
    padding: 0 !important;
}

.log-panel.minimized .settings-btn {
    font-size: 0.6rem !important;
    padding: 0.2rem 0.4rem !important;
    letter-spacing: 1px !important;
}

/* Optimize metrics for minimized state */
.log-panel.minimized .metrics-grid {
    padding: 0.2rem 0.5rem !important;
    gap: 0.3rem !important;
}

.log-panel.minimized .metric {
    font-size: 0.55rem !important;
    padding: 0.1rem 0.3rem !important;
    gap: 0.2rem !important;
}

.log-panel.minimized .metric-icon {
    width: 10px !important;
    height: 10px !important;
}

.log-panel.minimized .metric span {
    min-width: auto !important;
    font-size: 0.55rem !important;
}

.advanced-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
}

#advanced-controls {
    height: auto !important;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.log-header {
    background: var(--header-bg);
    padding: 0 0.2rem; /* Ultra tight padding */
    height: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 243, 255, 0.4);
    font-family: var(--header-font);
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    color: var(--accent-cyan);
    width: 100%;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    flex-wrap: nowrap;
    position: relative;
    overflow: visible !important;
}

.log-header::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Edge */
}

.log-tabs {
    display: flex;
    height: 100%; /* Match log-header height */
    min-width: 0;
    flex: 1;
    overflow: hidden !important; /* Disable horizontal scroll as requested */
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.tab-push {
    margin-left: auto;
}

@media (max-width: 768px) {
    .tab-push {
        margin-left: 0;
    }

    .log-tabs {
        scrollbar-width: thin;
        /* Show thin scrollbar on mobile to indicate scrollability */
        scrollbar-color: var(--accent-cyan) transparent;
    }
}

.log-tab {
    padding: 0 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    border-right: 1px solid rgba(0, 243, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    opacity: 0.6;
    font-family: var(--header-font);
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    font-size: 0.65rem;
    white-space: nowrap;
    flex-shrink: 0;
    overflow: hidden;
}

.log-tab:hover {
    opacity: 1;
    background: rgba(0, 243, 255, 0.05);
}

.log-tab.active {
    opacity: 1;
    color: #fff;
    background: rgba(0, 243, 255, 0.15);
    text-shadow: var(--text-glow);
    border-bottom: 2px solid var(--accent-cyan);
}

.log-tab:active {
    background: rgba(0, 243, 255, 0.1);
}

.tab-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

@media (max-width: 800px) {
    .log-tab {
        padding: 0 0.8rem;
        flex-direction: column;
        justify-content: center;
        gap: 0;
    }

    .tab-text {
        display: none;
    }

    .log-count {
        font-size: 0.5rem;
        margin: 0;
        position: absolute;
        top: 2px;
        right: 2px;
        background: rgba(0, 0, 0, 0.6);
        padding: 1px 3px;
        border-radius: 4px;
        color: var(--accent-orange);
        border: 1px solid rgba(255, 94, 0, 0.3);
    }

    .tab-icon {
        width: 18px;
        height: 18px;
    }

    .log-tabs {
        justify-content: flex-start;
        padding-right: 0px;
    }

    .tab-push {
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    .log-tab {
        padding: 0 0.8rem;
        font-size: 0.6rem;
        letter-spacing: 1px;
    }
}

.log-tab:hover {
    background: rgba(0, 243, 255, 0.1);
    opacity: 0.8;
}

.log-tab.active {
    background: rgba(0, 243, 255, 0.15);
    opacity: 1;
    color: #fff;
    text-shadow: var(--text-glow);
}

.log-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 15px var(--accent-cyan), 0 0 5px #fff;
    animation: tab-underline-glow 2s infinite alternate;
}

@keyframes tab-underline-glow {
    from { opacity: 0.6; transform: scaleX(0.9); }
    to { opacity: 1; transform: scaleX(1.1); }
}

@media (max-width: 768px) {
    .overflow-trigger {
        display: none !important;
    }
}

@media (max-width: 500px) {
    .header-metrics {
        gap: 0.3rem !important;
    }

    .header-metrics .metric {
        font-size: 0.6rem !important;
        padding: 0.1rem 0.2rem !important;
    }
}

.log-panel.menu-open {
    overflow: visible !important;
    z-index: 2200; /* Pop above everything else */
}

.log-overflow-menu {
    position: absolute;
    bottom: 32px; /* Open upwards from log-header */
    right: 0;
    background: rgba(0, 8, 15, 0.98);
    border: 1px solid var(--accent-cyan);
    display: flex;
    flex-direction: column;
    z-index: 3000; /* Extremely high to clear all overlays */
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.9);
    min-width: 150px;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.log-overflow-menu .log-tab {
    width: 100%;
    padding: 12px 1rem;
    border-right: none;
    border-bottom: 1px solid rgba(0, 243, 255, 0.1);
    opacity: 0.8;
    margin-left: 0 !important; /* Prevent tab-push from creating gaps in vertical menu */
}

.log-overflow-menu .log-tab:last-child {
    border-bottom: none;
}

.log-overflow-trigger {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(0, 243, 255, 0.2);
    color: var(--accent-cyan);
    width: 32px;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: all 0.2s;
    flex-shrink: 0;
}

.log-overflow-trigger:hover, .log-overflow-trigger.active {
    opacity: 1;
    background: rgba(0, 243, 255, 0.1);
}

.log-overflow-menu .log-tab.active {
    background: rgba(0, 243, 255, 0.1);
    opacity: 1;
}

.log-overflow-menu .log-tab.active::after {
    display: none;
    /* Hide the bottom line in the dropdown */
}

.tts-history-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.tts-history-play, .tts-history-download {
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
    user-select: none;
}

.tts-history-play:hover, .tts-history-download:hover {
    opacity: 1;
    color: var(--accent-cyan);
}

.tts-history-metrics-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.55rem;
    color: rgba(255,255,255,0.4);
    font-family: monospace;
    margin-top: 2px;
    flex-wrap: wrap;
}

.tts-history-entry.timeout, .tts-history-entry.failed {
    border-left: 2px solid var(--accent-orange);
    background: rgba(255, 94, 0, 0.05);
}

.tts-extend-btn {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-size: 0.55rem;
    padding: 1px 4px;
    cursor: pointer;
    border-radius: 2px;
    font-family: var(--header-font);
}

.tts-extend-btn:hover {
    background: var(--accent-cyan);
    color: #000;
}

.log-collapse-toggle {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(0, 243, 255, 0.1);
    color: var(--accent-cyan);
    padding: 0 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    height: 44px;
    opacity: 0.6;
}

.log-collapse-toggle:hover {
    opacity: 1;
    background: rgba(0, 243, 255, 0.1);
}

.log-panel-close {
    background: transparent;
    border: none;
    border-right: 1px solid rgba(0, 243, 255, 0.1);
    color: var(--accent-orange);
    padding: 0 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    height: 44px;
    opacity: 0.6;
    font-size: 1.2rem;
    font-family: var(--header-font);
}

.log-panel-close:hover {
    opacity: 1;
    background: rgba(255, 94, 0, 0.1);
    text-shadow: 0 0 10px var(--accent-orange);
}

.log-collapse-toggle svg {
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.log-panel.minimized .log-collapse-toggle svg {
    transform: rotate(180deg);
}



.log-header button {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-size: 0.6rem;
    padding: 1px 6px;
    cursor: pointer;
    border-radius: 2px;
}

.stt-status-bar {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
    margin-bottom: 0.5rem;
}

.log-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#tts-history-panel {
    flex: 1;
    overflow-y: auto !important;
    padding: 0.5rem;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-orange) rgba(0, 0, 0, 0.2);
}

#tts-history-panel::-webkit-scrollbar {
    width: 6px;
}

#tts-history-panel::-webkit-scrollbar-thumb {
    background: var(--accent-orange);
    border-radius: 3px;
}

.log-entries {
    flex: 1;
    overflow-y: auto !important;
    padding: 0.5rem 1.2rem 0.5rem 0.6rem; /* Extra right padding for scrollbar visibility */
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: #00ff00;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan) rgba(0, 0, 0, 0.2);
    user-select: text; /* Ensure logs can be selected */
    pointer-events: auto; /* Ensure events reach it */
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.log-entries::-webkit-scrollbar {
    width: 6px;
}

.log-entries::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.log-entries::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 3px;
    box-shadow: 0 0 10px var(--accent-cyan);
}

.log-entry {
    margin-bottom: 0.4rem;
    word-break: break-all;
    border-left: 1px solid rgba(0, 255, 0, 0.2);
    padding: 0.4rem 0.75rem;
    background: rgba(0, 243, 255, 0.02);
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    transition: background 0.2s, border-left-color 0.2s;
}

.log-entry:hover {
    background: rgba(0, 243, 255, 0.08);
    border-left-color: rgba(0, 255, 0, 0.5);
}

.log-scroll-btn {
    position: absolute;
    bottom: 0.85rem;
    right: 1.5rem;
    width: 38px;
    height: 38px;
    background: rgba(0, 10, 20, 0.94);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Above all logs */
    box-shadow: var(--border-glow);
    backdrop-filter: blur(12px);
    opacity: 0.95;
    animation: scroll-btn-pulse 2.5s ease-in-out infinite;
    padding: 0;
    margin: 0;
}

.log-scroll-btn:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 10px var(--accent-cyan);
}

.log-scroll-btn svg {
    stroke: currentColor;
}

.log-entry.stt {
    color: #ffcc00;
    /* Gold/Yellow for STT */
    border-left-color: rgba(255, 204, 0, 0.4);
}

.log-entry.ollama {
    color: #00ffcc;
    /* Aqua/Cyan for Ollama */
    border-left-color: rgba(0, 255, 204, 0.4);
}

.log-entry .timestamp {
    color: #008800;
}

.log-entry .type {
    text-transform: uppercase;
    font-weight: bold;
    margin-right: 0.5rem;
}

.log-entry.request {
    color: var(--accent-orange);
    border-left-color: var(--accent-orange);
}

.log-entry.response {
    color: #00ff00;
}

.log-entry.error {
    color: #ff4444;
    border-left-color: #ff4444;
}

/* Log Deduplication Styles */
.collapsed-count {
    color: var(--accent-orange);
    font-weight: bold;
    margin-left: 0.5rem;
    cursor: pointer;
}

.log-repeat-toggle {
    background: rgba(255, 140, 0, 0.1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
    font-size: 0.7rem;
    padding: 0 4px;
    margin-left: 0.5rem;
    cursor: pointer;
    border-radius: 2px;
    display: inline-block;
}

.log-repeat-toggle:hover {
    background: var(--accent-orange);
    color: #000;
}

.log-repeat-container {
    display: none;
    margin-top: 0.3rem;
    padding-left: 1rem;
    border-left: 1px dashed rgba(255, 140, 0, 0.3);
}

.log-entry.expanded .log-repeat-container {
    display: block;
}

.log-entry.expanded .log-repeat-toggle {
    background: var(--accent-orange);
    color: #000;
}

/* Responsive UI Adjustments */
@media (max-width: 900px) {
    .status-metrics {
        gap: 0.75rem;
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .metrics-grid {
        gap: 0.5rem;
    }

    .toggle-container {
        font-size: 0.65rem;
    }

    .metric {
        font-size: 0.7rem;
    }

    .status-metrics .kill-btn {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
    }

    .settings-row {
        gap: 0.3rem;
        padding: 0 0.25rem;
    }

    .personality-label {
        font-size: 0.55rem;
    }

    .settings-btn {
        font-size: 0.55rem;
        padding: 0.15rem 0.4rem;
    }
}

@media (max-width: 600px) {
    .status-metrics {
        flex-wrap: wrap;
        justify-content: center;
    }

    .settings-row {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Virtual Keyboard Styles */
.virtual-keyboard {
    position: relative;
    margin: 5px auto 0 auto;
    width: 100%;
    max-width: 600px;
    background: var(--panel-bg);
    border: 1px solid var(--accent-cyan);
    box-shadow: var(--border-glow);
    padding: 5px;
    z-index: 2000;
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    user-select: none;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.virtual-keyboard.undocked {
    position: fixed;
    bottom: auto;
    left: auto;
    top: 100px;
    left: 100px;
    transform: none;
    width: 320px;
    border-radius: 8px;
    cursor: move;
}

.kbd-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.kbd-key {
    flex: 1;
    height: 45px;
    background: rgba(0, 243, 255, 0.05);
    border: 1px solid rgba(0, 243, 255, 0.3);
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.1s;
    box-shadow: inset 0 0 5px rgba(0, 243, 255, 0.1);
}

.kbd-key:active {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 15px var(--accent-cyan);
    transform: scale(0.95);
}

.kbd-key.wide {
    flex: 2;
}

.kbd-key.extra-wide {
    flex: 3;
}

.kbd-key.space {
    flex: 5;
}

.kbd-key.special {
    background: rgba(255, 140, 0, 0.1);
    border-color: rgba(255, 140, 0, 0.4);
    color: var(--accent-orange);
}

.kbd-key.special:active {
    background: var(--accent-orange);
    color: #000;
}

.kbd-header {
    height: 18px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: move;
    position: relative;
    border-bottom: 1px solid rgba(0, 243, 255, 0.1);
    background: rgba(0, 243, 255, 0.05);
}

.kbd-controls {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 10;
}

.kbd-redock-btn, .kbd-close-btn {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-size: 12px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.kbd-redock-btn {
    display: none;
}

.virtual-keyboard.undocked .kbd-redock-btn {
    display: flex;
}

.kbd-redock-btn:hover, .kbd-close-btn:hover {
    background: var(--accent-cyan);
    color: #000;
}

.kbd-handle {
    width: 40px;
    height: 4px;
    background: var(--accent-cyan);
    opacity: 0.3;
    border-radius: 2px;
}

@media (max-width: 480px) {
    .kbd-key {
        height: 40px;
        font-size: 0.8rem;
    }

    .input-area {
        padding: 0.15rem 0.25rem;
    }

    .input-area button,
    .input-area .settings-btn,
    .input-area #send-btn {
        min-height: 24px !important;
        font-size: 0.65rem !important;
        padding: 0 0.5rem !important;
    }

    #user-input {
        padding: 0.5rem;
    }

    #send-btn {
        padding: 0 1rem;
        font-size: 0.8rem;
        min-width: 60px;
    }

    .input-area {
        flex-wrap: wrap;
        padding: 0.2rem 0.4rem;
        gap: 0.2rem;
    }

    .mic-group {
        order: 1;
    }

    .input-wrapper {
        order: 2;
        flex: 1;
        min-width: 0;
    }

    .log-panel.hidden ~ .input-area .input-wrapper {
        order: 1;
        width: 100%;
        min-width: 100%;
        margin-bottom: 0.2rem;
    }

    .log-panel.hidden ~ .input-area .mic-group,
    .log-panel.hidden ~ .input-area #auto-reply-btn,
    .log-panel.hidden ~ .input-area #send-btn {
        flex: 1;
    }

    .log-panel.hidden ~ .input-area .mic-group { order: 2; }
    .log-panel.hidden ~ .input-area #auto-reply-btn { order: 3; }
    .log-panel.hidden ~ .input-area #send-btn { order: 4; }

    #auto-reply-btn {
        order: 3;
        font-size: 0.55rem !important;
        padding: 0.2rem 0.4rem !important;
        min-width: auto !important;
    }

    #send-btn {
        order: 4;
        flex: 0 1 auto;
        font-size: 0.65rem !important;
        padding: 0.2rem 0.5rem !important;
        min-width: 40px !important;
    }
}

/* Scroll to Bottom Button — Enhanced */
.scroll-bottom-btn {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    background: rgba(0, 10, 20, 0.92);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    box-shadow: var(--border-glow);
    transition: all 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(10px);
    opacity: 0.9;
    animation: scroll-btn-pulse 2.5s ease-in-out infinite;
}

.scroll-bottom-btn:hover {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 20px var(--accent-cyan);
    opacity: 1;
    transform: translateY(-2px);
}

.scroll-bottom-btn:active {
    transform: translateY(0);
}

/* TTS Word Highlighting (CSS Custom Highlight API) */
::highlight(tts-word) {
    background-color: rgba(0, 243, 255, 0.15);
    text-decoration: underline wavy #00f3ff;
    text-shadow: 0 0 8px rgba(0, 243, 255, 0.6);
    color: #fff;
}

/* Custom Dialog Modal */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.custom-dialog-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.custom-dialog-box {
    background: var(--panel-bg);
    border: 2px solid var(--accent-cyan);
    box-shadow: var(--border-glow);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-dialog-overlay.active .custom-dialog-box {
    transform: scale(1);
}

.custom-dialog-box p {
    color: #fff;
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.5;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.custom-dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.custom-dialog-btn {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 0.5rem 1.5rem;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: all 0.2s;
    min-width: 100px;
}

.custom-dialog-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px var(--accent-cyan);
}

.custom-dialog-btn.confirm-btn {
    border-color: #ff4444;
    color: #ff4444;
}

.custom-dialog-btn.confirm-btn:hover {
    background: rgba(255, 68, 68, 0.1);
    box-shadow: 0 0 15px #ff4444;
}

.icon-btn.active svg {
    filter: drop-shadow(0 0 5px var(--accent-cyan));
    animation: kbd-pulse 2s infinite alternate;
}

@keyframes kbd-pulse {
    from {
        opacity: 0.7;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* STT Status Bar */
.stt-status-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(0, 20, 40, 0.95);
    display: flex;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(0, 243, 255, 0.3);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 1px;
    backdrop-filter: blur(5px);
}

.stt-indicator {
    color: rgba(0, 243, 255, 0.2);
    transition: all 0.2s ease;
    text-shadow: none;
}

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

.stt-indicator.active {
    color: var(--accent-cyan);
    text-shadow: 0 0 8px var(--accent-cyan);
    animation: stt-flash 0.4s ease-in-out infinite;
}

@keyframes stt-flash {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.stt-metrics {
    margin-left: auto;
    display: flex;
    gap: 0.8rem;
    color: rgba(0, 243, 255, 0.5);
    font-size: 0.6rem;
    font-variant-numeric: tabular-nums;
}

.stt-metrics span:not(.metric-label) {
    display: inline-block;
    min-width: 2.5rem;
    text-align: right;
    color: #fff;
}

.stt-metrics .metric-label {
    opacity: 0.6;
    color: var(--accent-cyan);
}

@media (max-width: 500px) {
    .stt-metrics {
        gap: 0.4rem;
    }
    .stt-metrics .metric-label {
        font-size: 0.55rem;
    }
    .stt-metrics .metric-label[data-short]::before {
        content: attr(data-short);
    }
    .stt-metrics .metric-label[data-short] {
        font-size: 0;
    }
}

#stt-status-cpu,
#stt-status-ram {
    min-width: 2.5rem;
}

#connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    margin-right: 0.5rem;
}

#status-led {
    transition: all 0.3s ease;
}

#status-led.blink {
    animation: status-blink 1s infinite alternate;
}

@keyframes status-blink {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.4;
    }
}

/* Status LED Stack */
.led-status-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    min-width: 24px;
    text-align: right;
    letter-spacing: 0.5px;
    opacity: 0;
    transition: opacity 0.2s;
    user-select: none;
    font-weight: bold;
}

.led-status-text.active {
    opacity: 1;
    animation: status-text-flash 0.3s infinite alternate;
}

.led-status-text.activity { color: #00f3ff; text-shadow: 0 0 4px #00f3ff; }
.led-status-text.llm { color: #ffcc00; text-shadow: 0 0 4px #ffcc00; }
.led-status-text.stt { color: #33ff33; text-shadow: 0 0 4px #33ff33; }
.led-status-text.tts { color: #ff8c00; text-shadow: 0 0 4px #ff8c00; }

@keyframes status-text-flash {
    from { opacity: 0.4; filter: brightness(0.8); }
    to { opacity: 1; filter: brightness(1.2); }
}

.status-led-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 2px;
}

.status-indicator-led {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

#led-activity.active {
    background: #00f3ff;
    box-shadow: 0 0 5px #00f3ff;
    animation: led-flash 0.1s infinite alternate;
}

#led-llm.active {
    background: #ffcc00;
    box-shadow: 0 0 5px #ffcc00;
    animation: led-flash 0.3s infinite alternate;
}

#led-stt.active {
    background: #33ff33;
    box-shadow: 0 0 5px #33ff33;
    animation: led-flash 0.5s infinite alternate;
}

#led-tts.active {
    background: #ff8c00;
    box-shadow: 0 0 5px #ff8c00;
    animation: led-flash 0.4s infinite alternate;
}

@keyframes led-flash {
    from {
        opacity: 0.3;
        transform: scale(0.8);
        filter: brightness(0.8) blur(0.5px);
    }

    to {
        opacity: 1;
        transform: scale(1.2);
        filter: brightness(1.2) blur(0px);
    }
}

/* Metrics Tab Styles */
#log-content-metrics {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#log-content-metrics .metrics-grid {
    flex-shrink: 0;
}

#log-content-metrics .graph-container {
    flex-grow: 1;
    min-height: 0;
    position: relative;
    width: 100%;
    overflow: hidden;
}

#log-content-metrics canvas {
    width: 100% !important;
    height: 100% !important;
}
/* Dual Count Indicator for Tabs */
.dual-count-indicator {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 4px;
    font-size: 0.65rem;
    line-height: 1;
    min-width: 24px;
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.2);
    vertical-align: middle;
}

#tts-active-count {
    color: #fff;
    text-shadow: 0 0 8px var(--accent-cyan);
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 243, 255, 0.3);
    width: 100%;
    text-align: center;
    padding-bottom: 1px;
}

#tts-queue-count {
    color: var(--accent-cyan);
    opacity: 0.8;
    width: 100%;
    text-align: center;
    padding-top: 1px;
}

/* ETA Badge for Message Bubbles */
.tts-eta-badge {
    position: absolute;
    bottom: -18px;
    right: 5px;
    font-size: 0.65rem;
    color: var(--accent-orange);
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--accent-orange);
    pointer-events: none;
    animation: heartbeat 2s infinite;
    z-index: 10;
    white-space: nowrap;
}

.message { position: relative; } /* Ensure absolute positioning works */

/* TTS history log icon styling */
.tts-log-icon {
    font-size: 0.85rem;
    text-decoration: none;
    margin-right: 0.3rem;
    opacity: 0.8;
    transition: transform 0.2s, opacity 0.2s;
    display: inline-block;
    filter: drop-shadow(0 0 2px var(--accent-cyan));
}

.tts-log-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.eta-text {
    font-size: 0.7rem;
    font-weight: bold;
}

/* Dry audio comparison button styling */
.tts-history-play-dry {
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
    border-radius: 3px;
    cursor: pointer;
    margin-right: 0.4rem;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
}

.tts-history-play-dry:hover {
    background: var(--accent-orange);
    color: #000;
    box-shadow: 0 0 8px var(--accent-orange);
}

/* Log hover preview full-screen overlay styling */
.tts-log-preview-popover {
    position: fixed;
    z-index: 10000;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
    max-height: 800px;
    background: rgba(10, 15, 20, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid var(--accent-cyan);
    border-radius: 8px;
    padding: 0; /* Remove padding from outer container */
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--accent-cyan);
    white-space: pre-wrap;
    overflow: hidden; /* Prevent outer scroll */
    pointer-events: auto; /* Allow interaction */
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.3), inset 0 0 30px rgba(0, 243, 255, 0.1);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan) transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.tts-log-preview-popover.visible {
    opacity: 1;
    visibility: visible;
}

.tts-log-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    color: var(--accent-cyan);
    cursor: pointer;
    line-height: 1;
    z-index: 10001;
    transition: all 0.2s;
    user-select: none;
    font-family: 'Orbitron', sans-serif;
}

.tts-log-close-btn:hover {
    color: #fff;
    text-shadow: 0 0 8px var(--accent-cyan);
    transform: scale(1.1);
}

.tts-log-preview-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 40px 20px 20px 20px; /* Padding now on scrollable content */
    box-sizing: border-box;
}

.tts-log-preview-content::-webkit-scrollbar {
    width: 4px;
}

.tts-log-preview-content::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 2px;
}

.tts-log-preview-popover::-webkit-scrollbar {
    width: 4px;
}

.tts-log-preview-popover::-webkit-scrollbar-thumb {
    background: var(--accent-cyan);
    border-radius: 2px;
}

/* Voice Cloner Studio Enhancements */
.voice-custom-ref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.voice-custom-ref-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auto-transcribe-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--ui-font);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auto-transcribe-label:hover {
    color: var(--accent-cyan);
}

.auto-transcribe-label input {
    margin: 0;
    accent-color: var(--accent-cyan);
}

.voice-mini-btn {
    font-size: 0.6rem !important;
    padding: 1px 6px !important;
    min-height: 18px !important;
    letter-spacing: 1px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    font-family: var(--header-font);
}

.voice-mini-btn:hover {
    background: rgba(0, 243, 255, 0.1) !important;
    border-color: var(--accent-cyan) !important;
    color: var(--accent-cyan) !important;
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.3);
}

.preview-header-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.audio-edit-controls {
    display: flex;
    gap: 6px;
}

#custom-voice-ref-text {
    width: 100%;
    min-height: 100px;
    background: rgba(0, 5, 12, 0.8);
    border: 1px solid rgba(255, 106, 16, 0.2);
    color: #fff;
    font-family: var(--body-font);
    font-size: 0.95rem;
    padding: 10px;
    outline: none;
    resize: vertical;
    transition: all 0.3s ease;
}

#custom-voice-ref-text:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(255, 106, 16, 0.1);
}

#custom-voice-ref-text:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(0, 5, 12, 0.4);
    border-style: dotted;
}

.voice-custom-ref-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Waveform Selection Styles */
.waveform-selection-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 243, 255, 0.2);
    border-left: 1px solid var(--accent-cyan);
    border-right: 1px solid var(--accent-cyan);
    pointer-events: none;
}
