/* ==============================================================================
   Tiamo Design System & LearningSys 核心样式规范
   遵循 Documents/UI_STYLE_GUIDE.md 设计令牌与组件规范
============================================================================== */

:root {
    /* --- 品牌主色系 (Primary Indigo) --- */
    --brand-primary: #4f46e5;          /* 主色：indigo-600 */
    --brand-primary-hover: #4338ca;    /* 悬停态：indigo-700 */
    --brand-primary-light: #eef2ff;    /* 极浅强调底色：indigo-50 */
    --brand-primary-glow: rgba(79, 70, 229, 0.25);

    /* --- 中性灰度色系 (Neutral Slate) --- */
    --bg-base: #f8fafc;                /* 页面整体底色：slate-50 */
    --surface-card: #ffffff;           /* 卡片与浮层：纯白 */
    --surface-glass: rgba(255, 255, 255, 0.92);
    --border-color: #e2e8f0;           /* 核心分隔线：slate-200 */
    --border-subtle: rgba(226, 232, 240, 0.8);

    /* --- 文本色阶 (Text) --- */
    --text-main: #0f172a;              /* 主标题、正文强调：slate-900 */
    --text-regular: #334155;           /* 正文常规：slate-700 */
    --text-muted: #64748b;             /* 辅助说明、占位符：slate-500 */
    --text-disabled: #94a3b8;          /* 禁用态文本：slate-400 */

    /* --- 状态功能色 (Feedback) --- */
    --color-success: #10b981;          /* 成功态：emerald-500 */
    --color-warning: #f59e0b;          /* 警告态：amber-500 */
    --color-danger: #ef4444;           /* 危险/删除：red-500 */
    --color-info: #0284c7;             /* 提示信息：sky-600 */

    /* --- 深度工作台背景 --- */
    --bg-dark-workspace: #09090b;

    /* --- 顶栏预留高度 (TiamoBar 32px) --- */
    --tiamo-bar-height: 32px;
}

/* 基础重置 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    padding-top: var(--tiamo-bar-height);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-regular);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* 胶囊细滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 布局容器 */
.layout-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* 按钮原子组件 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    text-decoration: none;
}

.btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
}

.btn-primary {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--brand-primary-glow);
}
.btn-primary:hover {
    background: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-regular);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-secondary:hover {
    background: #f8fafc;
    color: var(--text-main);
    border-color: #cbd5e1;
    transform: translateY(-1px);
}
.btn-secondary:active {
    transform: scale(0.98);
}

.btn-danger {
    background: #fef2f2;
    color: var(--color-danger);
    border-color: #fecaca;
}
.btn-danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger-outline {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 10px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
    transform: translateY(-1px);
}
.btn-danger-outline:active {
    transform: scale(0.98);
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-regular);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.icon-btn:hover {
    background: #f8fafc;
    color: var(--text-main);
    transform: translateY(-1px);
    border-color: #cbd5e1;
}
.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn.btn-delete:hover {
    background: #fef2f2;
    color: var(--color-danger);
    border-color: #fecaca;
}

.icon-btn img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
}

/* 本地离线开发角色切换器 (生产环境不展示) */
.dev-role-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: rgba(241, 245, 249, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-left: 0.75rem;
}
.role-pill {
    border: none;
    background: transparent;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.725rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.role-pill img {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    display: block;
}
.role-pill:hover {
    color: var(--text-main);
}
.role-pill.active-admin {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}
.role-pill.active-user {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

/* ==============================================================================
   首页：目录中心 (Home Catalog)
============================================================================== */
.home-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo-badge {
    width: 44px;
    height: 44px;
    background: var(--brand-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 12px var(--brand-primary-glow);
    flex-shrink: 0;
}

.brand-info h1 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.brand-info p {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.15rem;
}

/* 过滤与搜索胶囊栏 */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: var(--surface-card);
    padding: 0.75rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.filter-pills {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.15s ease;
}
.filter-pill:hover {
    background: #f1f5f9;
    color: var(--text-main);
}
.filter-pill.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.search-input-wrapper {
    position: relative;
    min-width: 240px;
}

.search-input {
    width: 100%;
    padding: 0.45rem 0.85rem 0.45rem 2.2rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-main);
    background: #f8fafc;
    outline: none;
    transition: all 0.2s ease;
}
.search-input:focus {
    background: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon img {
    width: 15px;
    height: 15px;
    display: block;
}

/* 科目卡片网格 */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.subject-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.subject-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px -6px rgba(79, 70, 229, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

.subject-card-header {
    margin-bottom: 1rem;
}

.subject-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    margin-bottom: 0.25rem;
}

.subject-card-subtitle {
    font-size: 0.875rem;
    color: var(--brand-primary);
    font-weight: 600;
    opacity: 0.9;
}

.badge-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.85rem 0 1.25rem;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}

.meta-badge.year {
    background: #e0e7ff;
    color: #3730a3;
}

.meta-badge.term {
    background: #fef3c7;
    color: #92400e;
}

.meta-badge.chapters {
    background: #ecfdf5;
    color: #065f46;
}

.meta-badge.has-comments {
    background: #fdf2f8;
    color: #9d174d;
    gap: 0.35rem;
}

.meta-badge.has-comments img {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    display: block;
}

.subject-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.85rem;
    margin-top: auto;
}

.read-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.card-actions {
    display: flex;
    gap: 0.35rem;
}

/* 新建科目卡片 */
.new-subject-card {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 20px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    min-height: 220px;
    transition: all 0.2s ease;
}
.new-subject-card:hover {
    border-color: var(--brand-primary);
    background: var(--brand-primary-light);
    transform: translateY(-2px);
}
.new-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--brand-primary);
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
.new-card-icon img {
    width: 22px;
    height: 22px;
    display: block;
}

/* ==============================================================================
   查看器：双语讲义工作区 (Subject Viewer)
============================================================================== */
.viewer-topbar {
    position: sticky;
    top: var(--tiamo-bar-height);
    z-index: 40;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.viewer-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.topbar-subject-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* 语言切换胶囊 */
.lang-toggle-group {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.lang-toggle-btn {
    padding: 0.3rem 0.75rem;
    border-radius: 7px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.lang-toggle-btn.active {
    background: #ffffff;
    color: var(--brand-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 查看器主双栏布局 */
.viewer-workspace {
    display: flex;
    min-height: calc(100vh - var(--tiamo-bar-height) - 56px);
}

/* 左侧目录侧边栏 */
.viewer-sidebar {
    width: 290px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    position: sticky;
    top: calc(var(--tiamo-bar-height) + 56px);
    height: calc(100vh - var(--tiamo-bar-height) - 56px);
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 0 0.5rem 0.75rem;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toc-link {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--text-regular);
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    transition: all 0.15s ease;
}
.toc-link:hover {
    background: #f8fafc;
    color: var(--text-main);
}
.toc-link.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 600;
}
.toc-link-en {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* 核心文章阅读区 */
.viewer-content-area {
    flex: 1;
    max-width: 920px;
    margin: 0 auto;
    padding: 3rem 2.5rem;
}

.subject-doc-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1.75rem;
    margin-bottom: 2.5rem;
}

.doc-title-cn {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.doc-title-en {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--brand-primary);
    margin-top: 0.35rem;
}

/* 章节容器 */
.chapter-block {
    margin-bottom: 3.5rem;
}

.chapter-title-cn {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.35rem;
    scroll-margin-top: calc(var(--tiamo-bar-height) + 70px);
}

.chapter-title-en {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* 块级段落与笔记容器 */
.block-row {
    position: relative;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    margin-bottom: 0.65rem;
    transition: background 0.15s ease;
}

.block-row:hover {
    background: rgba(241, 245, 249, 0.6);
}

.block-row.has-note {
    border-left: 3px solid var(--brand-primary);
    background: rgba(238, 242, 255, 0.4);
}

.block-content-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 1.25rem 0 0.5rem;
}

.block-content-heading .en-line {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
    margin-top: 0.15rem;
}

.block-content-list {
    margin-left: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.7;
}

.block-content-list .en-line {
    color: var(--text-muted);
    font-size: 0.88rem;
    display: block;
    margin-top: 0.15rem;
}

.block-content-paragraph {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-main);
}

.block-content-paragraph .en-line {
    color: #475569;
    font-size: 0.92rem;
    margin-top: 0.25rem;
    display: block;
    line-height: 1.6;
}

/* 笔记交互浮标 */
.block-note-btn {
    position: absolute;
    right: 0.5rem;
    top: 0.65rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    display: none;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-regular);
    transition: all 0.15s ease;
}

.block-note-btn img {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    display: block;
}

.block-row:hover .block-note-btn,
.block-row.has-note .block-note-btn {
    display: inline-flex;
}

.block-note-btn:hover {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-color: #c7d2fe;
}

.note-badge-count {
    background: var(--brand-primary);
    color: #ffffff;
    border-radius: 9999px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
}

/* 笔记抽屉/展开列表 */
.block-notes-panel {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.note-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}
.note-item:last-child {
    border-bottom: none;
}

.note-text {
    flex: 1;
    color: var(--text-regular);
}

.note-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-disabled);
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.note-delete-btn img {
    width: 12px;
    height: 12px;
    display: block;
}
.note-delete-btn:hover {
    color: var(--color-danger);
    background: #fef2f2;
}

.note-add-form {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.note-input {
    flex: 1;
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    outline: none;
}
.note-input:focus {
    border-color: var(--brand-primary);
}

/* ==============================================================================
   AI 伴学助手：悬浮气泡与对话抽屉
============================================================================== */
.ai-fab {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.5);
    z-index: 50;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-fab img {
    width: 26px;
    height: 26px;
    display: block;
}
.ai-fab:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.6);
}

.ai-chat-drawer {
    position: fixed;
    right: 2rem;
    bottom: 6rem;
    width: 400px;
    max-width: calc(100vw - 2.5rem);
    height: 540px;
    max-height: calc(100vh - var(--tiamo-bar-height) - 120px);
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow: hidden;
    animation: drawerPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-chat-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ai-header-title img {
    width: 16px;
    height: 16px;
    display: block;
}

.ai-header-sub {
    font-size: 0.725rem;
    color: var(--text-muted);
}

.ai-messages-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #fbfcfe;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--brand-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-bubble.assistant pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 0.75rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.chat-bubble.assistant code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.ai-chat-input-row {
    padding: 0.85rem 1rem;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.ai-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    outline: none;
}
.ai-input:focus {
    border-color: var(--brand-primary);
}

/* ==============================================================================
   新建与编辑表单 (Subject Editor)
============================================================================== */
.editor-card {
    max-width: 860px;
    margin: 2rem auto;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    color: var(--text-main);
    background: #ffffff;
    font-family: inherit;
    transition: all 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.textarea-markdown {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    min-height: 360px;
    resize: vertical;
}

/* Toast 提示浮层 */
.toast-container {
    position: fixed;
    top: calc(var(--tiamo-bar-height) + 16px);
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.2s ease forwards;
    pointer-events: auto;
}
.toast.success { background: #065f46; border: 1px solid #10b981; }
.toast.error { background: #991b1b; border: 1px solid #ef4444; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 响应式适配 */
@media (max-width: 868px) {
    .viewer-sidebar {
        display: none;
    }
    .viewer-content-area {
        padding: 1.5rem 1rem;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .ai-chat-drawer {
        right: 1rem;
        bottom: 5rem;
        width: calc(100vw - 2rem);
    }
}
