/* Reset & Base */
* { box-sizing: border-box; }
body { margin: 0; font-family: sans-serif; background-color: #050505; color: #f2f2f2; }

/* Layout Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.grow { flex-grow: 1; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }
.col-span-8 { grid-column: span 8 / span 8; }
.col-span-9 { grid-column: span 9 / span 9; }
.col-span-12 { grid-column: span 12 / span 12; }
.row-span-1 { grid-row: span 1 / span 1; }
.row-span-4 { grid-row: span 4 / span 4; }

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.left-0 { left: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }

/* Sizing */
.w-full { width: 100%; }
.h-full { height: 100%; }
.w-screen { width: 100vw; }
.h-screen { height: 100vh; }
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.w-12 { width: 3rem; }
.h-12 { height: 3rem; }
.w-16 { width: 4rem; }
.h-16 { height: 4rem; }
.w-20 { width: 5rem; }
.h-20 { height: 5rem; }
.w-24 { width: 6rem; }
.h-24 { height: 6rem; }
.w-32 { width: 8rem; }
.h-32 { height: 8rem; }
.w-40 { width: 10rem; }
.h-40 { height: 10rem; }
.w-48 { width: 12rem; }
.h-48 { height: 12rem; }
.w-56 { width: 14rem; }
.w-64 { width: 16rem; }
.w-72 { width: 18rem; }
.w-80 { width: 20rem; }

/* Spacing */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.p-12 { padding: 3rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.pt-0 { padding-top: 0; }
.pt-1 { padding-top: 0.25rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-4 { padding-bottom: 1rem; }
.pl-2 { padding-left: 0.5rem; }
.pl-4 { padding-left: 1rem; }
.pr-2 { padding-right: 0.5rem; }
.pr-4 { padding-right: 1rem; }

.m-0 { margin: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.mr-4 { margin-right: 1rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Typography */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: monospace; }
.font-serif { font-family: serif; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Colors */
.text-white { color: #fff; }
.text-black { color: #000; }
.text-dim { color: #888; }
.text-accent { color: #ffd700; }
.text-red-400 { color: #f87171; }
.text-red-500 { color: #ef4444; }
.text-green-400 { color: #4ade80; }
.text-green-500 { color: #22c55e; }
.text-blue-400 { color: #60a5fa; }
.text-blue-500 { color: #3b82f6; }
.text-yellow-400 { color: #facc15; }
.text-yellow-500 { color: #eab308; }
.text-purple-400 { color: #c084fc; }
.text-purple-500 { color: #a855f7; }
.text-pink-400 { color: #f472b6; }
.text-pink-500 { color: #ec4899; }
.text-gray-200 { color: #e5e7eb; }
.text-gray-300 { color: #d1d5db; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-transparent { color: transparent; }

/* Backgrounds */
.bg-black { background-color: #000; }
.bg-white { background-color: #fff; }
.bg-transparent { background-color: transparent; }
.bg-accent { background-color: #ffd700; }

/* Borders & Radius */
.border { border-width: 1px; border-style: solid; border-color: rgba(255,255,255,0.1); }
.border-t { border-top-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-l { border-left-width: 1px; }
.border-r { border-right-width: 1px; }
.border-none { border: none; }
.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }

/* Effects */
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }
.opacity-50 { opacity: 0.5; }
.opacity-80 { opacity: 0.8; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }
.cursor-pointer { cursor: pointer; }
.hidden { display: none !important; }
.block { display: block; }

/* Custom */
.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:scale-110:hover { transform: scale(1.10); }
.transition-all { transition: all 0.3s ease; }
.transition-transform { transition: transform 0.3s ease; }
.transition-colors { transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease; }
.group:hover .group-hover\:text-white { color: #fff; }
.group:hover .group-hover\:scale-110 { transform: scale(1.10); }
.group:hover .group-hover\:opacity-100 { opacity: 1; }

/* Background Opacities (Approximation) */
.bg-white\/5 { background-color: rgba(255,255,255,0.05); }
.bg-white\/10 { background-color: rgba(255,255,255,0.1); }
.bg-white\/20 { background-color: rgba(255,255,255,0.2); }
.bg-black\/20 { background-color: rgba(0,0,0,0.2); }
.bg-black\/30 { background-color: rgba(0,0,0,0.3); }
.bg-black\/40 { background-color: rgba(0,0,0,0.4); }
.bg-black\/50 { background-color: rgba(0,0,0,0.5); }
.bg-black\/60 { background-color: rgba(0,0,0,0.6); }
.bg-black\/80 { background-color: rgba(0,0,0,0.8); }
.bg-black\/90 { background-color: rgba(0,0,0,0.9); }

/* Specific Colors with Opacity */
.bg-accent\/10 { background-color: rgba(255, 215, 0, 0.1); }
.bg-accent\/20 { background-color: rgba(255, 215, 0, 0.2); }

/* Gradients (Basic) */
.bg-gradient-to-r { background: linear-gradient(to right, var(--tw-gradient-stops)); }
.bg-gradient-to-b { background: linear-gradient(to bottom, var(--tw-gradient-stops)); }
.bg-gradient-to-br { background: linear-gradient(to bottom right, var(--tw-gradient-stops)); }
.from-black { --tw-gradient-from: #000; --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(0, 0, 0, 0)); }
.to-transparent { --tw-gradient-to: transparent; }

/* --- FALLBACK UTILITIES (Safety Net for CDN Failure) --- */
.capitalize { text-transform: capitalize; }
.inline-block { display: inline-block; }
.h-11 { height: 2.75rem; }
.min-h-0 { min-height: 0; }
.min-w-0 { min-width: 0; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-0\.5 > * + * { margin-top: 0.125rem; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
.flex-wrap { flex-wrap: wrap; }
.gap-x-3 { column-gap: 0.75rem; }
.gap-y-1 { row-gap: 0.25rem; }
.col-span-2 { grid-column: span 2 / span 2; }

/* --- CORE VARIABLES --- */
:root {
    /* ThemeEngine managed */
    --bg-app: #050505;
    --bg-base: #08080a;
    --bg-elevated: #0a0a0c;
    --bg-overlay: #0e0e10;
    --bg-modal: #111113;
    --bg-card: #0e0e12;
    --bg-input: rgba(0,0,0,0.3);
    --bg-hover: rgba(255,255,255,0.05);
    --bg-sidebar: rgba(8, 8, 10, 0.95);
    --text-primary: #f2f2f2;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-disabled: #555555;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --accent: #ffd700;
    --accent-rgb: 255, 215, 0;
    --accent-soft: rgba(255,215,0,0.15);
    --accent-hover: #ffea44;
    --shadow: rgba(0,0,0,0.5);
    --glass: rgba(15,15,20,0.7);
    --glass-opacity: 0.7;
    --scrollbar: rgba(255,255,255,0.1);
    --scrollbar-hover: rgba(255,255,255,0.2);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    /* Typography */
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-editor: 'JetBrains Mono', 'Fira Code', monospace;
    --editor-size: 16px;
    --editor-lh: 1.7;
    --sidebar-width: 240px;
    --transition-speed: 0.3s;
    /* Legacy aliases for backward compat */
    --text-main: var(--text-primary);
    --text-dim: var(--text-muted);
    --border: var(--border-default);
    --radius-sm: 6px;
    --radius-md: 12px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Epic Commercial Grade Styles */
.epic-glass { background: rgba(15, 15, 20, 0.7); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.epic-card { position: relative; overflow: hidden; background: linear-gradient(160deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)); border: 1px solid rgba(255,255,255,0.05); transition: all 0.4s var(--ease); border-radius: 16px; }
.epic-card::before { content:''; position: absolute; top:0; left:0; right:0; height:1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent); opacity: 0; transition: opacity 0.4s; }
.epic-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,0.4); border-color: rgba(255,215,0,0.2); }
.epic-card:hover::before { opacity: 1; }

.epic-btn { position: relative; overflow: hidden; background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)); border: 1px solid rgba(255,255,255,0.1); color: var(--text-main); transition: all 0.3s var(--ease); }
.epic-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); color: #fff; box-shadow: 0 0 20px rgba(255,215,0,0.15); }
.epic-btn::after { content:''; position: absolute; inset:0; background: radial-gradient(circle at center, rgba(255,215,0,0.2), transparent 70%); opacity: 0; transition: opacity 0.3s; }
.epic-btn:hover::after { opacity: 1; }

.epic-input { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); transition: all 0.3s; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.epic-input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), inset 0 2px 4px rgba(0,0,0,0.2); background: rgba(0,0,0,0.5); }

.nav-glow { position: absolute; width: 4px; height: 20px; background: var(--accent); border-radius: 2px; left: 0; box-shadow: 0 0 15px var(--accent); opacity: 0; transition: opacity 0.3s; }
.sidebar-item.active .nav-glow { opacity: 1; }

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    background-color: var(--bg-app);
    -webkit-user-select: text;
    user-select: text;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255, 215, 0, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 240, 255, 0.02) 0%, transparent 40%),
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Utilities */
.center { display: flex; align-items: center; justify-content: center; }
.col { display: flex; flex-direction: column; }

/* Tab Active State */
.tab-btn { color: #888; transition: all 0.2s; }
.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); background: rgba(255, 215, 0, 0.05); }

/* --- COMPONENT STYLES (Tailwind Composite) --- */

/* Buttons */
.btn {
    height: 36px; padding: 0 16px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-main); font-size: 13px; font-weight: 500;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; transition: all 0.2s var(--ease);
    white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); transform: translateY(-1px); color: #fff; }
.btn:active { transform: translateY(0); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #ffbf00 100%);
    color: #000; border: none; font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}
.btn-primary:hover { box-shadow: 0 6px 16px rgba(255, 215, 0, 0.5); filter: brightness(1.15); transform: translateY(-2px); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 4px; }

/* High Visibility Icon Button for Dark Backgrounds */
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); color: #aaa; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); }
.btn-icon:hover { color: var(--accent); background: rgba(255,215,0,0.1); border-color: var(--accent); transform: scale(1.05); }

/* Inputs */
.input, .textarea, .select {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-main); padding: 10px 12px; border-radius: var(--radius-sm);
    width: 100%; font-family: inherit; font-size: 14px;
    transition: all 0.2s;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent); background: rgba(0,0,0,0.6);
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.1); outline: none;
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; padding-right: 30px; }

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-card); backdrop-filter: var(--glass);
}
.card-head {
    padding: 12px 16px; background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border);
    font-size: 13px; font-weight: 600; letter-spacing: 0.5px;
    display: flex; justify-content: space-between; align-items: center;
}
.card-body { padding: 16px; overflow-y: auto; flex: 1; }
.card-glass { background: rgba(255, 255, 255, 0.02); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-lg); }

/* Sidebar Fixed Mode */
.sidebar {
    width: 260px;
    background: rgba(10, 10, 12, 0.6);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    z-index: 50;
    backdrop-filter: blur(30px);
    overflow-x: hidden;
    flex-shrink: 0;
    box-shadow: 5px 0 30px rgba(0,0,0,0.2);
    transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), padding 0.25s;
}
.sidebar.collapsed {
    width: 60px;
    padding: 20px 6px;
}
.sidebar.collapsed .sidebar-item span { opacity: 0; width: 0; margin: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-item i { margin: 0; }
.sidebar.collapsed .sidebar-divider { margin: 6px 0; }
.sidebar.collapsed #local-sync-indicator { display: none !important; }

.sidebar-item {
    height: 44px;
    display: flex;
    align-items: center;
    border-radius: 12px;
    color: #888;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 16px;
    position: relative;
}

.sidebar-item:hover { background: rgba(255,255,255,0.08); color: #fff; transform: translateX(4px); }
.sidebar-item.active { background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), transparent); color: var(--accent); }

.sidebar-item i { width: 24px; text-align: center; font-size: 18px; flex-shrink: 0; color: #666; transition: all 0.3s; }
.sidebar-item.active i { color: var(--accent); transform: scale(1.1); filter: drop-shadow(0 0 8px rgba(255,215,0,0.4)); }
.sidebar-item:hover i { color: #fff; }

.sidebar-item span {
    margin-left: 14px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    transition: opacity 0.2s, width 0.2s, margin 0.2s;
}

.sidebar-divider { height: 1px; width: 100%; background: rgba(255,255,255,0.1); margin: 12px 0; }

/* Viewport */
.viewport { flex: 1; overflow: hidden; position: relative; background: transparent; display: flex; flex-direction: column; }

/* Layout Golden (2-Column System) */
.layout-golden {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}
.col-nav {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    min-width: 0;
    border-right: 1px solid rgba(255,255,255,0.05);
    background: rgba(10, 10, 12, 0.4);
    backdrop-filter: blur(20px);
}
.col-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
    min-width: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.2) 100%);
}

/* Writer Module Specifics */
.writer-grid { display: grid; grid-template-columns: 280px 1fr 320px; height: 100%; }
.writer-col { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); background: rgba(0,0,0,0.3); }
.writer-col:last-child { border-right: none; background: rgba(0,0,0,0.5); }

/* Toast */
.toast {
    position: fixed; top: 30px; left: 50%; transform: translateX(-50%) translateY(-20px);
    background: rgba(20, 20, 25, 0.95); color: #fff; border: 1px solid rgba(255,255,255,0.1);
    padding: 12px 30px; border-radius: 12px; z-index: 1000;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6); backdrop-filter: blur(20px);
    opacity: 0; animation: toastIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    font-weight: 600; font-size: 14px; letter-spacing: 0.5px;
    display: flex; align-items: center; gap: 10px;
}
.toast::before { content: ''; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 10px var(--accent); }
@keyframes toastIn { to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.4s var(--ease) forwards; }

/* Node Canvas */
.node-canvas { background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 24px 24px; background-color: var(--bg-app); }
.monitor-log { font-family: var(--font-mono); font-size: 11px; color: #888; background: #000; padding: 8px; max-height: 100px; overflow-y: auto; white-space: pre-wrap; border-radius: 4px; border: 1px solid #333; }

/* Custom Scrollbar for Epic Feel */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Markdown Content Styles */
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin-top: 1em; margin-bottom: 0.5em; font-weight: bold; color: #fff; line-height: 1.3; }
.markdown-body h1 { font-size: 1.8em; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.5em; }
.markdown-body p { margin-bottom: 1em; line-height: 1.7; color: #e0e0e0; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1em; padding-left: 1.5em; color: #d0d0d0; }
.markdown-body li { margin-bottom: 0.25em; }
.markdown-body code { background: rgba(255,255,255,0.1); padding: 0.2em 0.4em; rounded: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; color: #ff9e64; }
.markdown-body pre { background: #111; padding: 1em; rounded: 8px; overflow-x: auto; margin-bottom: 1em; border: 1px solid rgba(255,255,255,0.1); }
.markdown-body pre code { background: none; padding: 0; color: #ccc; }
.markdown-body blockquote { border-left: 4px solid var(--accent); padding-left: 1em; color: #888; margin-bottom: 1em; background: rgba(255,255,255,0.02); padding-top: 0.25rem; padding-bottom: 0.25rem; }
.markdown-body strong { color: #fff; font-weight: 700; }
.markdown-body em { color: #ccc; font-style: italic; }
.markdown-body table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.markdown-body th, .markdown-body td { border: 1px solid rgba(255,255,255,0.1); padding: 8px; text-align: left; }
.markdown-body th { background: rgba(255,255,255,0.05); font-weight: bold; color: #fff; }

/* --- THEME ENGINE UTILITIES --- */
[data-theme="light"] .epic-glass,
[data-theme="light"] .epic-card { border-color: var(--border-default); }
[data-theme="light"] .epic-card:hover { border-color: var(--accent-soft); }
[data-theme="light"] .sidebar { background: var(--bg-sidebar); }
[data-theme="sepia"] body { background: var(--bg-app); }
[data-theme="high_contrast"] * { border-width: 1px !important; }

/* Dynamic scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Editor font/size dynamic */
.editor-dynamic { font-family: var(--font-editor); font-size: var(--editor-size); line-height: var(--editor-lh); }

/* ═══════════════════════════════════════════════════════════════
   Rules Module — 世界规则管理
   ═══════════════════════════════════════════════════════════════ */
.rules-module { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.rules-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rules-title { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 0.5px; }
.rules-actions { display: flex; gap: 8px; }

.rules-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rules-tabs .tab-btn { display: flex; align-items: center; gap: 8px; padding: 12px 20px; font-size: 13px; font-weight: 600; border: none; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; transition: all 0.2s; }
.rules-tabs .tab-btn:hover { color: #fff; background: rgba(255,255,255,0.03); }
.rules-tabs .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(255,215,0,0.04); }
.rules-tabs .tab-btn svg { opacity: 0.5; }
.rules-tabs .tab-btn.active svg { opacity: 1; }
.tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,0.08); color: #888; }
.rules-tabs .tab-btn.active .tab-count { background: rgba(255,215,0,0.15); color: var(--accent); }

.rules-content { flex: 1; overflow-y: auto; padding: 16px 20px; }
.rules-empty { display: flex; align-items: center; justify-content: center; height: 200px; color: #555; font-size: 14px; }

.rule-card { background: rgba(255,255,255,0.02); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px; transition: all 0.2s; overflow: hidden; }
.rule-card:hover { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.04); }
.rule-card-header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.rule-card-actions { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.rule-card:hover .rule-card-actions { opacity: 1; }
.rule-card-body { padding: 14px 16px; }
.rule-name { font-size: 14px; font-weight: 700; color: #fff; margin: 0 0 6px 0; }
.rule-desc { font-size: 13px; color: #aaa; line-height: 1.6; margin: 0; }
.rule-examples, .rule-consequence { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.5; }
.rule-examples { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); color: #888; }
.rule-consequence { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.12); color: #f87171; }
.rule-examples-label, .rule-consequence-label { font-weight: 700; margin-right: 4px; }
.rule-examples-label { color: #666; }
.rule-consequence-label { color: #ef4444; }

.rule-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; }
.rule-badge-hard { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.rule-badge-soft { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.rule-category-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; }

/* Rules Form Overlay */
.rules-form-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); z-index: 100; display: flex; align-items: center; justify-content: center; }
.rules-form { width: 520px; max-width: 92vw; max-height: 85vh; }
.form-panel { background: rgba(18,18,20,0.98); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-lg); display: flex; flex-direction: column; box-shadow: 0 25px 60px rgba(0,0,0,0.5); max-height: 85vh; }
.form-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.form-panel-header h3 { font-size: 15px; font-weight: 700; color: #fff; margin: 0; }
.form-body { padding: 20px; overflow-y: auto; flex: 1; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #aaa; margin-bottom: 6px; }
.form-group .required { color: #ef4444; }
.form-input, .form-textarea, .form-select { width: 100%; background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm); color: #e0e0e0; padding: 10px 12px; font-size: 13px; font-family: inherit; transition: all 0.2s; outline: none; }
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,215,0,0.1); background: rgba(0,0,0,0.6); }
.form-textarea { resize: vertical; min-height: 60px; line-height: 1.6; }
.form-select { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; padding-right: 32px; }

.radio-group { display: flex; gap: 12px; }
.radio-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #ccc; cursor: pointer; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,0.08); transition: all 0.2s; flex: 1; }
.radio-label:hover { border-color: rgba(255,255,255,0.15); background: rgba(255,255,255,0.03); }
.radio-label input[type="radio"] { display: none; }
.radio-label input[type="radio"]:checked + .radio-dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 8px rgba(255,215,0,0.4); }
.radio-label input[type="radio"]:checked + .radio-dot::after { opacity: 1; }
.radio-label:has(input:checked) { border-color: rgba(255,215,0,0.3); background: rgba(255,215,0,0.05); }
.radio-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #555; background: transparent; transition: all 0.2s; position: relative; flex-shrink: 0; }
.radio-dot::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: #000; opacity: 0; transition: opacity 0.2s; }
.radio-dot-hard { border-color: rgba(239,68,68,0.5); }
.radio-label input[type="radio"]:checked + .radio-dot-hard { border-color: #ef4444; background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.radio-dot-soft { border-color: rgba(59,130,246,0.5); }
.radio-label input[type="radio"]:checked + .radio-dot-soft { border-color: #3b82f6; background: #3b82f6; box-shadow: 0 0 8px rgba(59,130,246,0.4); }
