:root {
    --bg-dark: #090d16;
    --panel-bg: rgba(15, 23, 42, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --accent-primary: #6366f1;
    --accent-primary-glow: rgba(99, 102, 241, 0.35);
    --accent-primary-hover: #4f46e5;
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    --accent-rose: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.12) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 1200px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 968px) {
    .container {
        grid-template-columns: 1fr;
    }
}

.header-full {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 20px;
}

.header-full h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 50%, #34d399 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.header-full p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Glassmorphic Panel Card */
.card {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 12px;
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-main);
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Button Styles */
button {
    background: var(--accent-primary);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-primary-glow);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

/* Auth Section styling */
.auth-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 16px;
}

.auth-status-badge {
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.auth-status-badge.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Audio Player Box */
.player-container {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.6);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background-color: var(--accent-emerald);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: pulse 1.8s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 1; }
}

/* Sous-titres synchronisés (phrase en cours de la séance) */
.subtitle-box {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
}

.subtitle-text {
    text-align: center;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--text-main);
    opacity: 0.92;
    transition: opacity 0.35s ease;
}

.subtitle-text.fading {
    opacity: 0;
}

.subtitle-text:empty::before {
    content: "…";
    color: var(--text-muted);
}

.player-controls {
    display: flex;
    gap: 12px;
}

.player-controls button {
    padding: 10px 18px;
}

.btn-play-pause {
    background: var(--accent-emerald);
    min-width: 110px;
}

.btn-play-pause:hover {
    background: #059669;
    box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.btn-stop {
    background: var(--accent-rose);
}

.btn-stop:hover {
    background: #e11d48;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

/* Seeker progress bar style */
.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 45px;
}

.progress-track {
    position: relative;
    flex-grow: 1;
    height: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-buffer {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(16, 185, 129, 0.25);
    transition: width 0.25s ease;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-emerald) 100%);
    border-radius: 6px;
    transition: width 0.1s linear;
}

/* Audio Mix Sliders */
.mix-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    border-top: 1px solid var(--panel-border);
    padding-top: 18px;
}

@media (max-width: 500px) {
    .mix-sliders {
        grid-template-columns: 1fr;
    }
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-main);
    cursor: pointer;
    border: 2px solid var(--accent-primary);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Terminal Console styled Logs */
.logs-console {
    background: #040711;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.825rem;
    color: #e2e8f0;
    min-height: 250px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8);
}

.log-meta {
    color: #34d399;
}

.log-error {
    color: #f43f5e;
}

.log-warning {
    color: #fbbf24;
}

.log-info {
    color: #60a5fa;
}

/* History list styling */
.history-section {
    border-top: 1px solid var(--panel-border);
    padding-top: 20px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 8px;
}

.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(99, 102, 241, 0.3);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-title {
    font-weight: 600;
    font-size: 0.925rem;
}

.history-meta {
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* General Layout adjustments */
.status-msg {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 7, 17, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.3s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Modal Card */
.modal-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.98) 0%, rgba(9, 13, 22, 0.99) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 40px rgba(99, 102, 241, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    animation: scaleUp 0.3s forwards cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    to { transform: scale(1); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.35rem;
    color: #ffffff;
    font-weight: 700;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    color: var(--accent-rose);
    background: transparent;
    box-shadow: none;
    transform: scale(1.1);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.65;
    color: #cbd5e1;
    max-height: 60vh;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 23, 42, 0.4);
}

/* Markdown styling inside modal */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: #ffffff;
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

.markdown-body h2 {
    font-size: 1.2rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.markdown-body h3 {
    font-size: 1.05rem;
}

.markdown-body p {
    margin-bottom: 14px;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 20px;
}

.markdown-body li {
    margin-bottom: 6px;
}

.markdown-body strong {
    color: var(--accent-emerald);
}

.markdown-body code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #f43f5e;
}

/* ---------------------------------------------------------------------------
   Multi-page navigation (home menu + shared top nav)
   --------------------------------------------------------------------------- */
.top-nav {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 12px 18px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.top-nav .nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: #fff;
    background: var(--accent-primary);
}

/* Home menu cards */
.menu-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 968px) {
    .menu-grid { grid-template-columns: 1fr; }
}

.menu-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 28px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

.menu-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-primary);
    box-shadow: 0 12px 30px -12px var(--accent-primary-glow);
}

.menu-card .menu-icon { font-size: 1.8rem; }
.menu-card h3 { font-size: 1.15rem; font-weight: 600; color: #fff; }
.menu-card p { color: var(--text-muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
   Lecteur — besoins grid + active-need badge + session image + transcript
   --------------------------------------------------------------------------- */
.need-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 540px) { .need-grid { grid-template-columns: 1fr; } }

.need-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.need-tile:hover { border-color: var(--accent-primary); transform: translateY(-2px); }
.need-tile.active {
    border-color: var(--accent-emerald);
    background: var(--accent-emerald-glow);
    box-shadow: 0 0 0 1px var(--accent-emerald) inset;
}
.need-tile .need-emoji { font-size: 1.4rem; line-height: 1; }
.need-tile .need-label { font-size: 0.95rem; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.need-tile .need-sub { font-size: 0.78rem; color: var(--text-muted); line-height: 1.35; }
.need-tile .need-meta { font-size: 0.72rem; color: var(--accent-primary); margin-top: 2px; }

.need-active-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--accent-emerald-glow);
    border: 1px solid var(--accent-emerald);
    font-size: 0.85rem;
    color: var(--text-main);
}
.need-active-badge .need-clear {
    width: auto; min-width: 0; padding: 2px 9px; font-size: 0.85rem;
    background: rgba(0,0,0,0.25);
}

.session-image {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

/* Transcript */
.transcript-section { display: flex; flex-direction: column; gap: 12px; }
.transcript-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.transcript-toolbar h3 { margin-right: auto; }
.transcript-stats { font-size: 0.78rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.transcript-actions { display: flex; align-items: center; gap: 8px; }
.transcript-actions button { width: auto; min-width: 0; padding: 5px 12px; font-size: 0.8rem; }

.transcript {
    max-height: 360px;
    overflow-y: auto;
    padding: 16px 18px;
    background: rgba(4, 7, 17, 0.55);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--text-main);
}
.transcript .transcript-empty { font-size: 0.85rem; }
.transcript .t-sentence {
    transition: background 0.3s ease, color 0.3s ease;
    border-radius: 4px;
    padding: 1px 2px;
}
.transcript .t-sentence.active {
    background: var(--accent-emerald-glow);
    color: #fff;
    box-shadow: 0 0 0 1px var(--accent-emerald-glow);
}

/* Transcript groupé par bloc d'expert + pauses */
.transcript .t-block { margin-bottom: 16px; }
.transcript .t-block:last-child { margin-bottom: 0; }
.transcript .t-block-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--panel-border);
}
.transcript .t-block:first-child .t-block-head { border-top: none; padding-top: 0; }
.transcript .t-block-expert {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.transcript .t-block-dur {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}
.transcript .t-block-theme {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.45;
    margin-bottom: 8px;
}
/* Pause = retour à la ligne explicite */
.transcript .t-pause {
    display: block;
    margin: 5px 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.85;
}

.logs-details { border-top: 1px solid var(--panel-border); padding-top: 12px; }
.logs-details summary { cursor: pointer; color: var(--text-muted); font-size: 0.85rem; user-select: none; }
.logs-details summary:hover { color: var(--text-main); }
.logs-details .logs-console { margin-top: 12px; }