/* ============================================================
   AI蒸馏馆 — 暗色科学实验室主题 v2.0
   ============================================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1a1d2e;
    --bg-hover: #222539;
    --bg-input: #1e2135;
    --border: #2a2d3e;
    --border-hover: #3d4160;
    --text-primary: #e4e6f0;
    --text-secondary: #b0b3c5;
    --text-muted: #6b6f85;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.5rem 1.2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon { font-size: 1.6rem; }
.logo-text { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--accent); color: #fff; }

.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
    padding: 1rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-badge { font-size: 0.85rem; color: var(--text-secondary); }
.btn-logout, .btn-login-side {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    text-align: center;
}
.btn-logout:hover, .btn-login-side:hover { background: var(--bg-hover); color: var(--text-primary); }

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 2rem;
    max-width: 1200px;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.page-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.2rem;
}

.card-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-more {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.card-more:hover { color: var(--accent-light); }

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1.5rem;
    text-align: center;
}

.stat-num {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-light);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ============================================================
   Home Grid
   ============================================================ */
.home-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.2rem;
}

/* ============================================================
   Person Mini List
   ============================================================ */
.person-list-mini {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.person-row-mini {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-secondary);
    transition: background 0.15s;
}

.person-row-mini:hover { background: var(--border); color: var(--text-primary); }

.person-avatar-mini {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
}

.person-name-mini { flex: 1; font-size: 0.9rem; }

.person-progress-mini {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.8rem; color: var(--text-muted);
}

.mini-progress-bar {
    width: 60px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.mini-progress-bar span {
    display: block; height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s;
}

/* ============================================================
   Training Mini List
   ============================================================ */
.training-list-mini {
    display: flex; flex-direction: column; gap: 0.5rem;
}

.training-row-mini {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
    color: #fff;
}

.btn-primary { background: var(--accent); }
.btn-primary:hover { background: #6d28d9; color: #fff; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1.05rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* ============================================================
   Tags
   ============================================================ */
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.tag-lg { padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.tag-active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent-light); }
.tag-strength { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.tag-move { border-color: var(--accent); color: var(--accent-light); background: var(--accent-glow); }
.tag-done { border-color: var(--success); color: var(--success); }

.training-mode-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: var(--accent-glow);
    color: var(--accent-light);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 100px; }
.status-done { background: var(--success-bg); color: var(--success); }
.status-running { background: var(--warning-bg); color: var(--warning); }

/* ============================================================
   Person Grid (人物库列表)
   ============================================================ */
.person-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.2rem;
}

.person-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}
.person-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.person-card-avatar {
    height: 80px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 2rem; font-weight: 800;
}

.person-card-body {
    padding: 1rem;
}

.person-card-body h3 {
    font-size: 1.1rem; margin-bottom: 0.2rem;
}

.person-title {
    font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem;
}

.progress-bar-small {
    width: 100%; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0.6rem 0;
    overflow: hidden;
}
.progress-bar-small span {
    display: block; height: 100%;
    background: var(--accent);
    transition: width 0.5s;
}

.person-meta {
    display: flex; gap: 1rem;
    font-size: 0.78rem; color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.person-actions {
    display: flex; gap: 0.5rem;
}

/* ============================================================
   Person Detail
   ============================================================ */
.person-hero {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

.person-hero-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 2rem; font-weight: 800;
    flex-shrink: 0;
}

.person-hero-info h1 { font-size: 1.5rem; margin-bottom: 0.2rem; }
.person-hero-title { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.person-hero-meta { display: flex; gap: 1.5rem; font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; }

.progress-ring-container {
    position: relative;
    width: 80px; height: 80px;
    margin-left: auto;
}
.progress-ring { width: 80px; height: 80px; }
.progress-ring-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    font-size: 0.9rem; font-weight: 700;
    color: var(--accent-light);
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-nav {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-item {
    padding: 0.7rem 1.3rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active { color: var(--accent-light); border-bottom-color: var(--accent); }

.tab-content { min-height: 300px; }

/* ============================================================
   Portrait Sections
   ============================================================ */
.portrait-section {
    margin-bottom: 1.5rem;
}

.portrait-section h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.portrait-desc {
    color: var(--text-secondary);
    line-height: 1.7;
    background: var(--bg-hover);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.tag-group {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
}

.portrait-edit-box {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.portrait-edit-box h3 {
    font-size: 0.95rem; color: var(--text-muted); margin-bottom: 1rem;
}

/* ============================================================
   Decision Cards (决策模型)
   ============================================================ */
.decision-list {
    display: flex; flex-direction: column; gap: 1rem;
    margin-top: 1rem;
}

.decision-card {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
}

.decision-scenario {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 0.5rem;
}

.decision-scenario-icon { margin-right: 0.3rem; }

.decision-flow {
    display: flex; align-items: center; gap: 0.6rem;
    flex-wrap: wrap;
}

.decision-node {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    flex: 1;
    min-width: 180px;
}

.node-label {
    font-size: 0.7rem;
    color: var(--accent-light);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.node-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.decision-arrow {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: bold;
}

.decision-result {
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--success);
    padding: 0.4rem 0.8rem;
    background: var(--success-bg);
    border-radius: var(--radius-sm);
}

/* ============================================================
   Case Cards
   ============================================================ */
.case-list {
    display: flex; flex-direction: column; gap: 1rem;
    margin-top: 1rem;
}

.case-card {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
}

.case-header {
    display: flex; align-items: center; gap: 0.8rem;
    margin-bottom: 0.8rem;
}
.case-header h3 { font-size: 1rem; }

.case-type-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.case-success { background: var(--success-bg); color: var(--success); }
.case-fail { background: var(--danger-bg); color: var(--danger); }

.case-reasoning {
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    padding: 0.8rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0.8rem 0;
}
.case-reasoning strong { color: var(--accent-light); }

/* ============================================================
   Pipeline (蒸馏流程)
   ============================================================ */
.pipeline-flow {
    display: flex; align-items: center; justify-content: center;
    gap: 0; padding: 1.5rem 0;
    flex-wrap: wrap;
}

.pipeline-step {
    text-align: center;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s;
    opacity: 0.4;
    min-width: 70px;
}

.pipeline-step.active {
    opacity: 1;
    background: var(--accent-glow);
    transform: scale(1.1);
}

.pipeline-step.done {
    opacity: 1;
    background: var(--success-bg);
}

.pipeline-icon { font-size: 1.3rem; margin-bottom: 0.3rem; }
.pipeline-label { font-size: 0.72rem; color: var(--text-muted); }
.pipeline-step.done .pipeline-label { color: var(--success); }
.pipeline-step.active .pipeline-label { color: var(--accent-light); }

.pipeline-connector {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin: 0 0.2rem;
}

.pipeline-result {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-top: 1rem;
}
.pipeline-result h3 { color: var(--accent-light); margin-bottom: 0.8rem; }

.conv-select-list {
    display: flex; flex-direction: column; gap: 0.5rem;
}

.conv-select-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.conv-select-item.processed { opacity: 0.6; }

.conv-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--accent-glow);
    color: var(--accent-light);
    border-radius: 3px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
}

/* ============================================================
   Mentor Grid (导师选择)
   ============================================================ */
.mentor-grid {
    display: flex; gap: 0.8rem; flex-wrap: wrap;
}

.mentor-card {
    display: flex; flex-direction: column; align-items: center;
    padding: 1rem 1.2rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
    text-align: center;
}
.mentor-card:hover { border-color: var(--border-hover); }
.mentor-card.selected { border-color: var(--accent); background: var(--accent-glow); }

.mentor-avatar {
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.3rem; font-weight: 800;
    margin-bottom: 0.5rem;
}
.mentor-name { font-size: 0.9rem; color: var(--text-primary); font-weight: 600; }
.mentor-style { font-size: 0.75rem; color: var(--text-muted); }
.mentor-progress { font-size: 0.7rem; color: var(--accent-light); margin-top: 0.3rem; }

/* ============================================================
   Mode Grid (训练模式选择)
   ============================================================ */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.mode-card {
    display: flex; flex-direction: column; align-items: center;
    padding: 1.2rem 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.mode-card:hover { border-color: var(--border-hover); }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--accent-glow); }

.mode-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.mode-name { font-size: 0.9rem; color: var(--text-primary); font-weight: 600; }
.mode-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; line-height: 1.4; }

/* ============================================================
   Chat (训练对话)
   ============================================================ */
.training-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.training-meta {
    display: flex; align-items: center; gap: 0.8rem;
}

.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-height: 400px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 1rem;
    margin-bottom: 1rem;
}

.chat-bubble {
    max-width: 75%;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    line-height: 1.5;
}

.chat-left {
    align-self: flex-start;
    background: var(--bg-hover);
    border: 1px solid var(--border);
}

.chat-right {
    align-self: flex-end;
    background: var(--accent-glow);
    border: 1px solid var(--accent);
}

.chat-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.chat-content {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.chat-content.typing {
    color: var(--text-muted);
    font-style: italic;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-input-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
}

.chat-input-bar form {
    display: flex; gap: 0.8rem;
}

.chat-input-bar input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

.chat-input-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================================
   Review (复盘)
   ============================================================ */
.review-meta {
    display: flex; gap: 1.5rem; flex-wrap: wrap;
    padding: 1rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.2rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.review-content {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

/* ============================================================
   Login
   ============================================================ */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 80vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 360px;
    text-align: center;
}

.login-card h1 { font-size: 1.3rem; margin-bottom: 1.5rem; }

.login-hint {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 1rem;
}

.error-msg {
    color: var(--danger);
    background: var(--danger-bg);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.modal-box h2 {
    font-size: 1.2rem;
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    position: absolute; top: 0.8rem; right: 1rem;
    background: none; border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }

/* ============================================================
   Utility
   ============================================================ */
.empty-text { color: var(--text-muted); font-size: 0.9rem; padding: 1rem 0; text-align: center; }
.empty-text-full { color: var(--text-muted); font-size: 1rem; padding: 3rem 0; text-align: center; display: block; }

.loading {
    text-align: center; padding: 2rem; color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.5rem;
}

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

.success-box {
    background: var(--success-bg);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--success);
}

.error-box {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 1rem;
    color: var(--danger);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand { justify-content: center; padding: 1rem 0.5rem; }
    .logo-text, .sidebar-nav a span:not(.nav-icon), .sidebar-footer { display: none; }
    .sidebar-nav a { justify-content: center; }
    .main-content { margin-left: 60px; padding: 1rem; }
    
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .home-grid { grid-template-columns: 1fr; }
    .mode-grid { grid-template-columns: repeat(2, 1fr); }
    
    .decision-flow { flex-direction: column; }
    .decision-arrow { transform: rotate(90deg); }
    .person-hero { flex-direction: column; text-align: center; }
    .progress-ring-container { margin: 0 auto; }
}

/* ============================================================
   AI 分析按钮 & 弹窗
   ============================================================ */
.portrait-ai-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn-ai {
    background: linear-gradient(135deg, var(--accent), #a78bfa) !important;
    border: none !important;
    font-weight: 600;
    padding: 0.6rem 1.5rem !important;
}
.btn-ai:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-ai-outline {
    background: transparent;
    border: 1.5px dashed var(--accent-light) !important;
    color: var(--accent-light) !important;
    font-weight: 500;
}
.btn-ai-outline:hover {
    background: rgba(124, 58, 237, 0.1) !important;
    border-style: solid !important;
}

.ai-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal-wide {
    max-width: 620px !important;
}

/* Animation for loading spinner */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   话术 SOP 相关样式
   ============================================================ */

/* 话术列表 */
.script-list { display: flex; flex-direction: column; gap: 1.2rem; }

.script-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    transition: box-shadow 0.2s;
}
.script-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.script-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.script-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.script-icon { font-size: 1.1rem; }
.script-type-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}
.script-card-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.script-preview {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    background: var(--bg);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.script-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* 知识库区域 */
.knowledge-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1rem;
    margin-top: 0.75rem;
}
.knowledge-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #0369a1;
    margin-bottom: 0.6rem;
}
.knowledge-icon { font-size: 1rem; }
.knowledge-summary {
    color: #0c4a6e;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}
.knowledge-steps { display: flex; flex-direction: column; gap: 0.5rem; }
.knowledge-step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.step-num {
    background: #0284c7;
    color: #fff;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.step-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #0c4a6e;
    white-space: nowrap;
    flex-shrink: 0;
}
.step-phrases { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.step-phrase {
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-size: 0.78rem;
    color: #0369a1;
}

.knowledge-empty { padding: 0.75rem 0; }

.empty-state-scripts {
    text-align: center;
    padding: 3rem 1rem;
}

/* 训练页话术推荐区域 */
.chat-input-area {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 100;
}

.script-suggest-bar {
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    border-bottom: 1px solid #fde68a;
    padding: 0.75rem 1rem;
    max-height: 220px;
    overflow-y: auto;
}
.script-suggest-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.script-suggest-icon { font-size: 1rem; }
.script-suggest-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #92400e;
}
.script-suggest-hint {
    font-size: 0.75rem;
    color: #b45309;
    flex: 1;
}
.script-suggest-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #b45309;
    padding: 0 0.25rem;
    line-height: 1;
}
.script-suggest-close:hover { color: #92400e; }

.suggest-item {
    background: #fff;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 0.7rem 0.8rem;
    margin-bottom: 0.5rem;
}
.suggest-item:last-child { margin-bottom: 0; }
.suggest-text {
    font-size: 0.9rem;
    color: #1a1a1a;
    line-height: 1.6;
    margin-bottom: 0.4rem;
}
.suggest-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.suggest-source {
    font-size: 0.75rem;
    color: #92400e;
}
.btn-copy-suggest {
    background: #f59e0b;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
    flex-shrink: 0;
}
.btn-copy-suggest:hover { background: #d97706; }

/* ============================================================
   v3.0 账号权限系统相关样式
   ============================================================ */

/* 侧边栏 - 用户信息区域 */
.user-info-box {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.user-role-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}
.role-admin {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
}
.role-student {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff;
}
.nav-accounts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.15s;
    margin-bottom: 0.3rem;
}
.nav-accounts:hover { background: var(--bg); color: var(--text); }
.nav-accounts.active { background: var(--accent); color: #fff; }

/* 学员只读提示 */
.readonly-notice {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #92400e;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* 首页训练列表 - 用户身份标签 */
.training-user-label {
    font-weight: 600;
    color: var(--text);
}

/* 账号设置页面 */
.account-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}
.account-meta {
    display: flex;
    gap: 1.5rem;
}
.account-field {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.student-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.student-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: box-shadow 0.15s;
}
.student-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.student-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.student-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}
.student-actions {
    display: flex;
    gap: 0.5rem;
}
