:root {
    --bg-app: #0F172A;
    --bg-panel: #1E293B;
    --bg-hover: #334155;
    --bg-preview: #F8FAFC;

    --border-color: #334155;
    --border-focus: #EC4899;

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    --color-primary: #EC4899;
    --color-primary-hover: #DB2777;
    --color-secondary: #06B6D4;
    --color-secondary-hover: #0891B2;
    --color-danger: #EF4444;
    --color-danger-bg: rgba(239, 68, 68, 0.1);

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.block {
    display: block !important;
}

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

.text-sm {
    font-size: 0.85rem;
}

.w-full {
    width: 100%;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

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

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 4px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.form-select {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px;
    padding: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--border-focus);
}

/* Header */
.navbar {
    height: 56px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary);
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Editor Pane */
.editor-pane {
    width: 40%;
    min-width: 300px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.pane-header {
    height: 48px;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.pane-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

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

/* CodeMirror overrides */
.CodeMirror {
    height: 100% !important;
    font-family: var(--font-mono) !important;
    font-size: 14px;
    background: transparent !important;
}

.error-panel {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    padding: 1rem;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

/* Preview Pane */
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-preview);
    position: relative;
}

.preview-pane .pane-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.preview-pane .pane-header h2 {
    color: #64748b;
}

.preview-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    border: none;
    cursor: grab;
}

.preview-wrapper:active {
    cursor: grabbing;
}

#mermaid-output {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mermaid-output svg {
    max-width: 100%;
    height: auto;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-close-modal {
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
}

.modal-body {
    padding: 1.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}