:root {
    --brand-primary: #222f6e;
    --brand-secondary: #2563eb;
    --brand-accent: #eac000;
    --brand-hover: #1a2a60;
    --surface: #ffffff;
    --surface-alt: #f8fbff;
    --border: #e4e9f2;
    --text-main: #1e2a4a;
    --text-muted: #5f687b;
    --text-light: #9ca3af;
    --shadow-sm: 0 2px 8px rgba(34, 47, 110, 0.07);
    --shadow-md: 0 6px 18px rgba(34, 47, 110, 0.1);
}

/* ── Hero ── */
.tai-hero {
    background: linear-gradient(135deg, var(--brand-primary) 0%, #1e3a8a 100%);
    color: #fff;
    padding: 1.8rem 0 1.5rem;
}

.tai-hero-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.tai-breadcrumb {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.tai-breadcrumb a { color: rgba(255,255,255,0.75); text-decoration: none; }
.tai-breadcrumb a:hover { color: #fff; }
.tai-breadcrumb .sep { opacity: 0.4; }

.tai-hero-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.5rem;
}

.tai-hero-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tai-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

.tai-badge-ai {
    background: rgba(234,192,0,0.2);
    color: var(--brand-accent);
    border: 1px solid rgba(234,192,0,0.35);
}

.tai-badge-active {
    background: rgba(34,197,94,0.2);
    color: #86efac;
    border: 1px solid rgba(34,197,94,0.3);
}

/* ── Body ── */
.tai-body {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
}

/* ── Panels ── */
.tai-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-sm);
}

.tai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tai-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.tai-panel-title i { color: var(--brand-secondary); }

.tai-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Buttons */
.tai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.tai-btn-ghost {
    background: var(--surface-alt);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.tai-btn-ghost:hover { background: var(--border); color: var(--text-main); text-decoration: none; }

.tai-btn-primary {
    background: var(--brand-primary);
    color: #fff;
}

.tai-btn-primary:hover { background: var(--brand-hover); color: #fff; text-decoration: none; }

.tai-btn-accent {
    background: var(--brand-accent);
    color: #000;
    border-bottom: 2px solid #c9a000;
}

.tai-btn-accent:hover { background: #f0ca00; color: #000; text-decoration: none; }

/* ── Professor AI Player ── */
.tai-professor {
    background: linear-gradient(135deg, var(--surface-alt) 0%, #eef1fb 100%);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    display: none;
}

.tai-professor.visible { display: block; }

.tai-prof-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tai-prof-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.tai-prof-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tai-prof-avatar.speaking::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #4ade80;
    animation: tai-pulse-bar 1s infinite;
}

@keyframes tai-pulse-bar {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.tai-prof-info { flex: 1; }

.tai-prof-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.2rem;
}

.tai-prof-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0;
}

/* Controls */
.tai-controls {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
    gap: 0.25rem;
}

.tai-ctrl-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.tai-ctrl-btn:hover { color: var(--brand-primary); background: var(--surface-alt); }

.tai-play-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 0.5rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tai-play-btn:hover { background: var(--brand-hover); transform: scale(1.05); }

.tai-progress-wrap {
    flex: 1;
    margin: 0 0.5rem;
}

.tai-progress-track {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    margin-bottom: 0.3rem;
}

.tai-progress-fill {
    position: absolute;
    height: 100%;
    background: var(--brand-secondary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.2s;
}

.tai-time-display {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-light);
}

/* Lesson content area */
.tai-lesson-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem;
    font-size: 0.9rem;
    line-height: 1.75;
    min-height: 160px;
    max-height: 380px;
    overflow-y: auto;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.tai-lesson-content .speaking-paragraph {
    background: rgba(34, 47, 110, 0.05);
    border-left: 3px solid var(--brand-secondary);
    padding-left: 0.75rem;
    border-radius: 0 4px 4px 0;
}

.tai-notes-preview {
    background: var(--surface-alt);
    border-left: 3px solid var(--brand-primary);
    border-radius: 0 6px 6px 0;
    padding: 0.65rem 0.9rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.tai-transcript-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.tai-transcript-toggle:hover { background: var(--surface-alt); border-color: var(--brand-primary); color: var(--brand-primary); }

.tai-resource-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.tai-resource-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tai-resource-badge i { color: var(--brand-secondary); }

.tai-resource-badge:hover { background: var(--border); color: var(--text-main); }

/* ── Topics list ── */
.tai-topic-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s;
    cursor: pointer;
}

.tai-topic-item:hover { background: var(--surface-alt); }

.tai-topic-item.tai-locked { opacity: 0.6; cursor: not-allowed; }

.tai-topic-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.tai-topic-num.done { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.tai-topic-num.locked { background: #fef3c7; border-color: #fde68a; color: #92400e; }

.tai-topic-info { flex: 1; min-width: 0; }

.tai-topic-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 0.2rem;
}

.tai-topic-meta {
    font-size: 0.72rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tai-upgrade-pill {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    text-decoration: none;
    flex-shrink: 0;
}

.tai-upgrade-pill:hover { background: var(--brand-accent); color: #000; }

/* Lesson sub-items */
.tai-lesson-items { padding-left: 2rem; margin-bottom: 0.25rem; }

.tai-lesson-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.tai-lesson-item:last-child { border-bottom: none; }
.tai-lesson-item:hover { color: var(--brand-primary); }

.tai-lesson-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(34,47,110,0.08);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.tai-lesson-status {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    margin-left: auto;
    flex-shrink: 0;
}

.tai-status-done { background: #4ade80; color: #fff; }
.tai-status-lock { background: var(--border); color: var(--text-light); }

/* ── Progress bar ── */
.tai-prog-wrap {
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.tai-prog-bar {
    height: 100%;
    background: var(--brand-secondary);
    border-radius: 99px;
    transition: width 0.5s;
}

/* ── AI Chat ── */
.tai-chat-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.tai-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tai-tool-btn:hover {
    background: rgba(34,47,110,0.08);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.tai-chat-messages {
    height: 280px;
    overflow-y: auto;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.tai-msg {
    max-width: 82%;
    padding: 0.65rem 0.9rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.55;
}

.tai-msg-user {
    background: var(--brand-primary);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.tai-msg-ai {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.tai-msg ul { padding-left: 1.2rem; margin: 0.4rem 0 0; }
.tai-msg li { margin-bottom: 0.2rem; }

.tai-msg-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

.tai-chat-input {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.tai-mic-btn {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tai-mic-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.tai-mic-btn.active {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
    animation: tai-pulse-mic 1.5s infinite;
}

@keyframes tai-pulse-mic {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.tai-chat-field {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    background: var(--surface-alt);
    color: var(--text-main);
    transition: border-color 0.2s;
}

.tai-chat-field:focus {
    outline: none;
    border-color: var(--brand-secondary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.tai-send-btn {
    background: var(--brand-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.tai-send-btn:hover { background: var(--brand-hover); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .tai-hero-title { font-size: 1.25rem; }
    .tai-body { padding: 1rem 1rem 3rem; }
    .tai-chat-messages { height: 220px; }
    .tai-lesson-content { max-height: 260px; }
}
