/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Light Theme (Default) */
:root,
[data-theme="light"] {
    --primary-color: #5865f2;
    --primary-hover: #4752c4;
    --secondary-color: #8b5cf6;
    --background: #ffffff;
    --surface: #f2f3f5;
    --surface-hover: #e3e5e8;
    --border: #e3e5e8;
    --text-primary: #2e3338;
    --text-secondary: #4e5058;
    --text-muted: #80848e;
    --success: #23a559;
    --warning: #f0b232;
    --danger: #f23f43;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #5865f2;
    --primary-hover: #4752c4;
    --secondary-color: #8b5cf6;
    --background: #36393f;
    --surface: #2f3136;
    --surface-hover: #292b2f;
    --border: #202225;
    --text-primary: #dcddde;
    --text-secondary: #b9bbbe;
    --text-muted: #72767d;
    --success: #3ba55d;
    --warning: #faa81a;
    --danger: #ed4245;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

/* Java Brown Theme */
[data-theme="java"] {
    --primary-color: #8B4513;
    --primary-hover: #6F3609;
    --secondary-color: #D2691E;
    --background: #F5E6D3;
    --surface: #E8D5C4;
    --surface-hover: #D9C3AE;
    --border: #C4A57B;
    --text-primary: #3E2723;
    --text-secondary: #5D4037;
    --text-muted: #8D6E63;
    --success: #689F38;
    --warning: #F57C00;
    --danger: #D32F2F;
    --shadow-sm: 0 1px 2px 0 rgb(62 39 35 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(62 39 35 / 0.15);
    --shadow-lg: 0 10px 15px -3px rgb(62 39 35 / 0.2);
    --shadow-xl: 0 20px 25px -5px rgb(62 39 35 / 0.25);
}

/* Java theme specific adjustments */
[data-theme="java"] .sidebar {
    background: linear-gradient(180deg, #D2691E 0%, #8B4513 100%);
    color: #F5E6D3;
}

[data-theme="java"] .sidebar .logo {
    color: #F5E6D3;
}

[data-theme="java"] .btn-primary {
    background: #6F3609;
    color: #F5E6D3;
}

[data-theme="java"] .btn-primary:hover {
    background: #5A2A07;
}

[data-theme="java"] .btn-secondary {
    background: #8D6E63;
    color: #F5E6D3;
}

[data-theme="java"] .btn-secondary:hover {
    background: #6F5549;
}

[data-theme="java"] .editor {
    background: #FFF8F0;
    color: #3E2723;
}

[data-theme="java"] .toolbar {
    background: #D2691E;
    color: #F5E6D3;
    border-bottom: 2px solid #8B4513;
}

[data-theme="java"] .btn-icon {
    color: #F5E6D3;
}

[data-theme="java"] .btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Theme Toggle Buttons */
.theme-toggle {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    background: var(--surface);
    border: 3px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.theme-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.theme-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.theme-icon {
    font-size: 3rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.theme-name {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.theme-btn.active .theme-name {
    color: white;
}

/* Welcome Actions */
.welcome-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.btn-secondary-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary-large:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Midnight Theme */
[data-theme="midnight"] {
    --primary-color: #7289da;
    --primary-hover: #5b6eae;
    --secondary-color: #9b84ee;
    --background: #1e2124;
    --surface: #282b30;
    --surface-hover: #1e2124;
    --border: #0e0f11;
    --text-primary: #e6e7e8;
    --text-secondary: #b0b3b8;
    --text-muted: #5c5e66;
    --success: #43b581;
    --warning: #faa61a;
    --danger: #f04747;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

/* Forest Theme */
[data-theme="forest"] {
    --primary-color: #57ab5a;
    --primary-hover: #46954a;
    --secondary-color: #7ee787;
    --background: #0d1117;
    --surface: #161b22;
    --surface-hover: #1c2128;
    --border: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8d96a0;
    --text-muted: #6e7681;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --primary-color: #ff6b6b;
    --primary-hover: #ee5a52;
    --secondary-color: #ffa07a;
    --background: #2d1b1e;
    --surface: #3d2327;
    --surface-hover: #4d2b2f;
    --border: #1d0b0e;
    --text-primary: #ffe5e5;
    --text-secondary: #ffb3b3;
    --text-muted: #cc8888;
    --success: #51cf66;
    --warning: #ffd43b;
    --danger: #ff6b6b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --primary-color: #4dabf7;
    --primary-hover: #339af0;
    --secondary-color: #74c0fc;
    --background: #1a2332;
    --surface: #243447;
    --surface-hover: #2d3f56;
    --border: #0f1419;
    --text-primary: #e3f2fd;
    --text-secondary: #90caf9;
    --text-muted: #5c7a99;
    --success: #4ecdc4;
    --warning: #ffe66d;
    --danger: #ff6b9d;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--background);
    line-height: 1.6;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth transitions for theme changes */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Prevent transition on page load */
.no-transition * {
    transition: none !important;
}

/* Layout */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding-bottom: 80px; /* Space for app footer */
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-footer {
    padding: 1rem;
    padding-bottom: 6rem; /* Space for app footer */
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-row {
    display: flex;
    gap: 0.5rem;
}

.footer-row .btn-secondary {
    flex: 1;
}

.btn-full {
    width: 100%;
}

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

.project-item {
    padding: 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.project-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.project-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.project-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-item.active .project-item-meta {
    color: rgba(255, 255, 255, 0.8);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 80px; /* Space for app footer */
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* Custom scrollbar for welcome screen */
.welcome-screen::-webkit-scrollbar {
    width: 10px;
}

.welcome-screen::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.welcome-screen::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.welcome-screen::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .welcome-screen,
[data-theme="midnight"] .welcome-screen,
[data-theme="forest"] .welcome-screen,
[data-theme="sunset"] .welcome-screen,
[data-theme="ocean"] .welcome-screen {
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    color: var(--text-primary);
}

[data-theme="dark"] .feature-card,
[data-theme="midnight"] .feature-card,
[data-theme="forest"] .feature-card,
[data-theme="sunset"] .feature-card,
[data-theme="ocean"] .feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
}

[data-theme="dark"] .btn-large,
[data-theme="midnight"] .btn-large,
[data-theme="forest"] .btn-large,
[data-theme="sunset"] .btn-large,
[data-theme="ocean"] .btn-large {
    background: var(--primary-color);
    color: white;
}

.welcome-content {
    max-width: 1200px;
    text-align: center;
    padding: 2rem 0;
    width: 100%;
}

.welcome-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.welcome-content > p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 3rem;
}

.feature-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.15);
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Editor View */
.editor-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-center {
    flex: 1;
    text-align: center;
}

.project-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.divider {
    color: var(--border);
    margin: 0 0.5rem;
}

.word-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 0.375rem;
}

.save-status {
    font-size: 0.875rem;
    color: var(--success);
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.3s;
}

.save-status.saving {
    color: var(--warning);
}

.save-status.error {
    color: var(--danger);
}

/* Editor Container */
.editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Document Tree */
.document-tree {
    width: 250px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.tree-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.tree-content {
    flex: 1;
    padding: 0.5rem;
}

.tree-item {
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.tree-item:hover {
    background: var(--surface-hover);
}

.tree-item.active {
    background: var(--primary-color);
    color: white;
}

.tree-item-icon {
    font-size: 0.875rem;
}

.tree-item-name {
    flex: 1;
    font-size: 0.875rem;
}

.tree-item-actions {
    display: none;
    gap: 0.25rem;
}

.tree-item:hover .tree-item-actions {
    display: flex;
}

/* Writing Area */
.writing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.editor {
    flex: 1;
    padding: 3rem;
    font-family: 'Merriweather', Georgia, serif;
    font-size: 16px;
    line-height: 1.8;
    border: none;
    outline: none;
    resize: none;
    background: var(--background);
    color: var(--text-primary);
}

.editor::placeholder {
    color: var(--text-muted);
}

.preview {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    background: var(--surface);
    border-left: 1px solid var(--border);
    font-family: 'Merriweather', Georgia, serif;
    font-size: 16px;
    line-height: 1.8;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.preview p {
    margin-bottom: 1rem;
}

.preview a {
    color: var(--primary-color);
    text-decoration: none;
}

.preview a:hover {
    text-decoration: underline;
}

.preview code {
    background: var(--surface-hover);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875em;
}

.preview pre {
    background: var(--surface-hover);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.preview blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
}

/* Research Panel */
.research-panel {
    width: 350px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

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

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    background: var(--surface-hover);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.panel-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.research-textarea {
    width: 100%;
    height: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    resize: none;
    outline: none;
}

.research-textarea:focus {
    border-color: var(--primary-color);
}

/* Corkboard View */
.corkboard-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #d4a574;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.corkboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.corkboard-header h2 {
    color: #4a3728;
}

.corkboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    overflow-y: auto;
    padding: 1rem;
}

.cork-card {
    background: #fef3c7;
    padding: 1.5rem;
    border-radius: 0.25rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    cursor: move;
    position: relative;
    min-height: 200px;
    transform: rotate(-1deg);
    transition: transform 0.2s;
}

.cork-card:nth-child(even) {
    transform: rotate(1deg);
}

.cork-card:hover {
    transform: rotate(0deg) scale(1.05);
    z-index: 10;
}

.cork-card::before {
    content: '📌';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
}

.cork-card-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #4a3728;
}

.cork-card-content {
    font-size: 0.875rem;
    color: #6b5744;
    line-height: 1.6;
}

/* Binder View */
.binder-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.binder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.binder-content {
    flex: 1;
    overflow-y: auto;
}

.binder-item {
    padding: 1rem;
    margin: 0.5rem 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.binder-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.binder-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.binder-item-icon {
    font-size: 1.25rem;
}

.binder-item-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.binder-item-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-left: 2rem;
}

/* Graph View */
.graph-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.graph-canvas {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
}

.graph-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.btn-large {
    padding: 1rem 2rem;
    background: white;
    color: var(--primary-color);
    border: none;
    border-radius: 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-xl);
}

.btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.btn-icon {
    padding: 0.5rem 0.75rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-icon:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon-small {
    padding: 0.25rem 0.5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--background);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: 'Inter', sans-serif;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.export-btn {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    font-weight: 500;
}

.export-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* History List */
.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.history-item-date {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.history-item-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Settings */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
}

.settings-group input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.settings-group input[type="range"] {
    flex: 1;
    margin: 0 0.5rem;
}

/* Focus Mode */
body.focus-mode .sidebar,
body.focus-mode .toolbar,
body.focus-mode .document-tree,
body.focus-mode .research-panel {
    display: none;
}

body.focus-mode .editor {
    max-width: 800px;
    margin: 0 auto;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -280px;
        z-index: 50;
        height: 100%;
    }
    
    .sidebar.open {
        transform: translateX(280px);
    }
    
    .document-tree {
        width: 200px;
    }
    
    .research-panel {
        width: 100%;
        position: absolute;
        right: -100%;
        transition: right 0.3s;
    }
    
    .research-panel.open {
        right: 0;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
}

/* AI & Cloud Features */
.ai-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.ai-btn {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ai-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.ai-results {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    max-height: 500px;
    overflow-y: auto;
}

.ai-results h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

/* Backlinks Panel */
.backlinks-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 350px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 90;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.backlinks-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.backlink-item {
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.backlink-item:hover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.backlink-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.backlink-project {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.backlink-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Wiki-style Links in Editor */
.editor-link {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

.editor-link:hover {
    background: var(--primary-color);
    color: white;
    padding: 0 0.25rem;
    border-radius: 0.25rem;
}

/* Cloud Sync Status */
.cloud-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.cloud-status.synced {
    color: var(--success);
}

.cloud-status.syncing {
    color: var(--warning);
}

.cloud-status.offline {
    color: var(--text-muted);
}

/* Writing Goals & Gamification */
.goals-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.goal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.goal-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--background);
    border-radius: 12px;
    overflow: hidden;
    margin: 0.75rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}

.streak-display {
    text-align: center;
    padding: 1rem;
}

.streak-number {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.achievement-badge {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.achievement-badge.unlocked {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color)10, transparent);
}

.achievement-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.achievement-badge.locked .achievement-icon {
    filter: grayscale(100%);
    opacity: 0.3;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.75rem;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Achievement Notification */
.achievement-notification {
    position: fixed;
    top: 2rem;
    right: -400px;
    width: 350px;
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    display: flex;
    gap: 1rem;
    transition: right 0.3s ease;
}

.achievement-notification.show {
    right: 2rem;
}

.achievement-notification .achievement-icon {
    font-size: 3rem;
}

.achievement-content {
    flex: 1;
}

.achievement-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.achievement-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.25rem 0;
}

.achievement-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Analytics Dashboard */
.analytics-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.analytics-tabs .tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: -2px;
}

.analytics-tabs .tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.analytics-content {
    min-height: 400px;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 0.5rem;
}

.metric-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.metric-card h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.metric-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 0.375rem;
    text-align: center;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* World Builder */
.world-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.world-tabs .tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.world-tabs .tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.world-content {
    min-height: 500px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.item-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.item-card h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.item-card .item-role {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.item-card .item-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-view {
    margin-top: 1rem;
}

.timeline-event {
    position: relative;
    padding-left: 2.5rem;
    padding-bottom: 2rem;
    border-left: 2px solid var(--border);
}

.timeline-event:last-child {
    border-left-color: transparent;
}

.timeline-marker {
    position: absolute;
    left: -0.5rem;
    top: 0;
    width: 1rem;
    height: 1rem;
    background: var(--primary-color);
    border-radius: 50%;
    border: 3px solid var(--background);
}

.timeline-date {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.timeline-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.timeline-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Import Modal */
.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
}

.import-dropzone:hover,
.import-dropzone.drag-over {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.import-preview {
    margin-top: 1.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
}

.file-name {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 1rem;
}

.file-remove {
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

/* Character Form */
.character-form,
.location-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 1rem;
}

.form-section {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.form-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.form-section input,
.form-section textarea,
.form-section select {
    width: 100%;
    margin-bottom: 0.75rem;
}

.form-section input:last-child,
.form-section textarea:last-child,
.form-section select:last-child {
    margin-bottom: 0;
}

/* Modal Size Variants */
.modal-content.modal-large {
    max-width: 900px;
    width: 90vw;
}

/* Worlddata Options */
.worlddata-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* ============================================
   COMPACT MODE (Auto-enabled for 1920x1080)
   ============================================ */

.compact-mode {
    --compact-padding: 0.75rem;
    --compact-font-size: 0.875rem;
    --compact-line-height: 1.4;
}

/* Reduce toolbar height */
.compact-mode .toolbar {
    padding: 0.5rem 1rem;
    min-height: 48px;
}

.compact-mode .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Reduce sidebar width */
.compact-mode .sidebar {
    width: 220px;
}

/* Reduce font sizes */
.compact-mode .editor {
    font-size: var(--compact-font-size);
    line-height: var(--compact-line-height);
    padding: var(--compact-padding);
}

.compact-mode .project-title {
    font-size: 1rem;
}

.compact-mode .word-count,
.compact-mode .save-status {
    font-size: 0.75rem;
}

/* Reduce modal sizes */
.compact-mode .modal-content {
    max-width: 600px;
    padding: 1.5rem;
}

.compact-mode .modal-header h2 {
    font-size: 1.25rem;
}

/* Reduce spacing */
.compact-mode .feature-card {
    padding: 1rem;
}

.compact-mode .form-group {
    margin-bottom: 0.75rem;
}

.compact-mode .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.compact-mode .btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Reduce document tree spacing */
.compact-mode .tree-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* Reduce research panel */
.compact-mode .research-panel {
    width: 280px;
}

/* Tighter welcome screen */
.compact-mode .welcome-content {
    max-width: 700px;
}

.compact-mode .features-grid {
    gap: 1rem;
}

/* Compact toolbar buttons - hide labels, show only icons */
.compact-mode .toolbar-left,
.compact-mode .toolbar-right {
    gap: 0.25rem;
}

/* ============================================
   GAMIFICATION & GOALS STYLES
   ============================================ */

.goals-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.goal-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.goal-card.full-width {
    grid-column: 1 / -1;
}

.goal-card h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Progress Bars */
.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--background);
    border-radius: 12px;
    overflow: hidden;
    margin: 0.75rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Streak Display */
.stat-large {
    text-align: center;
    margin-bottom: 1rem;
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-small {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.stat-small .stat-value {
    font-size: 1.5rem;
}

/* Achievements Grid */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.achievement-badge {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background: var(--background);
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.achievement-badge.unlocked {
    background: var(--surface);
    border-color: var(--primary-color);
}

.achievement-badge.locked {
    opacity: 0.4;
    filter: grayscale(100%);
}

.achievement-badge .achievement-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.achievement-badge .achievement-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.achievement-badge .achievement-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Achievement Notification */
.achievement-notification {
    position: fixed;
    top: 80px;
    right: -400px;
    width: 350px;
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: right 0.3s ease;
    z-index: 10000;
}

.achievement-notification.show {
    right: 20px;
}

.achievement-notification .achievement-icon {
    font-size: 3rem;
}

.achievement-notification .achievement-content {
    flex: 1;
}

.achievement-notification .achievement-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.achievement-notification .achievement-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.achievement-notification .achievement-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
}

.stat-item .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-item .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* App Footer */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.footer-links span {
    color: var(--text-muted);
}

/* Hide footer in editor view */
#editorView:not(.hidden) ~ .app-footer {
    display: none;
}

/* ============================================
   UPGRADE PROMPT STYLES
   ============================================ */

.upgrade-prompt {
    text-align: center;
    padding: 2rem;
}

.upgrade-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.upgrade-prompt h3 {
    color: var(--primary-color);
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.upgrade-prompt p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.feature-list {
    text-align: left;
    max-width: 400px;
    margin: 1.5rem auto;
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.pricing {
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    color: white;
}

.pricing .price {
    font-size: 3rem;
    font-weight: 700;
}

.pricing .period {
    font-size: 1.25rem;
    opacity: 0.9;
}

.upgrade-note {
    margin-top: 1.5rem;
    color: var(--text-muted);
}

/* AI Modal Tabs */
.ai-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.ai-tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-tab-btn:hover {
    color: var(--primary-color);
}

.ai-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.ai-tab-content {
    display: none;
    padding: 1.5rem 0;
}

.ai-tab-content.active {
    display: block;
}

.ai-results {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.names-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.name-card {
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.name-card:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* AI Usage Indicator */
.ai-usage-indicator {
    display: inline-block;
    margin-left: 1rem;
}

.usage-badge,
.premium-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.usage-badge {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.usage-badge.usage-depleted {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.premium-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    border: none;
}

/* Analytics Display Styles */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.metric-card {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.readability-score {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.score-value {
    font-size: 3rem;
    font-weight: 700;
}

.score-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.word-tag {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.pace-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.pace-bar .bar {
    height: 24px;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Handbook Viewer */
.handbook-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.handbook-viewer {
    max-height: 600px;
    overflow-y: auto;
    padding: 2rem;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.handbook-viewer h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.handbook-viewer h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.handbook-viewer h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.handbook-viewer p {
    line-height: 1.8;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.handbook-viewer ul,
.handbook-viewer ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.handbook-viewer li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.handbook-viewer code {
    background: var(--surface);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.handbook-viewer pre {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.handbook-viewer table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.handbook-viewer th,
.handbook-viewer td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.handbook-viewer th {
    background: var(--surface);
    font-weight: 600;
}

.handbook-viewer a {
    color: var(--primary-color);
    text-decoration: none;
}

.handbook-viewer a:hover {
    text-decoration: underline;
}

.handbook-viewer hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2rem 0;
}

/* Print Styles */
@media print {
    .sidebar,
    .toolbar,
    .document-tree,
    .research-panel,
    .backlinks-panel,
    .app-footer {
        display: none;
    }
    
    .editor {
        padding: 1in;
        max-width: 100%;
    }
}

/* ============================================
   AUTHENTICATION UI STYLES
   ============================================ */

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: 8px;
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    animation: fadeIn 0.3s;
}

.auth-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
}

.account-info {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.account-info p {
    margin-bottom: 0.75rem;
}

.account-info p:last-child {
    margin-bottom: 0;
}

.account-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-secondary {
    background: var(--surface);
    color: var(--text-secondary);
}

.error-message {
    background: rgba(242, 63, 67, 0.1);
    color: var(--danger);
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#auth-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   AI ANALYTICS MODAL STYLES
   ============================================ */

.ai-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.ai-tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.ai-tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.ai-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.ai-tab-content {
    animation: fadeIn 0.3s;
}

.ai-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.ai-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.ai-section select,
.ai-section input {
    margin-bottom: 1rem;
}

.ai-results {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.ai-results h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.results-content {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 6px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.names-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
}

.names-grid .name-item {
    background: var(--background);
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.names-grid .name-item:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#insertSuggestionBtn {
    margin-top: 1rem;
}

/* AI Report Styling */
.ai-report {
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--primary-color);
    color: white;
}

.report-header h4 {
    margin: 0;
    font-size: 1.125rem;
}

.report-date {
    font-size: 0.875rem;
    opacity: 0.9;
}

.report-content {
    padding: 1.5rem;
    line-height: 1.8;
}

.report-content h3 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.report-content h4 {
    color: var(--text-primary);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
}

.report-content h5 {
    color: var(--text-secondary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.report-content p {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.report-content ul {
    margin: 1rem 0;
    padding-left: 2rem;
}

.report-content li {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.report-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.export-md-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Loading state */
.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.ai-loading::before {
    content: "🤖";
    font-size: 2rem;
    animation: pulse 1.5s infinite;
}

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