:root {
    --bg-dark: #070913;
    --card-bg: rgba(18, 22, 45, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --neon-blue: #00f0ff;
    --neon-green: #39ff14;
    --neon-pink: #ff007f;
    --neon-red: #ff3333;
    --text-primary: #f0f4f9;
    --text-secondary: #8e9bb4;
    --font-header: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --shadow-glow: 0 0 15px rgba(0, 240, 255, 0.25);
}

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

body {
    background-color: var(--bg-dark);
    font-family: var(--font-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Stunning Ambient Background Gradients */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(255, 0, 127, 0.05) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.logo {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.neon-glow {
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    background: linear-gradient(135deg, var(--neon-blue) 0%, #a200ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    font-size: 0.75rem;
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-blue);
    border: 1px solid rgba(0, 240, 255, 0.3);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
    text-shadow: var(--shadow-glow);
}

.server-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.indicator.online {
    background-color: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
}

/* Tab Bar styling */
.tab-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.4rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.tab-btn.active {
    color: var(--neon-blue);
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.05);
}

/* Tab pane state management */
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

/* Card & Glassmorphism styles */
.card {
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.card.glass {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.card h2 {
    font-family: var(--font-header);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #ffffff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

/* Buttons */
.btn {
    border: none;
    outline: none;
    font-family: var(--font-header);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--neon-blue) 0%, #0077ff 100%);
    color: #000;
    font-weight: 700;
}
.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn.success {
    background: linear-gradient(135deg, var(--neon-green) 0%, #00aa30 100%);
    color: #000;
    font-weight: 700;
}
.btn.success:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.3);
}

.btn.danger {
    background: linear-gradient(135deg, var(--neon-red) 0%, #cc0000 100%);
    color: #fff;
}
.btn.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(255, 51, 51, 0.3);
}

/* Controls */
.controls-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.status-lbl {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.status-lbl.idle { color: var(--neon-blue); }
.status-lbl.success { color: var(--neon-green); }
.status-lbl.running { color: var(--neon-pink); animation: breathe 1.5s infinite alternate; }

@keyframes breathe {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Audio Level Monitors */
.audio-monitors {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.monitor-bar {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.monitor-bar label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.bar-outer {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.bar-inner {
    height: 100%;
    background: linear-gradient(to right, var(--neon-blue), var(--neon-pink));
    border-radius: 4px;
    transition: width 0.1s ease;
}

/* Latency Metric Display */
.latency-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.metric .val {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-header);
}

.metric .unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: -0.25rem;
}

.metric .lbl {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-weight: 600;
}

.metric.highlight .val {
    color: var(--neon-blue);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

/* Consoles & Terminals */
.log-console-container {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.log-console-container.large {
    min-height: 400px;
}

.console-hdr {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.console {
    background: #020308;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-y: auto;
    height: 180px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.log-console-container.large .console {
    height: 380px;
}

.console span {
    display: block;
}

.console .log-info { color: #8e9bb4; }
.console .log-success { color: var(--neon-green); }
.console .log-warn { color: #ffab00; }
.console .log-err { color: var(--neon-red); }

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

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

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

input[type="text"], select, textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.25s;
}

input[type="text"]:focus, select:focus, textarea:focus {
    border-color: var(--neon-blue);
}

textarea {
    resize: none;
    height: 220px;
}

/* Skills list */
.skills-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skill-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.skill-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.skill-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.skill-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.skill-bar-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 180px;
}

.skill-pct {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--neon-blue);
    width: 45px;
    text-align: right;
}

/* DIHCL next item display */
.zpd-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.15);
    padding: 1.25rem;
    border-radius: 12px;
    margin-top: 1.5rem;
}

.zpd-item-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.feedback-btns {
    display: flex;
    gap: 0.75rem;
}

/* taVNS indicator */
.tavns-status-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.tavns-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.pulse-wave {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 0, 127, 0.2);
    border: 2px solid var(--neon-pink);
    position: relative;
}

.pulse-wave.active {
    animation: wavePulse 1s infinite linear;
}

@keyframes wavePulse {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 0, 127, 0.6); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 0, 127, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 0, 127, 0); }
}

.tavns-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.95rem;
}

.sync-status {
    font-weight: 700;
}
.sync-status.ok { color: var(--neon-green); }
.sync-status.err { color: var(--neon-red); }

/* Haptic Matrix */
.haptics-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.haptic-group {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.haptic-group h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.grid-16 {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 0.4rem;
}

.tactor {
    aspect-ratio: 1;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background-color 0.1s ease, box-shadow 0.1s ease;
}

.tactor.active {
    background-color: var(--neon-blue);
    box-shadow: 0 0 8px var(--neon-blue);
}

.group-label {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Grounding KG layout */
.kg-results-split {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.kg-nodes-box, .kg-edges-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.no-data {
    color: var(--text-secondary);
    text-align: center;
    display: block;
    margin: 1rem 0;
}

.kg-node-pill {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.kg-node-pill.concept { border-color: rgba(0, 240, 255, 0.3); }
.kg-node-pill.word { border-color: rgba(57, 255, 20, 0.3); }
.kg-node-pill.dialect { border-color: rgba(255, 0, 127, 0.3); }

.kg-edge-line {
    padding: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

/* HSK Database & Search Workspace Styling */
.db-status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.status-metric {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.status-metric:hover {
    background: rgba(0, 240, 255, 0.02);
    border-color: rgba(0, 240, 255, 0.2);
}

.status-metric .val {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--neon-blue);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
    font-family: var(--font-header);
}

.status-metric .lbl {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 500;
    text-align: center;
}

.search-section {
    margin-bottom: 1.5rem;
}

.telemetry-bar {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--neon-blue);
    display: inline-block;
    margin-top: 0.5rem;
}

.results-container h3 {
    font-family: var(--font-header);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.search-result-item {
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.01);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.search-result-item:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 240, 255, 0.15);
}

.result-flex {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

@media (max-width: 600px) {
    .result-flex {
        flex-direction: column;
    }
}

.result-visual {
    flex-shrink: 0;
}

.mnemonic-card-img {
    width: 180px;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mnemonic-card-img:hover {
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.25);
}

.result-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

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

.score-badge {
    font-size: 0.8rem;
    color: var(--neon-green);
    font-weight: 700;
}

.badge.word { background: rgba(57, 255, 20, 0.08); color: var(--neon-green); border: 1px solid rgba(57, 255, 20, 0.2); }
.badge.phrase { background: rgba(0, 240, 255, 0.08); color: var(--neon-blue); border: 1px solid rgba(0, 240, 255, 0.2); }
.badge.grammar { background: rgba(255, 0, 127, 0.08); color: var(--neon-pink); border: 1px solid rgba(255, 0, 127, 0.2); }
.badge.scenario { background: rgba(255, 171, 0, 0.08); color: #ffab00; border: 1px solid rgba(255, 171, 0, 0.2); }

/* Grammar correction card (slow path feedback) */
.correction-card { border-color: rgba(245, 158, 11, 0.3) !important; }
.correction-original { text-decoration: line-through; opacity: 0.6; }
.correction-corrected { color: #34d399; font-weight: 600; }
.correction-pos-sequence { font-family: 'Courier New', monospace; color: #f59e0b; font-size: 0.85rem; }

.audio-control-row {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.audio-control-row label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.audio-control-row audio {
    width: 100%;
    height: 32px;
    border-radius: 4px;
    outline: none;
}

/* Scenario Turns styles */
.scenario-turns-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.scenario-turn {
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 0.4rem;
}

.scenario-turn:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.scenario-turn .py {
    color: var(--neon-blue);
}

.scenario-turn .eng {
    color: var(--text-secondary);
}

.turn-analysis {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    padding-left: 0.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
}

/* AI Enrichment CSS */
:root {
    --neon-purple: #bd00ff;
}

.telemetry-bar {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
    font-size: 0.85rem;
}

.ai-toggle-label input {
    cursor: pointer;
    accent-color: var(--neon-purple);
}

.ai-enrichment-box {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(189, 0, 255, 0.3); /* Premium purple border */
    background: rgba(189, 0, 255, 0.03); /* Subtle purple glassmorphic background */
    box-shadow: 0 0 15px rgba(189, 0, 255, 0.05);
    transition: all 0.3s ease;
}

.ai-enrichment-box h3 {
    color: var(--neon-purple) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
}

.ai-enrichment-box h3::before {
    content: "✨";
}

.ai-enrichment-box .section-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.25rem;
}

.ai-enrichment-box .intent-text, 
.ai-enrichment-box .pedagogical-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.ai-enrichment-box table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.ai-enrichment-box th, 
.ai-enrichment-box td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-enrichment-box th {
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.ai-enrichment-box td {
    color: var(--text-secondary);
}

.ai-enrichment-box td .alt-hanzi {
    font-weight: bold;
    color: var(--neon-blue);
    font-size: 1.05rem;
}

.ai-grammar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-grammar-item {
    background: rgba(255, 255, 255, 0.01);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.ai-grammar-item .grammar-structure {
    font-weight: bold;
    color: var(--neon-purple);
    font-size: 0.95rem;
}

.ai-grammar-item .grammar-formula {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.ai-grammar-item .grammar-explanation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.hidden {
    display: none !important;
}

.ai-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner-ring {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(189, 0, 255, 0.1);
    border-top: 2px solid var(--neon-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.ai-provider-select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.ai-provider-select:focus,
.ai-provider-select:hover {
    border-color: var(--neon-purple);
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.2);
}

/* Search Input Wrapper and Microphone Button styling */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input-wrapper input[type="text"] {
    width: 100%;
    padding-right: 3rem; /* Leave room for the mic button */
}

.search-mic-btn {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-mic-btn:hover {
    color: var(--neon-blue);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: var(--shadow-glow);
}

.search-mic-btn.active {
    color: var(--neon-red);
    background: rgba(255, 51, 51, 0.15);
    box-shadow: 0 0 15px rgba(255, 51, 51, 0.4);
    animation: micPulse 1.5s infinite ease-in-out;
}

.search-mic-btn .mic-icon {
    width: 1.25rem;
    height: 1.25rem;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

/* Flash animation on successful voice transcription */
@keyframes voiceFlash {
    0% { box-shadow: 0 0 0 rgba(0, 240, 255, 0); border-color: rgba(255, 255, 255, 0.08); }
    50% { box-shadow: 0 0 15px rgba(0, 240, 255, 0.4); border-color: var(--neon-blue); }
    100% { box-shadow: 0 0 0 rgba(0, 240, 255, 0); border-color: rgba(255, 255, 255, 0.08); }
}

.voice-active {
    animation: voiceFlash 1s ease-out;
}

/* Premium Audio Wave Listening Indicator */
.listening-wave-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.25rem 0.25rem 0.25rem;
    margin-top: -0.5rem;
    margin-bottom: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.wave-bar {
    width: 3px;
    height: 12px;
    background: var(--neon-blue);
    border-radius: 2px;
    animation: bounce 1.2s ease-in-out infinite;
    box-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
}

.wave-bar.bar-1 { animation-delay: 0.1s; height: 14px; }
.wave-bar.bar-2 { animation-delay: 0.4s; height: 18px; }
.wave-bar.bar-3 { animation-delay: 0.2s; height: 10px; }
.wave-bar.bar-4 { animation-delay: 0.6s; height: 16px; }
.wave-bar.bar-5 { animation-delay: 0.3s; height: 12px; }

.wave-text {
    font-size: 0.8rem;
    color: var(--neon-blue);
    margin-left: 0.5rem;
    font-weight: 500;
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
    letter-spacing: 0.5px;
}

@keyframes bounce {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(2.2); }
}

/* Video Scaffolding Styles */
.video-container-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#video-intake {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* mirror output */
}

.video-focus-box {
    position: absolute;
    top: 35%;
    left: 30%;
    width: 40%;
    height: 30%;
    border: 2px dashed rgba(0, 240, 255, 0.6);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* Dim everything else */
    pointer-events: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-focus-box.stable {
    border: 2px solid var(--neon-green);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 20px var(--neon-green);
}

.video-focus-box.scanning {
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 15px var(--neon-blue);
}

.focus-corners {
    width: 100%;
    height: 100%;
    position: relative;
}

.focus-corners::before, .focus-corners::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border-color: var(--neon-blue);
    border-style: solid;
    pointer-events: none;
    transition: border-color 0.2s ease;
}

.video-focus-box.stable .focus-corners::before, 
.video-focus-box.stable .focus-corners::after {
    border-color: var(--neon-green);
}

.focus-corners::before {
    top: -2px;
    left: -2px;
    border-width: 3px 0 0 3px;
}

.focus-corners::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
}

.ar-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.ar-billboard-card {
    position: absolute;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    pointer-events: auto;
    font-family: var(--font-header);
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: arScaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    max-width: 250px;
}

.ar-billboard-card.stable-card {
    border-color: var(--neon-green);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
}

.ar-billboard-card.cloud-card {
    border-color: var(--neon-purple);
    box-shadow: 0 0 20px rgba(189, 0, 255, 0.3);
}

@keyframes arScaleIn {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.ar-billboard-card h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.15rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ar-billboard-card .ar-pinyin {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.ar-billboard-card .ar-meaning {
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.ar-billboard-card .ar-bkt-info {
    font-size: 0.75rem;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--neon-blue);
    display: inline-block;
}

.ar-billboard-card.stable-card .ar-bkt-info {
    background: rgba(57, 255, 20, 0.08);
    border-color: rgba(57, 255, 20, 0.15);
    color: var(--neon-green);
}

.video-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

@media (max-width: 600px) {
    .video-controls-grid {
        grid-template-columns: 1fr;
    }
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-item label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.video-metrics .metric.highlight {
    background: rgba(189, 0, 255, 0.05);
    border: 1px solid rgba(189, 0, 255, 0.2);
}

.video-metrics .metric.highlight.edge-active {
    background: rgba(57, 255, 20, 0.05);
    border: 1px solid rgba(57, 255, 20, 0.2);
}

.video-metrics .metric.highlight.edge-active .val {
    color: var(--neon-green);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.2);
}

.video-metrics .metric.highlight.cloud-active {
    background: rgba(189, 0, 255, 0.05);
    border: 1px solid rgba(189, 0, 255, 0.2);
}

.video-metrics .metric.highlight.cloud-active .val {
    color: var(--neon-purple);
    text-shadow: 0 0 8px rgba(189, 0, 255, 0.2);
}

.latency-breakdown {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.latency-breakdown h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-header);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.4rem;
}

.budget-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    color: var(--text-secondary);
}

.budget-row strong {
    color: var(--text-primary);
}

.budget-row.total {
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    font-weight: bold;
    color: var(--text-primary);
}

.budget-row.total strong {
    color: var(--neon-blue);
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

/* Connect line simulation in AR */
.ar-connect-line {
    position: absolute;
    width: 2px;
    background: linear-gradient(to bottom, var(--neon-blue), transparent);
    transform-origin: top center;
    z-index: 50;
    pointer-events: none;
}

/* ==================================================== */
/* Unified Main Platform styles & bookmarklet overlays */
/* ==================================================== */
.tab-bar.hidden-nav {
    display: none;
}

.image-preview-container {
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    animation: fadeIn 0.3s ease-out;
}

.preview-hdr {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
}

.preview-body {
    display: flex;
    gap: 15px;
    align-items: center;
}

.image-frame {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#platform-image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ocr-status-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--neon-blue);
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.2);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 240, 255, 0.1);
    border-top-color: var(--neon-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Pause indicator for camera feed */
.video-container-wrapper.paused::after {
    content: "FEED PAUSED";
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 0, 127, 0.85);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(255, 0, 127, 0.5);
    letter-spacing: 1px;
    z-index: 99;
}

/* Resume feed button inside card */
.btn-resume {
    background: var(--neon-green);
    border: 1px solid var(--neon-green);
    color: #070913;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}

.btn-resume:hover {
    background: #fff;
    box-shadow: 0 0 15px rgba(255,255,255,0.8);
    transform: scale(1.03);
}

.btn-resume:active {
    transform: scale(0.98);
}

