/* TiberHealth Brand Colors */
:root {
    /* Core brand colors */
    --tiber-primary: #00adbc;
    --tiber-primary-dark: #008a96;
    --tiber-primary-light: #33c4d0;
    --tiber-charcoal: #32373c;
    --tiber-blue-gray: #4b6171;
    --tiber-light-gray: #f8f9fa;
    --tiber-white: #ffffff;
    --tiber-black: #000000;

    /* Gradient colors from Tiber Health */
    --tiber-gradient-start: #00adbc;
    --tiber-gradient-end: #0693e3;
    --tiber-gradient-purple: #9b51e0;

    /* Status colors */
    --status-partial: #f0ad4e;
    --status-sufficient: #6c757d;
    --status-solid: #28a745;

    /* Theme-specific variables (Light Mode - Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 50%, #f0f4f8 100%);
    --text-primary: #32373c;
    --text-secondary: #4b6171;
    --text-muted: #6c757d;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --input-border: #dee2e6;
    --input-text: #32373c;
    --accordion-bg: transparent;
    --accordion-active-bg: rgba(0, 173, 188, 0.05);
    /* Logo is white/light - invert to make it dark for light backgrounds */
    --logo-filter: brightness(0) saturate(100%) invert(19%) sepia(10%) saturate(746%) hue-rotate(169deg) brightness(95%) contrast(89%);

    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-200: #e2e8f0;
    --slate-50: #f8fafc;
    --teal-600: #0d9488;
    --teal-700: #0f766e;
    --teal-50: #f0fdfa;
    --white: #ffffff;

    /* PHSU brand colors */
    --phsu-teal: #00999A;
    --phsu-dark-teal: #024748;
    --phsu-orange: #F7951D;

    /* Typography */
    --font-family-base: 'Helvetica Neue', Arial, sans-serif;
    --font-family-heading: Georgia, 'Times New Roman', serif;
}

/* Dark Mode */
/* "Dark mode" is a DIMMED LIGHT theme (data-theme="dim"), NOT a true dark theme: a soft
   whitesmoke background instead of harsh pure white, with the normal dark text and teal
   accents. The teal brand/graphics/icons are designed for light surfaces, so a real dark theme
   fights them. Only the page background is softened; everything else matches light mode, so the
   light-default component styles render correctly. The legacy [data-theme="dark"] component rules
   below are dormant (nothing sets data-theme="dark" anymore) — kept in case true dark is revived
   once the brand assets are redone. */
[data-theme="dim"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #eeeef0;
    --bg-tertiary: #e6e7ea;
    --bg-gradient: linear-gradient(135deg, #f2f3f5 0%, #eeeef0 50%, #f4f5f7 100%);
    --text-primary: #32373c;
    --text-secondary: #4b6171;
    --text-muted: #6c757d;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    --input-bg: #ffffff;
    --input-border: #dee2e6;
    --input-text: #32373c;
    --accordion-bg: transparent;
    --accordion-active-bg: rgba(0, 173, 188, 0.05);
    /* Logos render on a light background — same dark tint as light mode. */
    --logo-filter: brightness(0) saturate(100%) invert(19%) sepia(10%) saturate(746%) hue-rotate(169deg) brightness(95%) contrast(89%);
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 0;
    font-family: var(--font-family-base);
    color: var(--tiber-charcoal);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
}

/* Hide Freshworks help widget on mobile */
@media (max-width: 768px) {
    #freshworks-container,
    #freshworks-frame-wrapper,
    [id^="freshworks"] {
        display: none !important;
    }
}

/* Focus states */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--tiber-primary);
}

/* Navigation */
.navbar-mdtutor {
    background: var(--tiber-white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-mdtutor .navbar-brand {
    font-weight: 700;
    color: var(--tiber-charcoal);
    font-size: 1.5rem;
}

.navbar-mdtutor .navbar-brand span {
    color: var(--tiber-primary);
}

.navbar-mdtutor .nav-link {
    color: var(--tiber-charcoal);
    font-weight: 500;
    transition: color 0.2s ease;
}

.navbar-mdtutor .nav-link:hover {
    color: var(--tiber-primary);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--tiber-charcoal) 0%, var(--tiber-blue-gray) 100%);
    color: var(--tiber-white);
    padding: 100px 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(0, 173, 188, 0.1) 100%);
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.hero-title span {
    color: var(--tiber-primary);
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 600px;
}

/* Buttons */
.btn-tiber-primary {
    background-color: var(--tiber-primary);
    border-color: var(--tiber-primary);
    color: var(--tiber-white);
    font-weight: 600;
    padding: 12px 32px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-tiber-primary:hover {
    background-color: var(--tiber-primary-dark);
    border-color: var(--tiber-primary-dark);
    color: var(--tiber-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 173, 188, 0.4);
}

.btn-tiber-outline {
    background-color: transparent;
    border: 2px solid var(--tiber-white);
    color: var(--tiber-white);
    font-weight: 600;
    padding: 12px 32px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-tiber-outline:hover {
    background-color: var(--tiber-white);
    color: var(--tiber-charcoal);
}

/* Features Section */
.features-section {
    padding: 80px 0;
    background-color: var(--tiber-white);
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--tiber-charcoal);
    margin-bottom: 1rem;
}

.section-subtitle {
    color: var(--tiber-blue-gray);
    font-size: 1.1rem;
    margin-bottom: 3rem;
}

.feature-card {
    background: var(--tiber-white);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    height: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--tiber-primary) 0%, var(--tiber-primary-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.feature-icon svg {
    width: 30px;
    height: 30px;
    color: var(--tiber-white);
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--tiber-charcoal);
    margin-bottom: 0.75rem;
}

.feature-description {
    color: var(--tiber-blue-gray);
    line-height: 1.6;
}

/* Stats Section */
.stats-section {
    padding: 60px 0;
    background: var(--tiber-light-gray);
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--tiber-primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--tiber-blue-gray);
    font-weight: 500;
}

/* CTA Section */
.cta-section {
    padding: 80px 0;
    background: linear-gradient(135deg, var(--tiber-primary) 0%, var(--tiber-primary-dark) 100%);
    color: var(--tiber-white);
}

.cta-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.cta-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

/* Topic Input Section */
.topic-section {
    padding: 60px 0;
    background: var(--tiber-white);
}

.topic-input-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.topic-input {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.topic-input:focus {
    border-color: var(--tiber-primary);
    box-shadow: 0 0 0 4px rgba(0, 173, 188, 0.1);
}

/* Recent Conversations */
.conversations-section {
    padding: 40px 0 80px;
    background: var(--tiber-light-gray);
}

.conversation-item {
    background: var(--tiber-white);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--tiber-charcoal);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item:hover {
    background: var(--tiber-white);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateX(5px);
    color: var(--tiber-charcoal);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(0, 173, 188, 0.1);
    color: var(--tiber-primary);
}

.status-badge.ended {
    background: rgba(108, 117, 125, 0.1);
    color: var(--tiber-blue-gray);
}

/* Footer */
.footer-mdtutor {
    background: var(--tiber-charcoal);
    color: var(--tiber-white);
    padding: 40px 0 20px;
}

.footer-brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.footer-brand span {
    color: var(--tiber-primary);
}

.footer-text {
    opacity: 0.7;
    font-size: 0.9rem;
}

.footer-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--tiber-primary);
}

/* Alerts */
.alert-danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
    border-radius: 12px;
}

/* Utilities */
.text-tiber-primary {
    color: var(--tiber-primary) !important;
}

.text-tutor {
    color: var(--tiber-charcoal) !important;
}

[data-theme="dark"] .text-tutor {
    color: var(--tiber-white) !important;
}

.bg-tiber-primary {
    background-color: var(--tiber-primary) !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

/* ============================
   Theme Toggle & Dark Mode
   ============================ */

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 20px rgba(0, 173, 188, 0.3);
}

.theme-toggle svg,
.theme-toggle i {
    width: 22px;
    height: 22px;
    font-size: 22px;
    color: var(--tiber-primary);
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg,
.theme-toggle:hover i {
    transform: rotate(15deg);
}

/* Theme Toggle in Header (Conversation page) */
.theme-toggle-header {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-header:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 10px rgba(0, 173, 188, 0.3);
}

.theme-toggle-header i {
    font-size: 16px;
    color: var(--tiber-primary);
    transition: transform 0.3s ease;
}

.theme-toggle-header:hover i {
    transform: rotate(15deg);
}

/* Sun/Moon icon visibility */
.theme-toggle .sun-icon,
.theme-toggle-header .sun-icon {
    display: none;
}

.theme-toggle .moon-icon,
.theme-toggle-header .moon-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon,
[data-theme="dark"] .theme-toggle-header .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon,
[data-theme="dark"] .theme-toggle-header .moon-icon {
    display: none;
}

/* Smooth theme transitions */
html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body,
.tutor-container,
.tutor-form,
.card,
.accordion,
.form-control,
.form-select,
.btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Dark mode specific overrides for Bootstrap components */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--input-text);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--input-bg);
    border-color: var(--tiber-primary);
    color: var(--input-text);
    box-shadow: 0 0 0 0.25rem rgba(0, 173, 188, 0.25);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-text {
    color: var(--text-muted);
}

[data-theme="dark"] .form-check-input {
    background-color: var(--input-bg);
    border-color: var(--input-border);
}

[data-theme="dark"] .form-check-input:checked {
    background-color: var(--tiber-primary);
    border-color: var(--tiber-primary);
}

[data-theme="dark"] .form-label,
[data-theme="dark"] .form-check-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .accordion-button {
    background-color: var(--accordion-bg);
    color: var(--text-primary);
}

[data-theme="dark"] .accordion-button:not(.collapsed) {
    background-color: var(--accordion-active-bg);
    color: var(--tiber-primary);
}

[data-theme="dark"] .accordion-button::after {
    filter: invert(1) brightness(0.8);
}

[data-theme="dark"] .accordion-body {
    background-color: var(--card-bg);
}

[data-theme="dark"] .accordion-item {
    background-color: var(--card-bg);
    border-color: var(--card-border);
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.3);
    color: #fca5a5;
}

/* ============================
   Conversation Page - Transcript Panel
   ============================ */

.conversation-header {
    background: var(--bg-secondary);
    min-height: 60px;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

/* Header Logo (inline with flex layout) */
.header-logo img {
    height: 32px;
    width: auto;
    filter: var(--logo-filter);
    transition: filter 0.3s ease;
}

/* SignalR connection status indicator */
.signalr-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    user-select: none;
}

.signalr-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.signalr-status--connected .signalr-status-dot {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}
.signalr-status--connected {
    color: #22c55e;
}

.signalr-status--connecting .signalr-status-dot,
.signalr-status--reconnecting .signalr-status-dot {
    background: #f59e0b;
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.5);
    animation: signalr-pulse 1.2s ease-in-out infinite;
}
.signalr-status--connecting,
.signalr-status--reconnecting {
    color: #f59e0b;
}

.signalr-status--disconnected .signalr-status-dot {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}
.signalr-status--disconnected {
    color: #ef4444;
}

@keyframes signalr-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Status icon inside the SignalR pill — replaces the prior text label.
 * Color is inherited from the parent's state class so it tracks the dot. */
.signalr-status-icon {
    font-size: 0.75rem;
    line-height: 1;
}

/* PubMed personal-key status pill — sibling of .signalr-status, same shape.
 * Rendered ONLY when the JWT carries a PubMed.ApiKey claim (positive
 * indicator). State is purely informational (set in the My Settings popup
 * on /select), so there's no JS-driven update — the badge re-renders on
 * next sign-in. */
.pubmed-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    line-height: 1;
    user-select: none;
    cursor: help;
    background: rgba(22, 163, 74, 0.15);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.4);
}

/* Move theme toggle below conversation header on conversation page */
body:has(.conversation-header) .theme-toggle {
    top: calc(60px + 1rem);
}

.conversation-content {
    overflow: hidden;
    position: relative;
}

.video-panel {
    min-width: 0;
    background: var(--bg-secondary);
}

/* Image reference overlay (SignalR ReceiveImageReference). z-index has to
   sit above every floating page element — quiz FAB (210), transcript bars
   (1050-1100), modal-grade UI (1200) — so the close button isn't occluded. */
.image-reference-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    animation: imageOverlayFadeIn 0.4s ease-out;
}

.image-reference-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: opacity 0.2s ease;
}

/* Hidden behind the loading placeholder until the bytes paint (see
   _renderImageOverlayContent); the placeholder is removed on the load event. */
.image-reference-img.is-loading {
    opacity: 0;
}

/* Publisher attribution under the enlarged figure. Absolutely positioned as a
   translucent caption bar at the bottom so it doesn't disturb the centered
   image. Real textbook figures only — generated images send no credit. */
.image-reference-credit {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 88%;
    text-align: center;
    color: #e5e7eb;
    font-size: 13px;
    font-style: italic;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 12px;
    border-radius: 6px;
}

.image-reference-credit-link {
    color: inherit;
    text-decoration: none;
}

.image-reference-credit-link:hover {
    text-decoration: underline;
}

/* "Open in new tab" on the enlarged view — generated (non-copyright) images only;
   textbook figures show their citation instead. Top-LEFT so it clears the close
   button (top-right). z-index above the image; click is stopped from dismissing. */
.image-reference-newtab {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 11;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 14px;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.55);
    padding: 8px 14px;
    border-radius: 20px;
    transition: background 0.15s ease;
}

.image-reference-newtab:hover {
    background: rgba(0, 0, 0, 0.85);
    text-decoration: underline;
}

@keyframes imageOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pending placeholder shown inside .image-reference-overlay while we wait
   for the generated image bytes. Light gray panel with a dark gray bar that
   sweeps top-to-bottom like an old CRT scan line. */
.image-reference-placeholder {
    width: 320px;
    height: 320px;
    background: #d6d6d6;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.image-reference-placeholder-scan {
    position: absolute;
    left: 0;
    right: 0;
    height: 8px;
    top: 0;
    background: linear-gradient(to bottom, transparent, #555 50%, transparent);
    animation: imageReferencePlaceholderScan 1.5s linear infinite;
    will-change: transform;
}

@keyframes imageReferencePlaceholderScan {
    from { transform: translateY(-8px); }
    to   { transform: translateY(320px); }
}

.image-reference-failed {
    padding: 18px 26px;
    background: #fff5f5;
    color: #b91c1c;
    border: 1px dashed #f5c2c2;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Close (×) button on the image overlay. Top-right of the backdrop. */
.image-reference-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 11;
    transition: background 0.15s ease;
}

.image-reference-close:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* ─── Avatar PIP mode ────────────────────────────────────────────────────
   When an image overlay opens, the daily-container STAYS full-size
   (so the .image-reference-overlay still fills the left video panel
   without overflowing onto the transcript on the right). The Daily.co
   <video> element INSIDE it shrinks to a small bottom-right tile with a
   very high z-index so it floats over the image. Toggled by
   UiController._enterAvatarPipMode / _exitAvatarPipMode tied to
   showImageOverlay / dismissImageOverlay.

   Transitions sit on the base video selector so both shrink and restore
   animate (a transition only on the active state would lose the
   animation on class removal). */
#daily-container > video {
    transition: width 0.4s ease,
                height 0.4s ease,
                top 0.4s ease,
                left 0.4s ease,
                bottom 0.4s ease,
                right 0.4s ease,
                border-radius 0.4s ease,
                box-shadow 0.4s ease;
}

#daily-container.avatar-pip > video {
    position: absolute !important;
    z-index: 1400;
    width: 200px !important;
    height: 158px !important;
    top: auto !important;
    left: auto !important;
    bottom: 10px;
    right: 10px;
    border-radius: 7px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    object-fit: cover;
}

/* Hidden state — video display:none, the show-pill takes its place. */
#daily-container.avatar-pip.avatar-hidden > video {
    display: none;
}

/* Hide (×) button — overlays the top-right corner of the shrunken video
   tile. Positioned relative to the daily-container at coordinates that
   land on the tile (tile is 300×200 at bottom:10 right:10, so the
   button sits at bottom: 10+200-28+2 ≈ 184px, right: 10+4 ≈ 14px). */
/* Single toggle button — × (hide) when the PIP video is visible, morphs
   into a "Show Dr. Olivia" pill at the bottom-right when avatar-hidden
   is on. Same DOM element, animated transitions on size/position. */
#daily-container.avatar-pip .avatar-pip-hide {
    position: absolute;
    bottom: 140px;
    right: 14px;
    z-index: 1401;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: bottom 0.3s ease,
                right 0.3s ease,
                width 0.3s ease,
                height 0.3s ease,
                border-radius 0.3s ease,
                padding 0.3s ease,
                font-size 0.3s ease,
                background 0.15s ease;
}

#daily-container.avatar-pip .avatar-pip-hide:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* When the avatar is hidden, the same button morphs into a wider pill at
   the bottom-right where the video used to be. Restores on click. */
#daily-container.avatar-pip.avatar-hidden .avatar-pip-hide {
    bottom: 10px;
    right: 10px;
    width: auto;
    height: auto;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.85);
}

#daily-container.avatar-pip.avatar-hidden .avatar-pip-hide:hover {
    background: #000;
}

/* Inline image thumbnails inside transcript replica entries. Click to
   re-open the full overlay. */
.transcript-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.transcript-image {
    width: 80px;
    height: 80px;
    padding: 0;
    border: none;
    border-radius: 6px;
    overflow: hidden;
    background: #2a2a2a;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.transcript-image:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.transcript-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.transcript-image--pending {
    background: #d6d6d6;
    cursor: default;
}

/* Bytes still downloading after the URL arrived — gray box + scan until the
   img's onload fires, so a slow fetch shows a loading state, never a blank tile.
   The tile is a fixed 80×80 so it can't collapse; the img is hidden until loaded. */
.transcript-image--loading {
    background: #d6d6d6;
}

.transcript-image--loading img {
    opacity: 0;
}

.transcript-image-scan {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(to bottom, transparent, #555 50%, transparent);
    animation: transcriptImageScan 1.5s linear infinite;
    will-change: transform;
}

@keyframes transcriptImageScan {
    from { transform: translateY(-4px); }
    to   { transform: translateY(80px); }
}

.transcript-image--failed {
    background: #fff5f5;
    color: #b91c1c;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transcript-image-failed-mark {
    font-size: 28px;
    line-height: 1;
}

/* Transcript Panel - Base Styles (Desktop >1200px) */
.transcript-panel {
    width: 380px;
    min-width: 380px;
    max-width: 400px;
    background: var(--card-bg);
    border-left: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.transcript-panel.collapsed {
    width: 0;
    min-width: 0;
    border-left: none;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.transcript-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    flex-shrink: 0;
    gap: 0.5rem;
}

.transcript-header h6 {
    display: flex;
    align-items: center;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transcript-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.transcript-actions .btn {
    padding: 0.25rem 0.5rem;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transcript-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Smooth scrolling */
    scroll-behavior: smooth;
}

.transcript-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

/* Transcript Entry */
.transcript-entry {
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    border-left: 3px solid transparent;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 0.5rem;
}

.transcript-entry.transcript-replica {
    border-left-color: var(--tiber-primary);
    background: rgba(0, 173, 188, 0.05);
    margin-right: 2rem;
}

.transcript-entry.transcript-user {
    border-left-color: var(--tiber-blue-gray);
    background: var(--bg-tertiary);
    margin-left: 2rem;
}

.transcript-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.transcript-speaker {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.transcript-entry.transcript-replica .transcript-speaker {
    color: var(--tiber-primary);
}

.transcript-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
}

.transcript-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Toggle button styling (collapse button in panel header) */
#toggle-transcript {
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#toggle-transcript:hover {
    background-color: rgba(0, 173, 188, 0.1);
    border-color: var(--tiber-primary);
    color: var(--tiber-primary);
}

#toggle-transcript svg {
    transition: transform 0.3s ease;
}

/* Floating expand button (visible when panel is collapsed) */
.expand-transcript-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 88px;
    background: var(--tiber-primary);
    border: none;
    border-radius: 8px 0 0 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    /* Above the image overlay (1300) so a student who closed the transcript
       to get a bigger image view can reopen it without dismissing the image. */
    z-index: 1310;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, width 0.2s ease, background-color 0.2s ease;
}

.expand-transcript-btn.visible {
    opacity: 1;
    pointer-events: all;
}

.expand-transcript-btn:hover {
    width: 50px;
    background-color: var(--tiber-primary-dark);
}

.expand-transcript-btn svg {
    flex-shrink: 0;
}

/* Old hover style - keeping for reference */
#toggle-transcript.btn-outline-secondary:hover {
    background-color: rgba(0, 173, 188, 0.1);
    border-color: var(--tiber-primary);
}

/* Status indicator */
#status-indicator {
    text-transform: capitalize;
}

#status-indicator.status-active {
    color: var(--tiber-primary);
}

#status-indicator.status-ended {
    color: var(--text-muted);
}

/* ============================
   RESPONSIVE BREAKPOINTS
   ============================ */

/* Laptop: 992px - 1200px - Reduced panel width */
@media (max-width: 1200px) {
    .transcript-panel {
        width: 320px;
        min-width: 320px;
        max-width: 320px;
    }

    .transcript-header {
        padding: 0.875rem;
    }

    .transcript-content {
        padding: 0.875rem;
    }

    .transcript-text {
        font-size: 0.875rem;
    }
}

/* Tablet: 768px - 992px - Smaller panel, collapsible by default */
@media (max-width: 992px) {
    .transcript-panel {
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }

    .transcript-header {
        padding: 0.75rem;
    }

    .transcript-header h6 {
        font-size: 0.95rem;
    }

    .transcript-content {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .transcript-entry {
        padding: 0.625rem;
    }

    .transcript-text {
        font-size: 0.85rem;
    }

    /* On tablet, panel can be collapsed to save space */
    .transcript-panel.collapsed {
        width: 0;
        min-width: 0;
    }
}

/* Mobile: <768px - Slide-out overlay with backdrop */
@media (max-width: 768px) {
    .transcript-panel {
        position: fixed;
        top: 60px;
        right: 0;
        bottom: 0;
        width: 85%;
        min-width: 85%;
        max-width: 400px;
        z-index: 1000;
        transform: translateX(100%);
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
        border-left: none;
    }

    .transcript-panel:not(.collapsed) {
        transform: translateX(0);
        opacity: 1;
        pointer-events: all;
    }

    .transcript-panel.collapsed {
        transform: translateX(100%);
        opacity: 0;
    }

    /* Backdrop overlay when panel is open on mobile */
    .transcript-panel:not(.collapsed)::before {
        content: '';
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Adjust conversation content for mobile overlay */
    .conversation-content {
        position: relative;
    }

    .video-panel {
        width: 100%;
    }

    /* Make header more compact on mobile */
    .conversation-header {
        padding: 0.75rem 1rem;
    }

    .conversation-header h4 {
        font-size: 1.1rem;
    }

    .conversation-header .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Adjust transcript for mobile */
    .transcript-header {
        padding: 0.875rem;
    }

    .transcript-content {
        padding: 0.875rem;
    }
}

/* Extra Small Mobile: <480px - Even more compact */
@media (max-width: 480px) {
    .transcript-panel {
        width: 90%;
        min-width: 90%;
    }

    .transcript-header h6 {
        font-size: 0.9rem;
    }

    .transcript-header h6 svg {
        width: 14px;
        height: 14px;
    }

    .transcript-actions .btn {
        padding: 0.25rem 0.4rem;
        min-width: 28px;
    }

    .transcript-actions .btn svg {
        width: 12px;
        height: 12px;
    }

    .transcript-entry {
        padding: 0.5rem;
    }

    .transcript-speaker {
        font-size: 0.8rem;
    }

    .transcript-time {
        font-size: 0.7rem;
    }

    .transcript-text {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Hide "Transcript" text on very small screens */
    #toggle-transcript .d-none.d-md-inline {
        display: none !important;
    }
}

/* Dark mode adjustments for transcript */
[data-theme="dark"] .transcript-entry.transcript-replica {
    background: rgba(0, 173, 188, 0.1);
}

[data-theme="dark"] .transcript-entry.transcript-user {
    background: var(--bg-tertiary);
}

/* Scrollbar styling for transcript */
.transcript-content::-webkit-scrollbar {
    width: 6px;
}

.transcript-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.transcript-content::-webkit-scrollbar-thumb {
    background: var(--tiber-primary);
    border-radius: 3px;
}

.transcript-content::-webkit-scrollbar-thumb:hover {
    background: var(--tiber-primary-dark);
}

/* ============================
   Mode Selection (Index Page)
   ============================ */

.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mode-option {
    position: relative;
}

.mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.mode-option label {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 2px solid var(--card-border);
    border-radius: 12px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.mode-option label:hover {
    border-color: var(--tiber-primary-light);
    background: var(--bg-secondary);
}

.mode-option input[type="radio"]:checked + label {
    border-color: var(--tiber-primary);
    background: rgba(0, 173, 188, 0.08);
    box-shadow: 0 0 0 3px rgba(0, 173, 188, 0.15);
}

.mode-option .mode-icon {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.mode-option .mode-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.mode-option .mode-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Responsive mode selection */
@media (max-width: 576px) {
    .mode-selection {
        grid-template-columns: 1fr;
    }

    .mode-option label {
        flex-direction: row;
        text-align: left;
        gap: 1rem;
        padding: 0.875rem;
    }

    .mode-option .mode-icon {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .mode-option .mode-info {
        flex: 1;
    }
}

/* Disabled mode option (at capacity) */
.mode-option.mode-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.mode-option.mode-disabled label {
    cursor: not-allowed;
    border-color: var(--card-border);
    background: var(--card-bg);
    box-shadow: none;
}

/* Stream status message (below Start button) */
.stream-message {
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.4;
    min-height: 1.4em;
    margin-top: 0.75rem;
}

.stream-message--info {
    color: var(--text-muted);
}

.stream-message--full {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #664d03;
    text-align: left;
}

.stream-message--full i {
    flex-shrink: 0;
    font-size: 1rem;
}

/* ============================
   Mode Badge (Conversation Header)
   ============================ */

.mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.75rem;
    vertical-align: middle;
}

.mode-badge.mode-video {
    background: rgba(0, 173, 188, 0.15);
    color: var(--tiber-primary);
}

.mode-badge.mode-audioonly {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
}

.mode-badge.mode-textavatar {
    background: rgba(234, 88, 12, 0.15);
    color: #ea580c;
}

.mode-badge.mode-puretext {
    background: rgba(22, 163, 74, 0.15);
    color: #16a34a;
}

/* ============================
   Faculty Mode pill
   ----------------------------
   Shown in the page header on every surface (Select, Avatar video,
   Audio-only, and the Angular text chatbot) when the current session is
   operating in Faculty mode. Students see nothing — the default Socratic
   experience carries no pill.
   ============================ */

.faculty-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(234, 88, 12, 0.15);
    color: #ea580c;
    border: 1px solid rgba(234, 88, 12, 0.35);
    user-select: none;
    white-space: nowrap;
}

.faculty-mode-pill i {
    font-size: 0.75rem;
}

/* ============================
   Impersonation Pill (Act-As override active)

   Shown alongside the Faculty pill on every client surface when the
   signed-in JWT carries an OriginalCanvasUserDimId claim. The admin (real)
   account is operating as another user; everything chat-side reflects the
   impersonated identity but admin audit logs still attribute the action to
   the real admin. Red/maroon palette so the screen-share viewer immediately
   sees they're not looking at a real student session.
   ============================ */

.impersonation-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(185, 28, 28, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.4);
    user-select: none;
    white-space: nowrap;
}

.impersonation-pill i {
    font-size: 0.75rem;
}

/* Below 1400px the Select-page header runs out of room and these pills wrap
   onto a second row. Collapse them to icon-only — native title= tooltips
   already explain each one, so the affordance is preserved. */
@media (max-width: 1399.98px) {
    .faculty-mode-pill,
    .impersonation-pill {
        padding: 0.3rem 0.45rem;
        gap: 0;
    }

    .faculty-mode-pill > span,
    .impersonation-pill > span {
        display: none;
    }
}

/* ============================
   Input Mode Toggle (Video/TextAvatar)
   ============================ */

.input-mode-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 3px;
    margin-left: 1rem;
    gap: 2px;
}

.input-mode-toggle .toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.input-mode-toggle .toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.input-mode-toggle .toggle-btn.active {
    background: var(--tiber-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 173, 188, 0.3);
}

.input-mode-toggle .toggle-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Text panel show/hide transition for toggle */
.text-input-panel.hidden {
    opacity: 0;
    transform: translateY(20px);
    visibility: hidden;
    pointer-events: none;
}

/* Responsive adjustments for toggle */
@media (max-width: 768px) {
    .input-mode-toggle {
        margin-left: 0.5rem;
    }

    .input-mode-toggle .toggle-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    .input-mode-toggle .toggle-btn span {
        display: none; /* Hide text on mobile, show only icons */
    }

    .input-mode-toggle .toggle-btn svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .input-mode-toggle {
        padding: 2px;
    }

    .input-mode-toggle .toggle-btn {
        padding: 0.25rem 0.4rem;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .input-mode-toggle {
    background: var(--bg-secondary);
}

[data-theme="dark"] .input-mode-toggle .toggle-btn.active {
    background: var(--tiber-primary-dark);
}

/* ============================
   Pure Text Chat Mode
   ============================ */

.chat-container {
    background: var(--bg-primary);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-messages {
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.chat-welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.chat-welcome h5 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Chat Message */
.chat-message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.chat-user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.chat-message.chat-assistant .chat-avatar {
    background: rgba(0, 173, 188, 0.15);
}

.chat-content {
    flex: 1;
    min-width: 0;
}

.chat-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.chat-message.chat-user .chat-sender {
    text-align: right;
}

.chat-text {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
}

.chat-message.chat-assistant .chat-text {
    background: rgba(0, 173, 188, 0.08);
    border: 1px solid rgba(0, 173, 188, 0.15);
}

.chat-message.chat-user .chat-text {
    background: var(--tiber-primary);
    color: white;
}

/* Streaming indicator */
.chat-message.streaming .chat-text::after {
    content: '▊';
    animation: blink 0.8s infinite;
    color: var(--tiber-primary);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Chat Input Area */
.chat-input-area {
    padding: 1rem 1.5rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--card-border);
}

.chat-input-area .input-group {
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--card-border);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.chat-input-area .input-group:focus-within {
    border-color: var(--tiber-primary);
}

.chat-input-area textarea {
    border: none;
    resize: none;
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    line-height: 1.4;
    background: transparent;
    color: var(--text-primary);
    max-height: 150px;
}

.chat-input-area textarea:focus {
    box-shadow: none;
    outline: none;
}

.chat-input-area textarea::placeholder {
    color: var(--text-muted);
}

.chat-input-area .btn {
    border-radius: 0;
    padding: 0.875rem 1.25rem;
    align-self: flex-end;
}

/* ============================
   TextAvatar Text Input Panel
   ============================ */

.text-input-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent, var(--bg-primary) 30%);
    z-index: 50;
}

.text-input-panel .input-group {
    max-width: 600px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 25px;
    border: 2px solid var(--card-border);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input-panel .input-group:focus-within {
    border-color: var(--tiber-primary);
    box-shadow: 0 4px 25px rgba(0, 173, 188, 0.2);
}

.text-input-panel input {
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    background: transparent;
    color: var(--text-primary);
}

.text-input-panel input:focus {
    box-shadow: none;
    outline: none;
}

.text-input-panel input::placeholder {
    color: var(--text-muted);
}

.text-input-panel .btn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Adjust video panel when text input is present */
.video-panel.with-text-input {
    padding-bottom: 80px;
}

/* ============================
   Dark Mode Adjustments for Chat
   ============================ */

[data-theme="dark"] .chat-message.chat-assistant .chat-text {
    background: rgba(0, 173, 188, 0.12);
    border-color: rgba(0, 173, 188, 0.2);
}

[data-theme="dark"] .chat-message.chat-user .chat-text {
    background: var(--tiber-primary-dark);
}

[data-theme="dark"] .mode-badge.mode-audioonly {
    background: rgba(147, 51, 234, 0.25);
}

[data-theme="dark"] .mode-badge.mode-textavatar {
    background: rgba(234, 88, 12, 0.25);
}

[data-theme="dark"] .mode-badge.mode-puretext {
    background: rgba(22, 163, 74, 0.25);
}

/* ============================
   Responsive Chat Adjustments
   ============================ */

@media (max-width: 768px) {
    .chat-messages {
        padding: 1rem;
    }

    .chat-message {
        max-width: 95%;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .chat-text {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    .chat-input-area {
        padding: 0.75rem 1rem 1rem;
    }

    .text-input-panel {
        padding: 0.75rem;
    }

    .text-input-panel .input-group {
        border-radius: 20px;
    }

    .mode-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .chat-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .chat-text {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .chat-sender {
        font-size: 0.75rem;
    }
}

/* ============================
   Interrupt Button (Header)
   ============================ */

.btn-interrupt {
    display: flex;
    align-items: center;
    gap: 6px;

    padding: 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;

    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;

    opacity: 0.5;
    cursor: not-allowed;

    transition: all 0.2s ease;
}

.btn-interrupt:disabled {
    opacity: 0.7;
    background: #6c757d;
    border: 1px solid #5a6268;
}

.btn-interrupt.active {
    opacity: 1;
    cursor: pointer;
    background: #dc3545;
    animation: pulse-interrupt 1.5s ease-in-out infinite;
}

.btn-interrupt.active:hover {
    background: #c82333;
    transform: scale(1.02);
}

.btn-interrupt.active:active {
    transform: scale(0.98);
}

.btn-interrupt.interrupted {
    animation: flash-interrupt 0.4s ease;
}

.btn-interrupt svg {
    flex-shrink: 0;
}

@keyframes pulse-interrupt {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.2);
    }
}

@keyframes flash-interrupt {
    0%, 100% {
        background: #dc3545;
    }
    50% {
        background: #fff;
        color: #dc3545;
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .btn-interrupt {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .btn-interrupt span {
        display: none;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .btn-interrupt.active {
        animation: none;
    }

    .btn-interrupt.interrupted {
        animation: none;
    }
}

/* ============================
   FontAwesome Icon Sizing
   ============================ */

/* Mode Selection Icons (Index.cshtml) */
.mode-icon i {
    font-size: 20px;
    line-height: 1;
}

/* Input Mode Toggle Icons */
.input-mode-toggle .toggle-btn i {
    font-size: 14px;
    line-height: 1;
}

/* Interrupt Button Icon */
.btn-interrupt i {
    font-size: 14px;
}

/* Send Button Icons */
.chat-input-area .btn i,
#send-btn i {
    font-size: 18px;
}

#send-text-btn i {
    font-size: 16px;
}

/* Transcript Panel Icons */
.expand-transcript-btn i {
    font-size: 20px;
}

#toggle-transcript i {
    font-size: 14px;
}

.transcript-header h6 i {
    font-size: 16px;
}

.transcript-actions .btn i {
    font-size: 14px;
}

/* Empty State Icon */
.transcript-empty i {
    font-size: 32px;
    display: block;
}

/* ========================================
   Mic Status Indicator
   ======================================== */
.mic-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.mic-indicator.mic-active {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    animation: pulse-mic 2s infinite;
}

.mic-indicator.mic-muted {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    animation: none;
}

@keyframes pulse-mic {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* ========================================
   Muted Window Glow Border
   ======================================== */
.mic-muted-glow {
    box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.7),
                inset 0 0 24px rgba(239, 68, 68, 0.15);
    transition: box-shadow 0.4s ease;
}

.mic-muted-glow::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    border: 3px solid rgba(239, 68, 68, 0.7);
    box-shadow: inset 0 0 30px rgba(239, 68, 68, 0.2),
                0 0 30px rgba(239, 68, 68, 0.15);
    animation: mute-glow-pulse 2s ease-in-out infinite;
}

@keyframes mute-glow-pulse {
    0%, 100% { border-color: rgba(239, 68, 68, 0.7); box-shadow: inset 0 0 30px rgba(239, 68, 68, 0.2), 0 0 30px rgba(239, 68, 68, 0.15); }
    50% { border-color: rgba(239, 68, 68, 0.4); box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.1), 0 0 15px rgba(239, 68, 68, 0.08); }
}



.ribbon-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 48px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
    color: #555;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.ribbon-btn img {
    width: 20px;
    height: 20px;
}

.ribbon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
}

.ribbon-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

.ribbon-btn.active {
    background: rgba(74, 158, 255, 0.12);
    border-color: rgba(74, 158, 255, 0.3);
    color: #4a9eff;
}

.ribbon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ribbon-btn-group {
    display: inline-flex;
    gap: 2px;
    padding: 2px 4px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    margin-right: 4px;
}

.ribbon-btn-group:last-child {
    border-right: none;
    margin-right: 0;
}

.powered-by-footer {
    margin-top: 2.5rem;
    font-size: 0.8rem;
    color: var(--slate-500);
    animation: fadeDown 0.6s ease-out 0.4s both;
}

.tutor-ai-tiber {
    font-family: "DM Sans", sans-serif;
    font-weight: 700;
    color: var(--tiber-charcoal);
    font-size: 1.5rem;
    margin-right: 0.5rem;
    margin-left: 0.25rem;
}

.tutor-ai-tiber > span {
    color: var(--teal-700);
    font-weight: 700;
}

/* ============================================================================
   Source materials overlay (avatar) — pushed via SignalR ReceiveMaterials at
   end-of-stream. Per-message link sits in the transcript entry header; the
   bottom button is rendered into the transcript panel by UiController.
   ============================================================================ */

.transcript-entry .transcript-materials-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    background: rgba(0, 153, 154, 0.12);
    color: #024748;
    border: 1px solid rgba(0, 153, 154, 0.35);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.transcript-entry .transcript-materials-link:hover {
    background: #00999A;
    color: #fff;
    border-color: #00999A;
}

.transcript-entry .transcript-materials-link i {
    font-size: 10px;
}

[data-theme="dark"] .transcript-entry .transcript-materials-link {
    background: rgba(0, 153, 154, 0.18);
    color: #b5e3e3;
    border-color: rgba(0, 153, 154, 0.55);
}

[data-theme="dark"] .transcript-entry .transcript-materials-link:hover {
    background: #00999A;
    color: #fff;
}

/* ============================================================================
   Per-response thumbs up/down rating (avatar transcript) — sits in the entry
   header next to the materials link. Rendered for every Olivia-spoken
   response once the server has pushed the ResponseId. Click submits via
   TutorHub.SubmitRating → ChatRequest.Rating (0=down, 1=up, null=cleared).
   ============================================================================ */

.transcript-entry .transcript-rating {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
}

.transcript-entry .transcript-rating-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    color: var(--text-secondary, #6b7d7d);
    border: 1px solid rgba(0, 153, 154, 0.35);
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.transcript-entry .transcript-rating-btn:hover {
    background: rgba(0, 153, 154, 0.18);
    color: #024748;
    border-color: #00999A;
}

.transcript-entry .transcript-rating-btn--active {
    background: #00999A;
    color: #fff;
    border-color: #00999A;
    transform: scale(1.05);
}

.transcript-entry .transcript-rating-btn--active:hover {
    background: #024748;
    border-color: #024748;
    color: #fff;
}

[data-theme="dark"] .transcript-entry .transcript-rating-btn {
    color: #b5e3e3;
    border-color: rgba(0, 153, 154, 0.55);
}

[data-theme="dark"] .transcript-entry .transcript-rating-btn:hover {
    background: rgba(0, 153, 154, 0.25);
    color: #fff;
}

[data-theme="dark"] .transcript-entry .transcript-rating-btn--active,
[data-theme="dark"] .transcript-entry .transcript-rating-btn--active:hover {
    background: #00999A;
    color: #fff;
    border-color: #00999A;
}

/* Thumbs-down: warning palette so it reads as "bad" instead of "more teal". */
.transcript-entry .transcript-rating-btn--down:hover {
    background: rgba(192, 57, 43, 0.18);
    color: #8b2918;
    border-color: #c0392b;
}

.transcript-entry .transcript-rating-btn--down.transcript-rating-btn--active,
.transcript-entry .transcript-rating-btn--down.transcript-rating-btn--active:hover {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

[data-theme="dark"] .transcript-entry .transcript-rating-btn--down:hover {
    background: rgba(216, 75, 75, 0.28);
    color: #ffb3a8;
    border-color: #d9534f;
}

[data-theme="dark"] .transcript-entry .transcript-rating-btn--down.transcript-rating-btn--active,
[data-theme="dark"] .transcript-entry .transcript-rating-btn--down.transcript-rating-btn--active:hover {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

.all-materials-bar {
    padding: 10px 16px 14px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    border-top: 1px solid var(--card-border);
    background: var(--bg-secondary);
}

.all-materials-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #024748 0%, #00999A 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(2, 71, 72, 0.25);
    transition: transform 0.15s, box-shadow 0.15s;
}

.all-materials-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(2, 71, 72, 0.35);
}

.all-materials-btn i {
    font-size: 14px;
}

/* ── Materials overlay modal ─────────────────────────────────────────────── */
.materials-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.5);
}

.materials-card {
    background: #fff;
    border-radius: 12px;
    width: 92%;
    max-width: 760px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.materials-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(135deg, #024748 0%, #00999A 100%);
    color: #fff;
    flex-shrink: 0;
}

.materials-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.materials-header h3 i {
    font-size: 18px;
}

.materials-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.materials-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.materials-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
    flex: 1;
}

.materials-empty {
    text-align: center;
    padding: 48px 16px;
    color: #888;
}

.materials-empty i {
    font-size: 36px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.materials-empty p {
    margin: 0;
    font-size: 14px;
}

.materials-group {
    margin-bottom: 20px;
}

.materials-group:last-child {
    margin-bottom: 0;
}

.materials-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 2px solid #00999A;
}

.materials-group-header i {
    color: #00999A;
    font-size: 16px;
}

.materials-group-title {
    font-weight: 700;
    color: #024748;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 1;
}

.materials-group-count {
    background: #e6f4f4;
    color: #024748;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.materials-group-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.materials-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fafa;
    border: 1px solid #e0e8e8;
    border-radius: 8px;
    border-left: 3px solid #00999A;
}

.materials-item-main {
    flex: 1;
    min-width: 0;
}

.materials-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #024748;
    line-height: 1.3;
}

.materials-item-subtitle {
    font-size: 12px;
    color: #5a6363;
    margin-top: 2px;
}

.materials-item-reason {
    font-size: 12px;
    color: #555;
    margin-top: 6px;
    line-height: 1.45;
    font-style: italic;
}

/* Outbound links to the source (e.g. PubMed abstract + PMC full text).
 * Compact pill-style links sit at the bottom of each item. Mirrors the
 * chatbot's materials-overlay.css for visual consistency. */
.materials-item-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.materials-item-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 153, 154, 0.1);
    color: #00777a;
    border: 1px solid rgba(0, 153, 154, 0.3);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.materials-item-link:hover {
    background: rgba(0, 153, 154, 0.18);
    color: #005d5e;
    text-decoration: none;
}

.materials-item-link i {
    font-size: 9px;
    opacity: 0.75;
}

.materials-item-strength {
    flex-shrink: 0;
    background: #00999A;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 10px;
    align-self: center;
}

@media (max-width: 600px) {
    .materials-card {
        width: 96%;
        max-height: 92vh;
    }
    .materials-header {
        padding: 14px 18px;
    }
    .materials-body {
        padding: 16px 18px 20px;
    }
}

/* Subtle build-version label, pinned to the bottom-right corner of the
   selection page. Faint and non-interactive — present for QA/support, not
   meant to draw the student's eye. */
.vt-build-version {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    line-height: 1;
    color: var(--slate-500);
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}
