/* Modern Reset & Base Variables */
:root {
    /* Premium Dark Theme Palette (Screenshot matched) */
    --bg-primary: #0b1120;
    --bg-secondary: #14532d;
    --bg-accent: #020617;

    --brand-primary: #22c55e;
    --brand-secondary: #16a34a;
    --brand-gradient: linear-gradient(135deg, #4ade80 0%, #16a34a 100%);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --glass-bg: rgba(11, 17, 32, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);

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

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar and Transitions remain standard CSS */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

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

::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}



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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #0b1120 radial-gradient(circle at center, #14532d 0%, #0b1120 70%);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Main Layout */
.app-container {
    display: flex;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: rgba(2, 6, 23, 0.4);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    margin-bottom: 0.5rem;

}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 10px rgba(34, 197, 94, 0.5));
}

.logo img {
    height: 2.5rem;
    width: auto;
    object-fit: contain;
}

.brand h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    margin-bottom: auto;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background-color: #ef4444;
    /* Default red/disconnected */
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
}

.pulse-dot.connected {
    background-color: var(--brand-primary);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 2rem;
}

.info-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.info-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-card li {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chat Area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

.chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 1.2rem;
    font-weight: 500;
}

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

.lang-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lang-select:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lang-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
    flex: 1;
    /* narrower column: side gutters keep bubbles clear of the navigator rail */
    padding: 2rem clamp(1.5rem, 7%, 6rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Message Bubbles */
.message {
    max-width: 80%;
    min-width: 0;
    animation: slideUp 0.4s var(--transition-smooth);
    opacity: 0;
    animation-fill-mode: forwards;
    position: relative;
}

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

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

.message-content {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    min-width: 0;
    max-width: 100%;
}

.bot-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.4rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message:hover .bot-actions,
.message:hover .user-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Markdown styling inside bubbles */
.message-content p {
    margin-bottom: 0.75rem;
}

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

.message-content strong {
    color: #fff;
    font-weight: 600;
}

.message-content ul,
.message-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

/* User Message */
.message.user {
    align-self: flex-end;
}

.message.user .message-content {
    background: var(--brand-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
}

/* Bot Message */
.message.bot {
    align-self: flex-start;
}

.message.bot .message-content {
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-radius: var(--radius-md);
    padding: 1rem 2.5rem 1rem 1.25rem;
    color: #ECECF1;
    font-size: 15.5px;
    line-height: 1.75;
}

/* Message Navigator Rail */
.msg-nav {
    position: absolute;
    /* sits in the right gutter, clear of the chat scrollbar */
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    max-height: 60%;
    overflow-y: auto;
    padding: 0.25rem 0;
    z-index: 20;
    scrollbar-width: none;
    /* the rail strip must not swallow clicks/selection in the chat area */
    pointer-events: none;
}

.msg-nav.visible {
    display: flex;
}

.msg-nav::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.nav-tick {
    position: relative;
    background: transparent;
    border: none;
    padding: 0.3rem 0.35rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    outline: none;
    flex: 0 0 auto;
    pointer-events: auto;
}

.tick-line {
    display: block;
    width: 20px;
    height: 3px;
    border-radius: 3px;
    background: #64748b;
    transition: var(--transition-fast);
}

/* brighten the whole rail while any tick is hovered */
.msg-nav:has(.nav-tick:hover) .tick-line {
    background: #94a3b8;
}

.nav-tick:hover .tick-line,
.nav-tick:focus-visible .tick-line {
    width: 30px;
    background: var(--text-primary);
}

.nav-tick.active .tick-line {
    width: 30px;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.7);
}

.msg-nav-tip {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 30;
    background: rgba(2, 6, 23, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.45;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    width: max-content;
    max-width: 280px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(8px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.msg-nav-tip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Flash the target message after jumping to it */
.message.flash .message-content {
    animation: flashHighlight 1.3s ease;
}

@keyframes flashHighlight {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }

    15% {
        box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.55);
    }

    65% {
        box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3);
    }
}

/* Input Area */
.chat-input-container {
    /* keep the composer aligned with the narrowed message column */
    padding: 1.5rem clamp(1.5rem, 7%, 6rem);
    background: linear-gradient(to top, rgba(2, 6, 23, 0.8), transparent);
}

#chat-form {
    display: flex;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    transition: var(--transition-smooth);
    align-items: flex-end;
}

#chat-form:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.8rem 1.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    resize: none;
    overflow-y: hidden;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    background: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 0.15rem;
}

#send-btn:hover {
    background: var(--brand-secondary);
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Typing Indicator */
.typing-indicator {
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 2rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

.typing-indicator.hidden {
    display: none;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Responsive */
.mobile-only {
    display: none !important;
}

.sidebar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
}

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

@media (min-width: 901px) {
    .sidebar-overlay {
        display: none !important;
    }
}

@media (max-width: 700px) {

    /* Not enough horizontal room for the rail + tooltips */
    .msg-nav,
    .msg-nav-tip {
        display: none !important;
    }

    .chat-messages {
        padding: 2rem 1.25rem;
    }
}

@media (max-width: 900px) {
    .mobile-only {
        display: flex !important;
    }

    .sidebar {
        position: absolute;
        z-index: 100;
        height: 100%;
        background: rgba(11, 17, 32, 0.95);
        backdrop-filter: blur(20px);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        transform: translateX(-100%);
        transition: transform var(--transition-smooth);
        display: flex;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .app-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
    max-width: 100%;
}

.image-card {
    flex: 1 1 250px;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    cursor: pointer;
    position: relative;
    background: #0d1117 center/cover no-repeat;
}

.image-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

.image-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    display: block;
}

.image-card:hover .image-wrapper img {
    transform: scale(1.08);
}

.image-label {
    padding: 0.5rem 0.8rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(236, 236, 241, 0.9);
    background: rgba(13, 17, 23, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Suggestions Container */
.suggestions-container {
    margin: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.5s ease-out;
}

.suggestions-container .brand-hero {
    margin-bottom: 2.5rem;
    text-align: center;
}

.suggestions-container .brand-hero h2 {
    font-size: 2.5rem;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.suggestions-container .brand-hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 800px;
    width: 100%;
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 1.2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
}

.suggestion-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.suggestion-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.suggestion-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media (max-width: 700px) {
    .suggestions-grid {
        grid-template-columns: 1fr;
    }
}

/* Answer State Badges */
.state-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.8rem;
}

.state-answered {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.state-partial {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.state-insufficient {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.state-unsupported_crop {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.state-low_confidence {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.state-escalated {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Speech Features */
.mic-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn:hover {
    color: var(--primary);
    background: var(--surface-hover);
}

.mic-btn.recording {
    color: #ef4444;
    animation: pulse-record 1.5s infinite;
}

@keyframes pulse-record {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.highlight-word {
    color: var(--primary) !important;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 4px;
    padding: 0 2px;
    transition: background 0.1s ease, color 0.1s ease;
}

.chat-input-container #chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

/* Chat Message Links */
.message-content a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.message-content a:hover {
    color: #4ade80;
    /* lighter green for hover */
    text-decoration: underline;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* ══════════════════════════════════════════════════════════════════════════
   Icon colour.

   Every lucide icon inherited currentColor, which is the white body text, so a
   bug, a droplet and a thermometer all rendered identically white. Colour is
   the fastest signal a farmer gets about what a thing IS, and it was carrying
   no information at all.

   Colours are semantic rather than decorative: water is blue, heat is warm,
   pests are the amber of a caution, health is the brand green.
   ══════════════════════════════════════════════════════════════════════════ */
.inline-icon,
[data-lucide] {
    width: 1.05em;
    height: 1.05em;
    vertical-align: -0.15em;
    stroke-width: 2;
    flex-shrink: 0;
}

/* pests and anything that warns */
[data-lucide="bug"],
[data-lucide="alert-triangle"],
[data-lucide="shield-alert"] {
    color: #f59e0b;
}

/* water and irrigation */
[data-lucide="droplet"],
[data-lucide="droplets"],
[data-lucide="cloud-rain"],
[data-lucide="waves"] {
    color: #38bdf8;
}

/* heat, climate, weather */
[data-lucide="thermometer"],
[data-lucide="sun"],
[data-lucide="flame"] {
    color: #fb7185;
}

/* diagnosis, health, growth — the brand green */
[data-lucide="stethoscope"],
[data-lucide="leaf"],
[data-lucide="sprout"],
[data-lucide="activity"] {
    color: #4ade80;
}

/* soil and earth */
[data-lucide="mountain"],
[data-lucide="layers"] {
    color: #d6a35c;
}

/* references and documents — muted, they support the answer rather than
   competing with it */
[data-lucide="book-open"],
[data-lucide="file-text"],
[data-lucide="link"] {
    color: #94a3b8;
}

/* calendar and timing */
[data-lucide="calendar"],
[data-lucide="clock"] {
    color: #c084fc;
}

/* A link's icon follows the link, not the palette above. */
a [data-lucide],
a .inline-icon {
    color: inherit;
}

/* ══════════════════════════════════════════════════════════════════════════
   Voice recording.

   While recording, the input row is REPLACED rather than decorated. Two
   reasons: there is nothing useful to type mid-utterance, and a farmer needs
   one obvious thing to press to stop. A small mic icon pulsing next to a live
   text box leaves both unclear.

   The waveform is a scrolling history drawn from the real analyser, so the
   start of the sentence stays visible as small dots and a flat line genuinely
   means the microphone is not picking anything up.
   ══════════════════════════════════════════════════════════════════════════ */
.voice-bar {
    display: none;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.4rem 0.45rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.10);
    animation: voice-in 0.18s ease-out;
}

.voice-bar.active {
    display: flex;
}

@keyframes voice-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Circular controls, sized to the bar so nothing looks bolted on. The icons
   are centred with grid rather than line-height, which is what stops an SVG
   sitting a pixel high inside its circle. */
.voice-bar button {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.voice-bar button svg {
    display: block;
}

.voice-bar button:hover {
    transform: scale(1.06);
    filter: brightness(1.1);
}

.voice-bar button:active {
    transform: scale(0.96);
}

.voice-bar button:focus-visible {
    outline: 2px solid #4ade80;
    outline-offset: 2px;
}

/* Cancel: recessed, so it never competes with stop. */
.voice-bar .voice-cancel {
    background: rgba(255, 255, 255, 0.10);
    color: #e2e8f0;
}

.voice-bar .voice-cancel:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Stop: the white circle from the reference. It is the primary action while
   recording, so it is the brightest thing in the bar. */
.voice-bar .voice-stop {
    background: #ffffff;
    color: #0f172a;
}

.voice-bar .voice-stop:hover {
    background: #f1f5f9;
}

.voice-wave {
    flex: 1 1 auto;
    height: 2.2rem;
    min-width: 0;
}

.voice-timer {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: #cbd5e1;
    min-width: 2.6rem;
    text-align: right;
    letter-spacing: 0.02em;
}

/* ── The mic button in the composer ──
   A filled circle rather than a bare glyph: it was previously an unstyled icon
   that read as part of the text field instead of as a control. */
.mic-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.15s ease;
}

.mic-btn svg {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
}

.mic-btn:hover {
    background: #ffffff;
    transform: scale(1.06);
}

.mic-btn:active {
    transform: scale(0.95);
}

.mic-btn:focus-visible {
    outline: 2px solid #4ade80;
    outline-offset: 2px;
}

.mic-btn.recording {
    background: #ef4444 !important;
    color: #ffffff !important;
    animation: mic-pulse 1.3s ease-in-out infinite;
}

@keyframes mic-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* ── Transcribing ──
   The input is busy, and saying so beats an empty box that looks broken. */
.voice-transcribing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #4ade80;
    padding: 0.5rem 0.25rem;
}

.voice-transcribing .dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin-right: 3px;
    border-radius: 50%;
    background: currentColor;
    animation: voice-dot 1s ease-in-out infinite;
}

.voice-transcribing .dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.voice-transcribing .dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes voice-dot {

    0%,
    60%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* While an answer is generating the composer is locked. Generation is 30-90 s
   of CPU; a second question queued behind the first makes both slower and the
   farmer cannot tell which reply belongs to which question. */
#chat-form.is-generating textarea {
    opacity: 0.55;
    cursor: not-allowed;
}

#chat-form.is-generating .mic-btn {
    display: none !important;
}

.voice-error {
    font-size: 0.82rem;
    color: #fca5a5;
    padding: 0.35rem 0.25rem 0;
}

@media (prefers-reduced-motion: reduce) {
    .voice-bar {
        animation: none;
    }

    .mic-btn.recording {
        animation: none;
    }

    .voice-transcribing .dots span {
        animation: none;
        opacity: 0.7;
    }
}

/* An answer currently being read aloud. Deliberately subtle: the point is to
   show which message the audio belongs to when several are on screen, not to
   decorate. */
.message-content.speaking {
    box-shadow: inset 3px 0 0 #22c55e;
    transition: box-shadow 0.2s ease;
}

.action-btn.speak-btn.active,
.message-content.speaking~.message-actions .speak-btn {
    color: #22c55e;
}

/* Thumbs up / down on bot answers - feedback the bot learns from. */
.action-btn.feedback-btn:disabled {
    cursor: default;
    opacity: 0.45;
}

.action-btn.feedback-btn.chosen,
.action-btn.feedback-btn.chosen:disabled {
    opacity: 1;
    color: #22c55e;
}