/* ========== CSS 变量 ========== */
:root {
    --bg-base: #0f0f0f;
    --bg-panel: #141414;
    --bg-card: #1a1a1a;
    --bg-hover: #1f1f1f;
    --border: #1e1e1e;
    --border-light: #2a2a2a;
    --t1: #fff;
    --t2: #e0e0e0;
    --tm: #8a8a8a;
    --td: #5a5a5a;
    --accent: #f97316;
    --accent-h: #fb923c;
    --accent-d: rgba(249, 115, 22, 0.1);
    --ok: #10b981;
    --ok-d: rgba(16, 185, 129, 0.1);
    --warn: #f59e0b;
    --warn-d: rgba(245, 158, 11, 0.1);
    --err: #ef4444;
    --err-d: rgba(239, 68, 68, 0.1);
    --r: 8px;
    --rs: 6px;
}

/* ========== 全局样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; background: var(--bg-base); color: #e0e0e0; min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #fb923c; }
input, textarea, select, button { font-family: inherit; }

/* ========== 按钮 ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: #f97316; color: #fff; }
.btn-primary:hover { background: #ea580c; transform: translateY(-1px); }
.btn-outline { background: transparent; color: #f97316; border: 1px solid #f97316; }
.btn-outline:hover { background: #f97316; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: #1e1e1e; color: #aaa; border: 1px solid #333; }
.btn-ghost:hover { background: #2a2a2a; color: #fff; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: #999; font-weight: 500; }
.form-input { width: 100%; padding: 10px 14px; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px; color: #fff; font-size: 14px; transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: #f97316; }
.form-input::placeholder { color: #555; }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ========== 工作台布局 ========== */
.workspace { display: flex; height: 100vh; background: #0f0f0f; }

/* ========== 侧边栏 ========== */
.sidebar {
    width: 240px;
    background: #141414;
    border-right: 1px solid #1e1e1e;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-logo .logo-text,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-arrow,
.sidebar.collapsed .menu-badge,
.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .sidebar-header { padding: 12px 0; justify-content: center; }
.sidebar.collapsed .menu-group-header { padding: 10px 0; justify-content: center; }
.sidebar.collapsed .menu-item { padding: 10px 0; justify-content: center; }
.sidebar.collapsed .sidebar-footer { padding: 12px 0; justify-content: center; }

/* 侧边栏头部 */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #1e1e1e;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon { font-size: 20px; }
.logo-text { font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; }
.sidebar-toggle {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.sidebar-toggle:hover { color: #f97316; background: rgba(249, 115, 22, 0.1); }

/* 侧边栏菜单 */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

/* 菜单项 */
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 6px;
    margin-bottom: 2px;
    text-decoration: none;
    white-space: nowrap;
}
.menu-item:hover { color: #e0e0e0; background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.menu-item.active { color: #f97316; background: rgba(249, 115, 22, 0.1); }
.menu-item.disabled { opacity: 0.4; cursor: not-allowed; }
.menu-item.disabled:hover { background: transparent; }
.menu-icon { display: flex; align-items: center; justify-content: center; width: 20px; flex-shrink: 0; }
.menu-text { flex: 1; }
.menu-badge { font-size: 10px; padding: 1px 6px; background: #2a2a2a; color: #666; border-radius: 4px; }

/* 菜单分组 */
.menu-group { margin-bottom: 4px; }
.menu-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.menu-group-header:hover { color: #e0e0e0; background: rgba(255, 255, 255, 0.04); }
.menu-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
}
.menu-group.expanded .menu-arrow { transform: rotate(180deg); }
.menu-submenu { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.menu-group.expanded .menu-submenu { max-height: 500px; }
.menu-submenu .menu-item { padding-left: 42px; font-size: 13px; }

/* 小说创作二级展开导航 */
.menu-subgroup { position: relative; }
.menu-subgroup .menu-item { cursor: pointer; }
.menu-subgroup .menu-arrow { margin-left: auto; transition: transform 0.2s; }
.menu-subgroup.expanded .menu-arrow { transform: rotate(180deg); }
.menu-submenu-list { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.menu-subgroup.expanded .menu-submenu-list { max-height: 400px; overflow-y: auto; }
.menu-submenu-list .menu-item { padding-left: 56px; font-size: 12px; color: #8a8a8a; }
.menu-submenu-list .menu-item:hover { color: #f97316; background: rgba(249,115,22,.08); }
.menu-submenu-list .menu-item.submenu-new { color: #f97316; font-weight: 500; }
.menu-submenu-list .menu-item.submenu-novel .menu-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.submenu-loading { padding: 8px 16px 8px 56px; font-size: 11px; color: #5a5a5a; }
.submenu-empty { padding: 8px 16px 8px 56px; font-size: 11px; color: #5a5a5a; font-style: italic; }
.submenu-info { padding: 6px 16px 8px 56px; font-size: 10px; color: #3a3a3a; border-top: 1px solid #1e1e1e; margin-top: 4px; }
.menu-submenu-list .menu-item.submenu-novel .menu-badge { font-size: 10px; color: #8a8a8a; margin-left: auto; flex-shrink: 0; }
.menu-submenu-list .menu-item.submenu-novel.active { color: #f97316; background: rgba(249,115,22,.08); }

/* 侧边栏底部 */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #1e1e1e;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.user-details { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 500; color: #e0e0e0; }
.user-role { font-size: 11px; color: #666; }
.logout-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.logout-btn:hover { color: #ef4444; background: rgba(239, 68, 68, 0.1); }

/* ========== 主内容区 ========== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid #1e1e1e;
    background: #141414;
    flex-shrink: 0;
}
.main-header h2 { font-size: 16px; font-weight: 600; color: #e0e0e0; }
.main-body { flex: 1; overflow-y: auto; padding: 24px; }
.main-body::-webkit-scrollbar { width: 6px; }
.main-body::-webkit-scrollbar-track { background: transparent; }
.main-body::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

/* ========== 仪表盘统计卡片 ========== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: #1a1a1a;
    border: 1px solid #1e1e1e;
    border-radius: 10px;
    padding: 20px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: #333; }
.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 14px;
}
.stat-card:nth-child(1) .stat-icon { background: rgba(249, 115, 22, 0.1); color: #f97316; }
.stat-card:nth-child(2) .stat-icon { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-card:nth-child(3) .stat-icon { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-card:nth-child(4) .stat-icon { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.stat-card .stat-label { font-size: 13px; color: #666; }

/* ========== 内容区块 ========== */
.content-section { margin-bottom: 28px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h3 { font-size: 15px; font-weight: 600; color: #e0e0e0; }

/* ========== 项目网格 ========== */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
    background: #1a1a1a;
    border: 1px solid #1e1e1e;
    border-radius: 10px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s;
}
.project-card:hover { border-color: #f97316; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.project-card .title { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #e0e0e0; }
.project-card .meta { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.project-card .desc { font-size: 12px; color: #666; margin-bottom: 12px; }
.project-card .actions { display: flex; gap: 8px; }

/* ========== 空状态 ========== */
.empty-state { text-align: center; padding: 60px 20px; color: #555; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { margin-bottom: 20px; font-size: 14px; color: #666; }

/* ========== 标签/徽章 ========== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-draft { background: #1e1e1e; color: #888; }
.badge-done { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.badge-type { background: rgba(249, 115, 22, 0.1); color: #f97316; }

/* ========== 完本挂牌 ========== */
.project-card.completed { border-color: #10b981; }

/* ========== 模态框 ========== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(4px); }
.modal { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 12px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.modal h3 { margin-bottom: 20px; font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ========== 编辑器布局 ========== */
.editor-layout { display: flex; height: 100%; }
.editor-sidebar { width: 320px; background: #141414; border-right: 1px solid #1e1e1e; overflow-y: auto; padding: 16px; flex-shrink: 0; }
.editor-sidebar::-webkit-scrollbar { width: 4px; }
.editor-sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }
.editor-main { flex: 1; overflow-y: auto; padding: 24px; background: #0f0f0f; }

/* ========== 场景列表 ========== */
.scene-list { display: flex; flex-direction: column; gap: 8px; }
.scene-item { background: #1a1a1a; border: 1px solid #1e1e1e; border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.15s; }
.scene-item:hover { border-color: #333; }
.scene-item.active { border-color: #f97316; background: rgba(249, 115, 22, 0.05); }
.scene-item .scene-num { font-size: 11px; color: #f97316; margin-bottom: 4px; font-weight: 500; }
.scene-item .scene-text { font-size: 12px; color: #888; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }

/* ========== 场景详情 ========== */
.scene-detail { max-width: 640px; }
.scene-detail h3 { margin-bottom: 16px; font-size: 16px; }
.scene-detail textarea { min-height: 80px; }
.audio-controls { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.audio-controls audio { flex: 1; height: 32px; border-radius: 6px; }

/* ========== 工具栏 ========== */
.toolbar { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.theme-tag {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    color: #888;
    transition: all 0.15s;
}
.theme-tag:hover { border-color: #555; color: #e0e0e0; }
.theme-tag.active { border-color: #f97316; color: #f97316; background: rgba(249, 115, 22, 0.1); }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; background: #1a1a1a; border: 1px solid #1e1e1e; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #1e1e1e; font-size: 13px; }
th { color: #666; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ========== 首页 ========== */
.hero { text-align: center; padding: 80px 32px 60px; }
.hero h1 { font-size: 48px; font-weight: 800; margin-bottom: 16px; }
.hero h1 .highlight { background: linear-gradient(135deg, #f97316, #ef4444); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { font-size: 18px; color: #888; max-width: 600px; margin: 0 auto 32px; }
.hero .btn-group { display: flex; gap: 16px; justify-content: center; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 960px; margin: 0 auto; padding: 0 32px 80px; }
.feature-card { background: #1a1a1a; border: 1px solid #1e1e1e; border-radius: 12px; padding: 28px; text-align: center; transition: border-color 0.2s; }
.feature-card:hover { border-color: #333; }
.feature-card .icon { font-size: 36px; margin-bottom: 14px; }
.feature-card h3 { font-size: 16px; margin-bottom: 8px; color: #e0e0e0; }
.feature-card p { font-size: 13px; color: #666; line-height: 1.6; }
.footer { text-align: center; padding: 32px; color: #444; font-size: 12px; border-top: 1px solid #1e1e1e; }

/* ========== 登录注册 ========== */
.auth-container { max-width: 400px; margin: 80px auto; padding: 0 24px; }
.auth-container h2 { font-size: 24px; margin-bottom: 8px; }
.auth-container .subtitle { color: #666; margin-bottom: 28px; font-size: 14px; }
.auth-container .switch-link { text-align: center; margin-top: 20px; font-size: 13px; color: #666; }
.error-msg { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 8px; padding: 10px 14px; color: #ef4444; font-size: 13px; margin-bottom: 16px; display: none; }

/* ========== 导航栏 ========== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 32px;
    background: #141414;
    border-bottom: 1px solid #1e1e1e;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}
.navbar .nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}
.navbar .nav-links a {
    color: #888;
    font-size: 14px;
    transition: color 0.2s;
}
.navbar .nav-links a:hover {
    color: #f97316;
}
.navbar .nav-links .btn {
    padding: 8px 16px;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .features { grid-template-columns: 1fr; }
    .hero h1 { font-size: 32px; }
    .sidebar { position: fixed; z-index: 150; }
    .sidebar.collapsed { width: 0; border: none; }
}
