/* ═══════════════════════════════════════
   KHIO TUTOR, Voice-First AI Tutor
   ═══════════════════════════════════════ */

.khio-tutor-wrap {
    display: flex; flex-direction: column;
    height: calc(100vh - 140px);
    width: 100%;
    max-width: 860px; margin: 0 auto;
    position: relative;
}

/* Voice session: take essentially the full canvas. Loading state reads
   really cramped at 1100px on a 1900px monitor, too much empty side
   gutter for a focused tutoring stage. Bump to 1500 so the bot, status
   and bubble actually fill the visual field. */
.khio-tutor-wrap.tutor-voice-session {
    max-width: 1500px;
}

/* Welcome screen uses a wider two-column layout that fills the available
   canvas, hero/mode on the left, config/info on the right. */
.khio-tutor-wrap.tutor-welcome-active {
    max-width: 1320px;
    height: auto;
    min-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 0 8px;
}

/* ── Welcome Screen ── */
.khio-tutor-welcome {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; flex: 1;
    padding: 40px 24px;
}
.khio-tutor-welcome-icon {
    width: 72px; height: 72px; border-radius: 20px;
    background: rgba(239, 68, 68, 0.1);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 20px;
}
.khio-tutor-welcome-icon i { width: 36px; height: 36px; color: #ef4444; }
.khio-tutor-welcome-title {
    font-size: 26px; font-weight: 800; color: var(--study-text);
    margin: 0 0 10px;
}
.khio-tutor-welcome-desc {
    font-size: 15px; color: var(--study-text-secondary);
    max-width: 420px; line-height: 1.6; margin: 0 0 24px;
}
.khio-tutor-welcome-modes {
    display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.khio-tutor-start-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 16px 36px; border-radius: 16px;
    border: 2px solid rgba(239, 68, 68, 0.3);
    background: #ef4444; color: #fff;
    font-size: 16px; font-weight: 800;
    cursor: pointer; font-family: inherit;
    box-shadow: 3px 3px 0 #1a1a1a;
    transition: all .15s;
}
.khio-tutor-start-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #1a1a1a;
}
.khio-tutor-start-btn i { width: 18px; height: 18px; }

/* ── Voice Picker ── */
.tutor-voice-picker {
    margin-bottom: 20px; text-align: center;
}
.tutor-voice-picker-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--study-text-tertiary);
    margin-bottom: 10px;
}
.tutor-voice-picker-chips {
    display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.tutor-voice-chip {
    padding: 8px 20px; border-radius: 12px;
    border: 1.5px solid var(--study-border);
    background: var(--bg-card, #fff); color: var(--study-text);
    font-size: 14px; font-weight: 700; font-family: inherit;
    cursor: pointer; transition: all .15s;
}
.tutor-voice-chip:hover {
    border-color: var(--study-accent); color: var(--study-accent);
}
.tutor-voice-chip.active {
    border-color: #ef4444; background: rgba(239,68,68,0.1);
    color: #ef4444;
}
.tutor-voice-chip.loading {
    position: relative; pointer-events: none; opacity: 0.7;
}
.tutor-voice-chip.loading::after {
    content: ''; position: absolute; right: 6px; top: 50%;
    width: 10px; height: 10px; margin-top: -5px;
    border: 1.5px solid currentColor; border-top-color: transparent;
    border-radius: 50%; animation: tutorVoiceChipSpin 0.7s linear infinite;
}
@keyframes tutorVoiceChipSpin { to { transform: rotate(360deg); } }

/* Past session resume list on welcome screen */
.khio-tutor-past {
    margin-top: 28px; width: 100%; max-width: 480px;
    text-align: left;
}
.khio-tutor-past-label {
    font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--study-text-tertiary);
    margin-bottom: 10px; text-align: center;
}
.khio-tutor-past-list {
    display: flex; flex-direction: column; gap: 8px;
}
.khio-tutor-past-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; width: 100%;
    cursor: pointer;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 12px;
    cursor: pointer; transition: all .15s;
    font-family: inherit;
    text-align: left;
}
.khio-tutor-past-row:hover {
    border-color: var(--study-accent, #ef4444);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.08);
}
.khio-tutor-past-row-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--study-accent, #ef4444);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.khio-tutor-past-row-icon i { width: 16px; height: 16px; }
.khio-tutor-past-row-body { flex: 1; min-width: 0; }
.khio-tutor-past-row-title {
    font-size: 14px; font-weight: 700; color: var(--study-text);
}
.khio-tutor-past-row-meta {
    font-size: 12px; color: var(--study-text-tertiary);
    margin-top: 2px;
}
.khio-tutor-past-row-chev {
    width: 16px; height: 16px; color: var(--study-text-tertiary);
    flex-shrink: 0;
}
/* In-progress accent on the row icon */
.khio-tutor-past-row-icon.in-progress {
    background: rgba(239, 68, 68, 0.18);
    color: var(--study-accent, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}
/* "In progress" pill inside the meta line */
.khio-tutor-past-badge {
    display: inline-block;
    font-size: 10px; font-weight: 800;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--study-accent, #ef4444);
    background: rgba(239, 68, 68, 0.12);
    padding: 2px 7px; border-radius: 999px;
    margin-right: 6px; vertical-align: 1px;
}
/* Snippet title: allow 2 lines, truncate, single-line styles override from base */
.khio-tutor-past-row .khio-tutor-past-row-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}
/* Delete button on each row */
.khio-tutor-past-del {
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--study-text-tertiary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.khio-tutor-past-del i { width: 15px; height: 15px; }
.khio-tutor-past-del:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--study-accent, #ef4444);
    border-color: rgba(239, 68, 68, 0.25);
}
.khio-tutor-past-del:disabled { opacity: 0.4; cursor: wait; }
/* Prevent the whole-row hover lift from hijacking the delete button */
.khio-tutor-past-row:has(.khio-tutor-past-del:hover) {
    transform: none;
    border-color: var(--study-border);
    box-shadow: none;
}
.khio-tutor-start-text {
    background: var(--bg-card, #fff); color: var(--study-text);
    border: 1.5px solid var(--study-border);
    box-shadow: none; font-size: 14px; font-weight: 700;
    padding: 12px 28px;
}
.khio-tutor-start-text:hover {
    background: var(--bg-base, #f5f5f5);
    box-shadow: none; transform: none;
}

/* ── Chat Header ── */
.khio-tutor-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}
.khio-tutor-header-left {
    display: flex; align-items: center; gap: 12px;
}
/* Back to setup, sits on the far left of the header */
.khio-tutor-back-btn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--study-border);
    background: var(--bg-card, #fff); color: var(--study-text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all .15s; margin-right: 4px;
}
.khio-tutor-back-btn:hover {
    background: var(--bg-base); color: var(--study-text);
    border-color: var(--study-text-tertiary);
    transform: translateX(-1px);
}
.khio-tutor-back-btn i { width: 18px; height: 18px; }
.khio-tutor-header-icon {
    width: 40px; height: 40px; border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    display: flex; align-items: center; justify-content: center;
}
.khio-tutor-header-icon i { width: 20px; height: 20px; color: #ef4444; }
.khio-tutor-header-title {
    font-size: 16px; font-weight: 800; color: var(--study-text);
}
.khio-tutor-header-sub {
    font-size: 12px; color: var(--study-text-tertiary);
    max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tutor-mode-toggle {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--study-border);
    background: var(--bg-card, #fff); color: var(--study-text-tertiary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.tutor-mode-toggle:hover { background: var(--bg-base); color: var(--study-text); }
.tutor-mode-toggle i { width: 16px; height: 16px; }
.khio-tutor-end-btn {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--study-border);
    background: var(--bg-card, #fff); color: var(--study-text-tertiary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.khio-tutor-end-btn:hover {
    background: rgba(239, 68, 68, 0.1); color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
.khio-tutor-end-btn i { width: 18px; height: 18px; }

/* ── Messages Area ── */
.khio-tutor-messages {
    flex: 1; overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    background: var(--bg-base, #f5f5f5);
    border-left: 1px solid var(--study-border);
    border-right: 1px solid var(--study-border);
    scroll-behavior: smooth;
}
.tutor-msg {
    display: flex; gap: 10px; max-width: 85%;
    animation: tutorMsgIn .25s ease;
}
@keyframes tutorMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.tutor-msg-ai { align-self: flex-start; }
.tutor-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.tutor-msg-avatar {
    width: 32px; height: 32px; border-radius: 10px;
    background: rgba(239, 68, 68, 0.1);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.tutor-msg-avatar i { width: 16px; height: 16px; color: #ef4444; }

.tutor-msg-bubble {
    padding: 12px 16px; border-radius: 16px;
    font-size: 14px; line-height: 1.65;
    word-break: break-word;
}
.tutor-msg-bubble-ai {
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    color: var(--study-text);
    border-top-left-radius: 4px;
}
.tutor-msg-bubble-ai p { margin: 0 0 8px; }
.tutor-msg-bubble-ai p:last-child { margin-bottom: 0; }
.tutor-msg-bubble-ai strong { color: var(--study-text); }
.tutor-msg-bubble-ai ul, .tutor-msg-bubble-ai ol { margin: 4px 0; padding-left: 20px; }
.tutor-msg-bubble-ai li { margin-bottom: 4px; }

.tutor-msg-bubble-user {
    background: var(--study-accent, #ef4444);
    color: #fff;
    border-top-right-radius: 4px;
}

/* Typing indicator */
.tutor-typing .tutor-typing-dots,
.podcast-ask-status .tutor-typing-dots {
    display: inline-flex; gap: 4px; padding: 4px 0;
}
.tutor-typing-dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--study-text-tertiary);
    animation: tutorDot 1.2s infinite ease-in-out;
}
.tutor-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.tutor-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tutorDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}
/* Phase-specific loading label above the typing dots */
.tutor-typing-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--study-text-secondary, #555);
    margin-bottom: 4px;
    letter-spacing: 0.01em;
    line-height: 1.35;
    animation: tutorLoadingLabelFade 0.25s ease-out;
}
@keyframes tutorLoadingLabelFade {
    from { opacity: 0; transform: translateY(-2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════
   VOICE MODE
   ══════════════════════════════════════ */
.khio-tutor-voice-area {
    padding: 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center;
    gap: 10px;
}

/* Big mic button */
.tutor-mic-btn {
    width: 80px; height: 80px; border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.3);
    background: #ef4444; color: #fff;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all .2s; position: relative;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}
.tutor-mic-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(239, 68, 68, 0.4);
}
.tutor-mic-btn:disabled {
    opacity: 0.4; cursor: default; transform: none;
}
.tutor-mic-btn i { width: 28px; height: 28px; }

/* Recording state */
.tutor-mic-btn.recording {
    background: #dc2626;
    border-color: rgba(220, 38, 38, 0.5);
    animation: tutorMicGlow 1.5s infinite ease-in-out;
}
@keyframes tutorMicGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 4px 40px rgba(239, 68, 68, 0.6), 0 0 60px rgba(239, 68, 68, 0.2); }
}

/* Pulse ring behind mic while recording */
.tutor-mic-pulse {
    position: absolute; inset: -8px;
    border-radius: 50%;
    border: 2px solid rgba(239, 68, 68, 0.4);
    animation: tutorPulse 1.5s infinite ease-out;
    pointer-events: none;
}
@keyframes tutorPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Busy state (thinking/speaking) */
.tutor-mic-btn.busy {
    background: var(--study-text-tertiary, #999);
    border-color: var(--study-border);
    box-shadow: none;
}

/* Status text */
.tutor-voice-status {
    font-size: 14px; font-weight: 700;
    color: var(--study-text); text-align: center;
}
.tutor-voice-hint {
    font-size: 12px; color: var(--study-text-tertiary);
    text-align: center; min-height: 16px;
}

/* Live transcript bubble */
.tutor-live-transcript {
    width: 100%; padding: 10px 14px;
    background: var(--bg-base, #f5f5f5);
    border: 1px solid var(--study-border);
    border-radius: 12px;
    font-size: 14px; line-height: 1.5;
    color: var(--study-text-secondary);
    max-height: 80px; overflow-y: auto;
    animation: tutorMsgIn .2s ease;
}

/* Text fallback below voice controls */
.tutor-text-fallback {
    width: 100%; margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--study-border);
}

/* ── Text-only Input Area ── */
.khio-tutor-input-area {
    padding: 16px 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}
.khio-tutor-input-row {
    display: flex; gap: 10px; align-items: flex-end;
}
.khio-tutor-input {
    flex: 1; padding: 12px 16px;
    border: 1.5px solid var(--study-border);
    border-radius: 14px;
    font-size: 15px; font-family: inherit;
    background: var(--bg-base, #f5f5f5);
    color: var(--study-text);
    resize: none; outline: none;
    min-height: 20px; max-height: 120px;
    line-height: 1.5;
    transition: border-color .15s;
}
.khio-tutor-input:focus { border-color: var(--study-accent); }
.khio-tutor-input:disabled { opacity: 0.5; }

.khio-tutor-send-btn {
    width: 44px; height: 44px; border-radius: 14px;
    border: none; background: #ef4444; color: #fff;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    flex-shrink: 0; transition: all .15s;
}
.khio-tutor-send-btn:hover { opacity: 0.85; transform: scale(1.04); }
.khio-tutor-send-btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.khio-tutor-send-btn i { width: 18px; height: 18px; }

/* ── Summary Screen ── */
.khio-tutor-summary {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; flex: 1;
    padding: 40px 24px;
}

/* ══════════════════════════════════════
   VOICE CONVERSATION MODE
   ══════════════════════════════════════ */

/* Full-screen conversational layout */
.tutor-voice-session .khio-tutor-header {
    border-radius: 16px 16px 0 0;
}

.tutor-convo-area {
    flex: 1; display: flex; flex-direction: column;
    align-items: stretch; justify-content: center;
    padding: 24px 20px 24px;
    background: var(--bg-base, #f5f5f5);
    border-left: 1px solid var(--study-border);
    border-right: 1px solid var(--study-border);
    overflow-y: auto; gap: 20px;
    position: relative;
    min-height: 0;
}

/* ==== New full-space stage layout (bot + status + bubble below) ==== */
.tutor-stage {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 36px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 16px 40px;
}
.tutor-stage .tutor-bot {
    width: 320px; height: 320px;
    flex-shrink: 0;
}
/* Scale the inner body + SVG to match the larger stage container, otherwise
   the robot face sits tiny inside an empty halo. */
.tutor-stage .tutor-bot-body {
    width: 240px; height: 240px;
    border-width: 3px;
}
.tutor-stage .tutor-bot-svg {
    width: 170px; height: 170px;
}
.tutor-stage .tutor-bot-wave { inset: 18px; }
.tutor-stage-status {
    font-size: 16px; font-weight: 700;
    color: var(--study-text-secondary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
}
.tutor-stage-bubble {
    width: 100%;
    max-width: 1080px;
    min-height: 160px;
    padding: 28px 36px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 24px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
    display: flex; flex-direction: column;
    gap: 10px;
    animation: tutorMsgIn .3s ease;
    position: relative;
}
.tutor-stage-bubble-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--study-text-tertiary);
}
.tutor-stage-bubble-text {
    font-size: 20px;
    line-height: 1.65;
    color: var(--study-text);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 340px;
    overflow-y: auto;
}
.tutor-stage-bubble-user {
    color: var(--study-text);
    font-weight: 500;
}
.tutor-stage-bubble-ai {
    color: var(--study-text);
}
.tutor-stage-bubble-ai::after {
    content: '▍';
    display: inline-block;
    margin-left: 2px;
    color: var(--study-accent, #ef4444);
    animation: tutorCaretBlink 1s steps(2) infinite;
    opacity: 0.7;
}
.tutor-stage-bubble-hint {
    font-size: 17px;
    color: var(--study-text-tertiary);
    text-align: center;
    padding: 16px 0;
    font-style: italic;
    line-height: 1.5;
}
.tutor-stage-bubble-dots {
    display: flex; justify-content: center; align-items: center;
    gap: 8px; padding: 20px 0;
}
.tutor-stage-bubble-dots span {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--study-accent, #ef4444);
    opacity: 0.35;
    animation: tutorDotPulse 1.2s ease-in-out infinite;
}
.tutor-stage-bubble-dots span:nth-child(2) { animation-delay: 0.18s; }
.tutor-stage-bubble-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes tutorDotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.25); }
}
@keyframes tutorCaretBlink {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 0; }
}

/* "Ask a question" mid-lecture pill, pauses the teach AI so the student
 * can interject. Only renders while the teach AI is actively speaking. */
.tutor-ask-question-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 14px auto 0;
    padding: 11px 22px;
    background: var(--study-surface, #ffffff);
    color: var(--study-text-primary, #1f2937);
    border: 1.5px solid var(--study-border, rgba(0,0,0,0.1));
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.tutor-ask-question-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    border-color: var(--study-accent, #ef4444);
    background: var(--study-bg-soft, #fafafa);
}
.tutor-ask-question-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.tutor-ask-question-btn i {
    width: 16px;
    height: 16px;
    color: var(--study-accent, #ef4444);
}

/* Mobile: shrink bot, tighter padding */
@media (max-width: 640px) {
    .tutor-stage { gap: 16px; padding: 6px 4px; }
    .tutor-stage .tutor-bot { width: 190px; height: 190px; }
    .tutor-stage .tutor-bot-body { width: 150px; height: 150px; }
    .tutor-stage .tutor-bot-svg { width: 110px; height: 110px; }
    .tutor-stage-bubble {
        padding: 16px 18px;
        min-height: 90px;
        border-radius: 16px;
    }
    .tutor-stage-bubble-text { font-size: 16px; max-height: 220px; }
    .tutor-stage-bubble-hint { font-size: 14px; }
}

/* Latest AI message, prominent display */
.tutor-convo-response {
    max-width: 560px; width: 100%;
    text-align: center;
    animation: tutorMsgIn .3s ease;
}
.tutor-convo-response-text {
    font-size: 16px; line-height: 1.7;
    color: var(--study-text);
    padding: 16px 20px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 16px;
    text-align: left;
    max-height: 200px; overflow-y: auto;
}
.tutor-convo-response-text p { margin: 0 0 8px; }
.tutor-convo-response-text p:last-child { margin: 0; }
.tutor-convo-response-text strong { color: var(--study-text); }

/* Center bot area */
.tutor-convo-center {
    display: flex; flex-direction: column;
    align-items: center; gap: 14px;
}
.tutor-convo-status {
    font-size: 15px; font-weight: 700;
    color: var(--study-text-secondary);
    letter-spacing: 0.02em;
    margin-top: 4px;
}
.tutor-convo-hint {
    font-size: 12px;
    color: var(--study-text-tertiary);
    letter-spacing: 0.01em;
    text-align: center;
    min-height: 14px;
}

/* ==== Bot character (central UI) ==== */
.tutor-bot {
    width: 168px; height: 168px; border-radius: 50%;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    cursor: pointer;
    color: var(--study-accent, #ef4444);
    padding: 0;
    transition: transform 0.2s ease;
}
.tutor-bot:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.tutor-bot:disabled { cursor: default; opacity: 0.8; }

/* Soft halo behind the bot, breathes in every state */
.tutor-bot-halo {
    position: absolute; inset: 0; border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
        rgba(239, 68, 68, 0.18) 0%,
        rgba(239, 68, 68, 0.08) 40%,
        transparent 70%);
    animation: tutorBotHaloBreathe 3.2s infinite ease-in-out;
    z-index: 0;
}
@keyframes tutorBotHaloBreathe {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.05); opacity: 1; }
}

/* Soundwave rings, hidden by default, shown when listening/speaking */
.tutor-bot-wave {
    position: absolute; inset: 10px;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

/* Bot body, invisible positioning wrapper. No border, no fill, no shadow.
   The SVG robot face is the only visible element; the halo behind provides
   the soft glow. Keeping the wrapper so state classes still have a hook. */
.tutor-bot-body {
    position: relative; z-index: 2;
    width: 120px; height: 120px; border-radius: 50%;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex; align-items: center; justify-content: center;
}
.tutor-bot-svg {
    width: 82px; height: 82px;
    color: var(--study-accent, #ef4444);
    transition: color 0.25s;
}

/* State badge, small pill in the corner of the bot showing current action */
.tutor-bot-badge {
    position: absolute;
    bottom: 6px; right: 6px;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--study-accent, #ef4444);
    color: var(--study-accent, #ef4444);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
    z-index: 3;
}
.tutor-bot-badge i { width: 16px; height: 16px; }

/* ── STATES ── */

/* Idle: slow halo, static face */
.tutor-bot-idle .tutor-bot-eye {
    animation: tutorBotBlink 5s infinite ease-in-out;
}

/* Listening: pulsing waves outward, mouth closed, eyes attentive */
.tutor-bot-listening .tutor-bot-body {
    animation: tutorBotListenPulse 1.6s infinite ease-in-out;
}
.tutor-bot-listening .tutor-bot-wave {
    animation: tutorBotWaveOut 1.8s infinite ease-out;
}
.tutor-bot-listening .tutor-bot-wave-1 { animation-delay: 0s; }
.tutor-bot-listening .tutor-bot-wave-2 { animation-delay: 0.6s; }
.tutor-bot-listening .tutor-bot-wave-3 { animation-delay: 1.2s; }
@keyframes tutorBotWaveOut {
    0% { transform: scale(0.85); opacity: 0.55; }
    100% { transform: scale(1.45); opacity: 0; }
}
@keyframes tutorBotListenPulse {
    0%, 100% { box-shadow: 0 8px 28px rgba(239, 68, 68, 0.25); }
    50% { box-shadow: 0 8px 40px rgba(239, 68, 68, 0.5); }
}

/* Speaking: mouth stays open, gentle nod */
.tutor-bot-speaking .tutor-bot-body {
    animation: tutorBotNod 1s infinite ease-in-out;
}
.tutor-bot-speaking .tutor-bot-svg { color: #dc2626; }
/* Mouth stays open the whole time while speaking, no flapping animation. */
.tutor-bot-speaking .tutor-bot-mouth-line { opacity: 0; }
.tutor-bot-speaking .tutor-bot-mouth-open { opacity: 1; }
@keyframes tutorBotNod {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-2px) scale(1.015); }
}
/* Gentle outward waves while speaking, softer than listening */
.tutor-bot-speaking .tutor-bot-wave {
    border-color: rgba(249, 115, 22, 0.4);
    animation: tutorBotWaveOut 2.2s infinite ease-out;
}
.tutor-bot-speaking .tutor-bot-wave-1 { animation-delay: 0s; }
.tutor-bot-speaking .tutor-bot-wave-2 { animation-delay: 0.7s; }
.tutor-bot-speaking .tutor-bot-wave-3 { animation-delay: 1.4s; }

/* Thinking: antenna dot pulses, eyes look up-and-left */
.tutor-bot-thinking .tutor-bot-svg { color: #64748b; }
.tutor-bot-thinking .tutor-bot-antenna-dot,
.tutor-bot-thinking .tutor-bot-antenna {
    animation: tutorBotAntennaPulse 1.2s infinite ease-in-out;
}
@keyframes tutorBotAntennaPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.tutor-bot-thinking .tutor-bot-eye {
    animation: tutorBotEyeThink 1.4s infinite ease-in-out;
}
@keyframes tutorBotEyeThink {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-1.2px, -1.2px); }
}
.tutor-bot-thinking .tutor-bot-badge {
    border-color: #64748b;
    color: #64748b;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.2);
}
.tutor-bot-thinking .tutor-bot-badge i {
    animation: tutorBotSpin 1s linear infinite;
}
@keyframes tutorBotSpin { to { transform: rotate(360deg); } }

/* Idle blink (used in all states where eyes aren't overridden) */
@keyframes tutorBotBlink {
    0%, 92%, 100% { transform: scaleY(1); }
    95%, 97% { transform: scaleY(0.1); }
}
.tutor-bot-eye { transform-origin: center; transform-box: fill-box; }

/* Legacy orb (replaced by .tutor-bot, kept to avoid breaking old references) */
.tutor-orb { display: none !important; }
.tutor-orb-legacy {
    width: 100px; height: 100px;
    border-radius: 50%;
    position: relative;
    display: flex; align-items: center; justify-content: center;
}

/* Orb button */
.tutor-orb-btn {
    width: 80px; height: 80px; border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.3);
    background: #ef4444; color: #fff;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all .2s;
    position: relative; z-index: 2;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}
.tutor-orb-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 6px 28px rgba(239, 68, 68, 0.4);
}
.tutor-orb-btn:disabled {
    opacity: 0.4; cursor: default; transform: none;
}
.tutor-orb-btn i { width: 28px; height: 28px; }

/* Animated rings behind the orb */
.tutor-orb-rings {
    position: absolute; inset: -10px;
    pointer-events: none;
}
.tutor-orb-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all .4s ease;
}

/* Idle state: subtle glow */
.tutor-orb-idle .tutor-orb-btn {
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2);
}

/* Listening state: pulsing rings */
.tutor-orb-listening .tutor-orb-btn {
    background: #dc2626;
    border-color: rgba(220, 38, 38, 0.5);
    animation: tutorOrbPulse 1.5s infinite ease-in-out;
}
.tutor-orb-listening .tutor-orb-ring {
    border-color: rgba(239, 68, 68, 0.3);
}
.tutor-orb-listening .tutor-orb-ring:nth-child(1) {
    animation: tutorRingPulse 2s infinite ease-out;
}
.tutor-orb-listening .tutor-orb-ring:nth-child(2) {
    animation: tutorRingPulse 2s 0.4s infinite ease-out;
}
.tutor-orb-listening .tutor-orb-ring:nth-child(3) {
    animation: tutorRingPulse 2s 0.8s infinite ease-out;
}

@keyframes tutorOrbPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 4px 40px rgba(239, 68, 68, 0.5), 0 0 60px rgba(239, 68, 68, 0.15); }
}
@keyframes tutorRingPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Speaking state: smooth wave */
.tutor-orb-speaking .tutor-orb-btn {
    background: linear-gradient(135deg, #ef4444, #f97316);
    border-color: rgba(249, 115, 22, 0.4);
    animation: tutorOrbSpeak 1s infinite ease-in-out;
}
.tutor-orb-speaking .tutor-orb-ring {
    border-color: rgba(249, 115, 22, 0.2);
    animation: tutorRingSpeakPulse 1.2s infinite ease-in-out;
}
.tutor-orb-speaking .tutor-orb-ring:nth-child(2) { animation-delay: 0.2s; }
.tutor-orb-speaking .tutor-orb-ring:nth-child(3) { animation-delay: 0.4s; }

@keyframes tutorOrbSpeak {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
@keyframes tutorRingSpeakPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.15); opacity: 0.1; }
}

/* Thinking state: rotating glow */
.tutor-orb-thinking .tutor-orb-btn {
    background: var(--study-text-tertiary, #999);
    border-color: var(--study-border);
    box-shadow: none;
    animation: tutorOrbThink 1.5s infinite linear;
}
@keyframes tutorOrbThink {
    0% { box-shadow: 0 0 20px rgba(150, 150, 150, 0.2); }
    50% { box-shadow: 0 0 30px rgba(150, 150, 150, 0.4); }
    100% { box-shadow: 0 0 20px rgba(150, 150, 150, 0.2); }
}

/* Live transcript (what user is saying) */
.tutor-convo-transcript {
    max-width: 480px; width: 100%;
    padding: 10px 16px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 12px;
    font-size: 14px; line-height: 1.5;
    color: var(--study-text-secondary);
    text-align: center;
    max-height: 60px; overflow-y: auto;
    animation: tutorMsgIn .2s ease;
}

/* Footer: history toggle + text fallback */
.tutor-convo-footer {
    padding: 12px 16px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}
.tutor-convo-type-row {
    display: flex; gap: 10px; align-items: flex-end;
}
.tutor-convo-input {
    flex: 1; font-size: 14px;
    padding: 10px 14px;
    border-radius: 12px;
}

/* History toggle button */
.tutor-vh-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; margin-bottom: 8px;
    border-radius: 8px; border: 1px solid var(--study-border);
    background: var(--bg-base, #f5f5f5);
    color: var(--study-text-tertiary);
    font-size: 12px; font-weight: 700;
    cursor: pointer; transition: all .15s;
    font-family: inherit;
}
.tutor-vh-toggle:hover, .tutor-vh-toggle.active {
    color: var(--study-text); border-color: var(--study-accent);
}
.tutor-vh-toggle i { width: 14px; height: 14px; }

/* History panel, floats from the bottom of the voice session as an overlay */
.tutor-voice-session .tutor-vh-panel {
    position: absolute;
    left: 16px; right: 16px; bottom: 16px;
    max-height: 50%; overflow-y: auto;
    padding: 14px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--study-border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    z-index: 10;
}
.tutor-voice-session { position: relative; }
/* Fallback (non-voice) styling kept for any legacy call sites */
.tutor-vh-panel {
    max-height: 160px; overflow-y: auto;
    margin-bottom: 10px; padding: 8px;
    background: var(--bg-base, #f5f5f5);
    border-radius: 10px;
    display: flex; flex-direction: column; gap: 6px;
}
.tutor-vh-msg {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px; line-height: 1.4;
}
.tutor-vh-ai { background: var(--bg-card, #fff); border: 1px solid var(--study-border); }
.tutor-vh-user { background: rgba(239, 68, 68, 0.08); }
.tutor-vh-label {
    font-weight: 800; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.04em;
    margin-right: 6px;
}
.tutor-vh-ai .tutor-vh-label { color: var(--study-accent, #ef4444); }
.tutor-vh-user .tutor-vh-label { color: var(--study-text-secondary); }
.tutor-vh-text { color: var(--study-text-secondary); }
.tutor-vh-empty {
    text-align: center; padding: 12px;
    color: var(--study-text-tertiary); font-size: 13px;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .khio-tutor-wrap {
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
    }
    .khio-tutor-header { padding: 12px 16px; }
    .khio-tutor-messages { padding: 14px; gap: 12px; }
    .tutor-msg { max-width: 92%; }
    .tutor-msg-bubble { padding: 10px 14px; font-size: 14px; }
    .khio-tutor-input-area { padding: 12px 14px; }
    .khio-tutor-input { font-size: 16px; padding: 10px 14px; }
    .khio-tutor-voice-area { padding: 16px; }
    .tutor-mic-btn { width: 72px; height: 72px; }
    .tutor-mic-btn i { width: 26px; height: 26px; }
    .khio-tutor-welcome { padding: 30px 20px; }
    .khio-tutor-welcome-title { font-size: 22px; }
    .khio-tutor-start-btn { padding: 14px 28px; font-size: 15px; }
    .tutor-text-fallback .khio-tutor-input { font-size: 16px; }

    /* Voice conversation mobile */
    .tutor-convo-area { padding: 16px 14px 12px; gap: 16px; }
    .tutor-convo-response-text { font-size: 15px; padding: 12px 16px; max-height: 160px; }
    .tutor-bot { width: 148px; height: 148px; }
    .tutor-bot-body { width: 108px; height: 108px; }
    .tutor-bot-svg { width: 72px; height: 72px; }
    .tutor-bot-badge { width: 30px; height: 30px; }
    .tutor-bot-badge i { width: 14px; height: 14px; }
    .tutor-convo-footer { padding: 10px 12px; }
    .tutor-convo-input { font-size: 16px; }
}

/* ── Teach vs Test mode segmented control (welcome screen) ── */
.tutor-mode-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px auto 14px;
    max-width: 540px;
    width: 100%;
}
.tutor-mode-seg-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 16px;
    border: 1.5px solid var(--study-border, rgba(0,0,0,0.08));
    background: var(--study-surface, #fff);
    color: var(--study-text, #0f172a);
    border-radius: 14px;
    cursor: pointer;
    transition: all .18s ease;
    text-align: left;
    font-family: inherit;
}
.tutor-mode-seg-btn i {
    width: 18px;
    height: 18px;
    color: var(--study-text-secondary, #64748b);
}
.tutor-mode-seg-btn .tutor-mode-seg-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.tutor-mode-seg-btn .tutor-mode-seg-sub {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--study-text-tertiary, #94a3b8);
    line-height: 1.35;
}
.tutor-mode-seg-btn:hover {
    border-color: var(--study-accent, #c1724e);
}
.tutor-mode-seg-btn.active {
    border-color: var(--study-accent, #c1724e);
    background: color-mix(in srgb, var(--study-accent, #c1724e) 8%, transparent);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--study-accent, #c1724e) 20%, transparent);
}
.tutor-mode-seg-btn.active i,
.tutor-mode-seg-btn.active .tutor-mode-seg-title {
    color: var(--study-accent, #c1724e);
}

/* Teach config block: scope picker + module checklist */
.tutor-teach-config {
    max-width: 540px;
    width: 100%;
    margin: 0 auto 14px;
    padding: 14px 16px;
    background: var(--study-surface-elev, rgba(0,0,0,0.02));
    border: 1px solid var(--study-border, rgba(0,0,0,0.06));
    border-radius: 14px;
}
.tutor-teach-config-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--study-text-secondary, #475569);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.tutor-teach-scope-seg {
    display: flex;
    gap: 8px;
}
.tutor-teach-scope-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1.5px solid var(--study-border, rgba(0,0,0,0.08));
    background: var(--study-surface, #fff);
    color: var(--study-text, #0f172a);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}
.tutor-teach-scope-btn i { width: 14px; height: 14px; }
.tutor-teach-scope-btn:hover:not([disabled]) {
    border-color: var(--study-accent, #c1724e);
}
.tutor-teach-scope-btn.active {
    border-color: var(--study-accent, #c1724e);
    color: var(--study-accent, #c1724e);
    background: color-mix(in srgb, var(--study-accent, #c1724e) 8%, transparent);
}
.tutor-teach-scope-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}
.tutor-teach-scope-hint {
    font-size: 12px;
    color: var(--study-text-tertiary, #94a3b8);
    margin-top: 8px;
}

.tutor-teach-modlist-wrap {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--study-border, rgba(0,0,0,0.08));
}
.tutor-teach-modlist-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.tutor-teach-modlist-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--study-text-secondary, #475569);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.tutor-teach-modlist-actions { display: flex; gap: 6px; }
.tutor-teach-mini-btn {
    padding: 4px 10px;
    border: 1px solid var(--study-border, rgba(0,0,0,0.08));
    background: var(--study-surface, #fff);
    color: var(--study-text-secondary, #475569);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s ease;
    font-family: inherit;
}
.tutor-teach-mini-btn:hover {
    color: var(--study-accent, #c1724e);
    border-color: var(--study-accent, #c1724e);
}
.tutor-mod-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}
.tutor-mod-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s ease;
}
.tutor-mod-item:hover { background: rgba(0,0,0,0.03); }
.tutor-mod-check {
    width: 16px; height: 16px;
    accent-color: var(--study-accent, #c1724e);
    cursor: pointer;
    flex-shrink: 0;
}
.tutor-mod-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--study-accent, #c1724e) 10%, transparent);
    color: var(--study-accent, #c1724e);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.tutor-mod-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--study-text, #0f172a);
    line-height: 1.35;
    flex: 1;
}

/* ── Teach-mode banner (in chat view) ── */
.tutor-teach-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--study-accent, #c1724e) 6%, transparent);
    border-bottom: 1px solid var(--study-border, rgba(0,0,0,0.06));
}
.tutor-teach-banner-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.tutor-teach-banner-kicker {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--study-accent, #c1724e);
}
.tutor-teach-banner-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--study-text, #0f172a);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tutor-teach-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 10px;
    border: 1px solid var(--study-border, rgba(0,0,0,0.08));
    background: var(--study-surface, #fff);
    color: var(--study-text, #0f172a);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .14s ease;
    font-family: inherit;
}
.tutor-teach-nav-btn i { width: 14px; height: 14px; }
.tutor-teach-nav-btn:hover:not([disabled]) {
    border-color: var(--study-accent, #c1724e);
    color: var(--study-accent, #c1724e);
}
.tutor-teach-nav-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}
.tutor-teach-nav-btn-primary {
    background: var(--study-accent, #c1724e);
    color: #fff;
    border-color: var(--study-accent, #c1724e);
}
.tutor-teach-nav-btn-primary:hover:not([disabled]) {
    background: color-mix(in srgb, var(--study-accent, #c1724e) 90%, #000);
    color: #fff;
}
.tutor-teach-nav-btn-primary[disabled] {
    background: var(--study-accent, #c1724e);
    color: #fff;
}
.tutor-teach-banner-notes {
    justify-content: center;
    color: var(--study-accent, #c1724e);
    font-size: 12.5px;
    font-weight: 600;
}

.khio-tutor-past-mini {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--study-accent, #c1724e);
    background: color-mix(in srgb, var(--study-accent, #c1724e) 12%, transparent);
    border-radius: 6px;
    vertical-align: middle;
}

@media (max-width: 640px) {
    .tutor-mode-seg { grid-template-columns: 1fr; gap: 8px; }
    .tutor-teach-config { margin-left: 12px; margin-right: 12px; }
    .tutor-teach-banner { padding: 8px 12px; }
    .tutor-teach-banner-title { font-size: 12.5px; }
}

/* ══════════════════════════════════════
   WELCOME SCREEN, Centered, theme-matched layout
   ══════════════════════════════════════ */
.khio-tutor-wrap.tutor-welcome-active .khio-tutor-welcome {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 44px 32px 32px;
    text-align: left;
    align-items: stretch;
    justify-content: flex-start;
    flex: none;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Hero block, icon + title + description, centered */
.tutor-welcome-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
    margin-bottom: 4px;
}
.tutor-welcome-hero .khio-tutor-welcome-icon {
    width: 84px; height: 84px;
    border-radius: 24px;
    margin: 0 auto 22px;
    background: linear-gradient(135deg,
        rgba(239, 68, 68, 0.18) 0%,
        rgba(239, 68, 68, 0.10) 100%);
    box-shadow:
        0 0 0 1px rgba(239, 68, 68, 0.18),
        0 12px 32px -10px rgba(239, 68, 68, 0.30);
    display: flex; align-items: center; justify-content: center;
}
.tutor-welcome-hero .khio-tutor-welcome-icon i {
    width: 38px; height: 38px;
    color: #ef4444;
}
.tutor-welcome-hero .khio-tutor-welcome-title {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin: 0 0 14px;
    color: var(--study-text, #0f172a);
    text-align: center;
}
.tutor-welcome-hero .khio-tutor-welcome-desc {
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
    font-size: 16px;
    line-height: 1.6;
    color: var(--study-text-secondary, #64748b);
}

/* Three big mode cards side-by-side, full width of the container.
   James 2026-05-17: was 2 columns (Test Me / Teach Me), added a third
   for Podcast so the standalone Podcast tab can retire and the user
   reaches it only from inside Khio Tutor. */
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg {
    margin: 8px 0 0;
    max-width: none;
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
/* Per-mode icon tint, Test stays red (existing), Teach goes blue,
   Podcast goes Khio rust so the three cards read as distinct paths. */
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="teach"] .tutor-mode-seg-icon {
    background: rgba(56, 122, 219, 0.12);
    color: #387adb;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="teach"] .tutor-mode-seg-icon i {
    color: #387adb;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="teach"] .tutor-mode-seg-cta {
    color: #387adb;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="podcast"] .tutor-mode-seg-icon {
    background: rgba(193, 114, 78, 0.14);
    color: #c1724e;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="podcast"] .tutor-mode-seg-icon i {
    color: #c1724e;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn[data-mode="podcast"] .tutor-mode-seg-cta {
    color: #c1724e;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 22px 22px 20px;
    border-radius: 16px;
    position: relative;
    background: var(--bg-card, #fff);
}
.tutor-mode-seg-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    margin-bottom: 6px;
}
.tutor-mode-seg-icon i {
    width: 20px; height: 20px;
    color: #ef4444;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn .tutor-mode-seg-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--study-text, #0f172a);
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn .tutor-mode-seg-sub {
    font-size: 13.5px;
    line-height: 1.55;
    font-weight: 500;
    color: var(--study-text-secondary, #64748b);
}
.tutor-mode-seg-cta {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
    letter-spacing: 0.01em;
}
.tutor-mode-seg-btn.active .tutor-mode-seg-cta {
    color: #ef4444;
    opacity: 0.85;
}

/* Active card: just a slight indicator that it's picked, thin red
   outline, no bg tint, no glow. James: "I dont want it to be that red
   just like a slight thing showing which ones picked." */
.khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn.active {
    border-color: rgba(239, 68, 68, 0.55);
    border-width: 1.5px;
    background: var(--bg-card, #fff);
    box-shadow: none;
}

/* Teach config (below the cards, only shown when Teach is active) */
.khio-tutor-wrap.tutor-welcome-active .tutor-teach-config {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 20px 22px;
}
.khio-tutor-wrap.tutor-welcome-active .tutor-mod-list {
    max-height: 300px;
}

/* Session starter panel, the "Start Your Interactive Session" card */
.tutor-session-panel {
    width: 100%;
    padding: 8px 0 0;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}
.tutor-session-panel-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--study-text, #0f172a);
    letter-spacing: -0.01em;
    margin-bottom: 2px;
    /* Decorative divider lines on each side, sparkle icon stays inline.
       Matches James's reference screenshot: "✨ Start Your Interactive
       Session" with horizontal hairlines stretching to the panel edges. */
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}
.tutor-session-panel-title::before,
.tutor-session-panel-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, var(--study-border, rgba(0,0,0,0.1)) 80%, transparent);
}
.tutor-session-panel-title i {
    width: 16px; height: 16px;
    color: var(--study-text-secondary, rgba(0,0,0,0.55));
    flex-shrink: 0;
    stroke-width: 2;
}
.tutor-session-panel-title span {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Override the original flex-column welcome-modes inside the session panel */
.tutor-session-panel .khio-tutor-welcome-modes {
    width: 100%;
    max-width: 420px;
    align-items: stretch;
    gap: 10px;
}
.tutor-session-panel .khio-tutor-start-btn {
    justify-content: center;
    width: 100%;
}
.tutor-session-panel .khio-tutor-start-text {
    padding: 10px 22px;
}

/* Voice picker inside the session panel */
.tutor-session-panel .tutor-voice-picker {
    margin: 6px 0 0;
    padding: 0;
    border: none;
    background: transparent;
    text-align: center;
    width: 100%;
}
.tutor-session-panel .tutor-voice-picker-label {
    text-align: center;
    margin-bottom: 10px;
    color: var(--study-text-tertiary, #94a3b8);
    /* Same divider treatment as the panel title, hairlines on each side
       of "Select Tutor Voice" so the chip row reads as its own section. */
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}
.tutor-session-panel .tutor-voice-picker-label::before,
.tutor-session-panel .tutor-voice-picker-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, var(--study-border, rgba(0,0,0,0.1)) 70%, transparent);
}
.tutor-session-panel .tutor-voice-picker-chips {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* Brave-browser warning inside the voice picker */
.tutor-voice-brave-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px auto 0;
    padding: 10px 12px;
    max-width: 480px;
    background: color-mix(in srgb, #f59e0b 10%, transparent);
    border: 1px solid color-mix(in srgb, #f59e0b 30%, transparent);
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--study-text-secondary, #475569);
    text-align: left;
}
.tutor-voice-brave-note i {
    width: 14px; height: 14px;
    color: #d97706;
    margin-top: 2px;
    flex-shrink: 0;
}
.tutor-voice-brave-note code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Past sessions, full-width card grid at the bottom */
.khio-tutor-wrap.tutor-welcome-active .khio-tutor-past {
    max-width: none;
    width: 100%;
    margin: 6px 0 0;
    padding: 20px 0 0;
    border-top: 1px solid var(--study-border, rgba(0,0,0,0.08));
    text-align: left;
}
.khio-tutor-wrap.tutor-welcome-active .khio-tutor-past-label {
    text-align: left;
    margin-bottom: 12px;
}
.khio-tutor-wrap.tutor-welcome-active .khio-tutor-past-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}

/* Mobile: stack cards, tighten padding */
@media (max-width: 720px) {
    .khio-tutor-wrap.tutor-welcome-active .khio-tutor-welcome {
        padding: 28px 18px 24px;
        gap: 18px;
    }
    .tutor-welcome-hero .khio-tutor-welcome-title { font-size: 24px; }
    .khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .khio-tutor-wrap.tutor-welcome-active .tutor-mode-seg-btn {
        padding: 18px 18px 16px;
    }
    .tutor-session-panel { padding: 20px 18px; }
    .khio-tutor-wrap.tutor-welcome-active .tutor-teach-config { padding: 16px 18px; }
}
