/* CSS Custom Properties */
:root {
    /* Light theme */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #a5b4fc;
    --accent-color: #10d9c4;
    --accent-hover: #0ea5e9;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --backdrop: #fefefe;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --info-color: #06b6d4;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
    
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', monospace;
}

/* Dark theme - Darkest Black Design */
[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #a5b4fc;
    --accent-color: #10b981;
    --accent-hover: #059669;
    
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    
    --background: #000000;
    --surface: #000000;
    --surface-hover: #0a0a0a;
    --backdrop: #000000;
    
    --border-color: #1f2937;
    --border-light: #374151;
    
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --info-color: #06b6d4;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.9);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.9), 0 2px 4px -2px rgb(0 0 0 / 0.7);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.95), 0 4px 6px -4px rgb(0 0 0 / 0.9);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.95), 0 10px 10px -5px rgb(0 0 0 / 0.9);
}

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

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--backdrop);
    min-height: 100vh;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 8px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

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

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.125rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: gradient-shift 3s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
}

.theme-toggle-btn {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    width: 64px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.theme-toggle-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    background: var(--surface-hover);
}

.theme-icon {
    font-size: 1rem;
    transition: all 0.3s ease;
    position: absolute;
}

.dark-icon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .light-icon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .dark-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Main Layout */
.main-layout {
    flex: 1;
    display: flex;
    gap: 0.75rem;
    min-height: 0;
    overflow: hidden;
}

/* Control Panel */
.control-panel {
    width: 380px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    background: var(--background);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Diagram Area */
.diagram-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.diagram-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    min-height: 0;
    transition: all 0.3s ease;
}

/* Input Cards */
.input-card, .unified-input-card {
    background: var(--background);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.unified-input-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-card h3, .unified-input-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Control Panel Sections */
.api-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.api-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.description-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    resize: vertical;
    min-height: 80px;
}

.action-section {
    display: flex;
    gap: 0.5rem;
}

.code-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.code-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.code-actions {
    display: flex;
    gap: 0.25rem;
}

/* Editor Section */
.editor-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-container {
    flex: 1;
    display: flex;
    gap: 1rem;
    min-height: 0;
}

/* Code and Preview Panels */
.code-panel,
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    min-height: 0;
    transition: all 0.3s ease;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.action-btn {
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

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

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.25rem;
}

.zoom-btn {
    background: transparent;
    border: none;
    padding: 0.3rem 0.5rem;
    margin: 0;
    font-size: 0.75rem;
    min-width: 28px;
}

.zoom-btn:hover {
    background: var(--primary-color);
    border: none;
}

.zoom-level {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    min-width: 45px;
    text-align: center;
    font-family: var(--font-mono);
}

.action-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

/* Code Editor */
.code-editor {
    flex: 1;
    display: flex;
    min-height: 0;
}

.code-editor-container {
    position: relative;
}

.code-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.example-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.example-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

#mermaidCodeEditor {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.4;
    resize: vertical;
    outline: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-height: 300px;
}

#mermaidCodeEditor:focus {
    border-color: var(--primary-color);
}

#mermaidCodeEditor::placeholder {
    color: var(--text-secondary);
}

/* Diagram Viewport and Container */
.diagram-viewport {
    flex: 1;
    background: var(--background);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.diagram-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.diagram-container:active {
    cursor: grabbing;
}

.diagram-container svg {
    max-width: none !important;
    height: auto !important;
    transition: all 0.3s ease;
}

.diagram-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--text-secondary);
}

.placeholder-content {
    text-align: center;
}

.placeholder-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* Examples */
.examples-card {
    flex-shrink: 0;
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.example-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.example-item strong {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.example-item span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* API Key Section */
.api-key-input {
    position: relative;
    display: flex;
    align-items: center;
}

.api-key-input input {
    flex: 1;
    padding: 0.75rem;
    padding-right: 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.api-key-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
}

.toggle-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.security-notice {
    font-size: 0.8rem;
    color: var(--warning-color);
    margin-top: 0.25rem;
}

.get-key-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: inline-block;
}

.get-key-link:hover {
    text-decoration: underline;
}

/* Input Fields */
input, textarea {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input {
    padding: 0.75rem;
}

textarea {
    padding: 1rem;
    resize: vertical;
    min-height: 120px;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color), 0.1);
    background: var(--background);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Buttons */
.generate-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

.clear-btn {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

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

/* Loading Spinner */
.loading-spinner {
    animation: spin 1s linear infinite;
}

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

/* Examples Section */
.examples-section summary {
    cursor: pointer;
    padding: 1rem 0;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
    user-select: none;
}

.examples-section summary::-webkit-details-marker {
    display: none;
}

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

.example-card {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.example-card h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.example-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

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

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

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

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* Tab Content */
.tab-pane {
    display: none;
}

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

/* Code Section */
.code-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.copy-btn, .download-btn {
    background: var(--surface);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.copy-btn:hover, .download-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

pre {
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    line-height: 1.4;
}

pre code {
    font-size: 0.9rem;
}

/* Diagram Section */
.diagram-header {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.diagram-container {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

/* Error Section */
.error-section {
    background: rgb(239 68 68 / 0.1);
    border-color: var(--error-color);
    color: var(--error-color);
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.error-icon {
    font-size: 1.2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        margin-bottom: 1rem;
        padding: 0.5rem 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .header-text {
        order: 2;
    }
    
    .theme-toggle {
        order: 1;
        align-self: flex-end;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    .main-layout {
        flex-direction: column;
        height: auto;
        gap: 1rem;
    }
    
    .control-panel {
        width: 100%;
        min-width: unset;
        order: 2;
    }
    
    .content-area, .diagram-area {
        order: 1;
        min-height: 60vh;
    }
    
    .editor-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .code-panel,
    .preview-panel {
        min-height: 250px;
    }
    
    .panel-actions {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .action-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .input-card {
        padding: 0.75rem;
    }
    
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .sidebar {
        gap: 0.75rem;
    }
    
    .input-card h3 {
        font-size: 0.85rem;
    }
    
    .generate-btn, .clear-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .panel-header {
        padding: 0.5rem 0.75rem;
    }
    
    .panel-header h3 {
        font-size: 0.8rem;
    }
    
    #mermaidCodeEditor {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}

@media (min-width: 1400px) {
    .sidebar {
        width: 380px;
    }
    
    .main-layout {
        gap: 1.5rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #6366f1;
        --primary-hover: #5b5bf6;
        --secondary-color: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border-color: #334155;
        --background: #0f172a;
        --surface: #1e293b;
    }
    
    body {
        background: linear-gradient(135deg, var(--background) 0%, var(--surface) 100%);
    }
}

/* Enhanced Mermaid Diagram Styling */
.mermaid {
    max-width: 100%;
    height: auto;
    background: transparent;
    border-radius: var(--radius);
    padding: 1rem;
}

/* Custom Mermaid Theme Overrides */
.mermaid svg {
    background: transparent !important;
    border-radius: var(--radius);
}

/* Dark mode diagram enhancements */
[data-theme="dark"] .mermaid svg {
    filter: brightness(1.1) contrast(1.05);
}

[data-theme="dark"] .mermaid .node rect,
[data-theme="dark"] .mermaid .node circle,
[data-theme="dark"] .mermaid .node ellipse,
[data-theme="dark"] .mermaid .node polygon {
    fill: var(--surface) !important;
    stroke: var(--border-light) !important;
    stroke-width: 2px !important;
}

[data-theme="dark"] .mermaid .edgePath path {
    stroke: var(--primary-light) !important;
    stroke-width: 2px !important;
}

[data-theme="dark"] .mermaid .edgeLabel {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
}

/* Light mode diagram enhancements */
[data-theme="light"] .mermaid svg {
    filter: contrast(1.1) saturate(1.1);
}

[data-theme="light"] .mermaid .node rect,
[data-theme="light"] .mermaid .node circle,
[data-theme="light"] .mermaid .node ellipse,
[data-theme="light"] .mermaid .node polygon {
    fill: #ffffff !important;
    stroke: var(--primary-color) !important;
    stroke-width: 2px !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

[data-theme="light"] .mermaid .edgePath path {
    stroke: var(--primary-color) !important;
    stroke-width: 2px !important;
}

/* Better text visibility */
.mermaid .nodeLabel,
.mermaid .edgeLabel {
    font-family: var(--font-sans) !important;
    font-weight: 500 !important;
    font-size: 14px !important;
}

[data-theme="dark"] .mermaid .nodeLabel {
    fill: var(--text-primary) !important;
}

[data-theme="light"] .mermaid .nodeLabel {
    fill: var(--text-primary) !important;
}

/* Diagram error styling */
.diagram-error {
    padding: 2rem;
    text-align: center;
    color: var(--error-color);
    background: rgb(239 68 68 / 0.1);
    border: 2px solid var(--error-color);
    border-radius: var(--radius);
    margin: 1rem 0;
}

.diagram-error details {
    margin-top: 1rem;
    text-align: left;
}

.diagram-error summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.5rem;
    background: rgb(239 68 68 / 0.1);
    border-radius: var(--radius);
}

.diagram-error pre {
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Loading animation */
.diagram-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.diagram-loading::after {
    content: '⏳';
    margin-left: 0.5rem;
    animation: spin 2s linear infinite;
}