/* ============================================================
   FPDF Visual Layout Designer — Stylesheet
   Professional dark theme with glassmorphism accents
   ============================================================ */

/* ============ RESET & VARIABLES ============ */
:root {
    /* Core palette */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2333;
    --bg-surface: #21262d;
    --bg-elevated: #2d333b;
    --bg-hover: #30363d;

    /* Accent colors */
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --accent-glow: rgba(88, 166, 255, 0.25);
    --accent-muted: rgba(88, 166, 255, 0.15);
    --accent-danger: #f85149;
    --accent-warning: #d29922;
    --accent-success: #3fb950;

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-link: #58a6ff;

    /* Borders */
    --border-default: #30363d;
    --border-muted: #21262d;
    --border-accent: #58a6ff;

    /* Rulers & Grid */
    --ruler-bg: #161b22;
    --ruler-text: #8b949e;
    --ruler-tick: #484f58;
    --ruler-highlight: rgba(88, 166, 255, 0.4);
    --grid-major: rgba(88, 166, 255, 0.12);
    --grid-minor: rgba(88, 166, 255, 0.05);

    /* Canvas */
    --canvas-bg: #0d1117;
    --canvas-page: #ffffff;
    --canvas-shadow: rgba(0, 0, 0, 0.6);

    /* Drawing */
    --draw-rect: #58a6ff;
    --draw-text: #3fb950;
    --draw-line: #f0883e;
    --draw-image: #bc8cff;
    --draw-table: #f778ba;
    --draw-selected: #ffd700;
    --draw-handle: #ffffff;

    /* Margins */
    --margin-color: rgba(248, 81, 73, 0.35);

    /* Layout */
    --toolbar-height: 52px;
    --ruler-size: 28px;
    --sidebar-width: 260px;
    --bottom-bar-height: 36px;

    /* Misc */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}


/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

::-webkit-scrollbar-corner {
    background: var(--bg-secondary);
}

/* ============ TOOLBAR ============ */
#toolbar {
    display: flex;
    align-items: center;
    height: var(--toolbar-height);
    min-height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-default);
    padding: 0 8px;
    gap: 4px;
    z-index: 100;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    white-space: nowrap;
}

.brand-icon {
    font-size: 20px;
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.brand-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--accent), #bc8cff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    background: var(--border-default);
    margin: 0 4px;
    flex-shrink: 0;
}

/* Tool Buttons */
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 48px;
    height: 42px;
    position: relative;
    font-family: var(--font-sans);
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.tool-btn.active {
    background: var(--accent-muted);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow), inset 0 0 8px var(--accent-glow);
}

.tool-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tool-btn:disabled:hover {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.tool-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
}

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

.icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Dropdowns */
.dropdown-wrapper select,
#page-template select {
    padding: 4px 24px 4px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    height: 28px;
}

.dropdown-wrapper select:hover,
#page-template select:hover {
    border-color: var(--accent);
}

.dropdown-wrapper select:focus,
#page-template select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ============ MAIN LAYOUT ============ */
#main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: auto var(--ruler-size) 1fr auto auto;
    grid-template-rows: var(--ruler-size) 1fr;
    grid-template-areas:
        "db-explorer corner  hruler   elements  inspector"
        "db-explorer vruler  canvas   elements  inspector";
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
}

/* Ruler Corner */
#ruler-corner {
    grid-area: corner;
    background: var(--ruler-bg);
    border-right: 1px solid var(--border-default);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

#ruler-corner span {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Horizontal Ruler */
#ruler-h-container {
    grid-area: hruler;
    background: var(--ruler-bg);
    border-bottom: 1px solid var(--border-default);
    overflow: hidden;
    position: relative;
    z-index: 50;
}

#ruler-h {
    display: block;
    width: 100%;
    height: 100%;
}

/* Vertical Ruler */
#ruler-v-container {
    grid-area: vruler;
    background: var(--ruler-bg);
    border-right: 1px solid var(--border-default);
    overflow: hidden;
    position: relative;
    z-index: 50;
}

#ruler-v {
    display: block;
    width: 100%;
    height: 100%;
}

/* Canvas Viewport */
#canvas-viewport {
    grid-area: canvas;
    background: var(--canvas-bg);
    overflow: auto;
    position: relative;
    cursor: crosshair;
    /* Subtle dot pattern background */
    background-image: radial-gradient(circle, var(--bg-elevated) 1px, transparent 1px);
    background-size: 20px 20px;
}

#canvas-container {
    position: relative;
    margin: 40px auto;
    box-shadow: 0 8px 32px var(--canvas-shadow), 0 2px 8px rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

#canvas-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Layer ordering */
#layer-pdf {
    z-index: 1;
}

#layer-grid {
    z-index: 2;
}

#layer-draw {
    z-index: 3;
}

#layer-cursor {
    z-index: 4;
    pointer-events: none;
}

/* Make the top interactive layer receive events */
#layer-draw {
    cursor: crosshair;
}

/* ============ SIDEBAR PANELS ============ */
.sidebar {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-default);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    transition: width var(--transition-normal), opacity var(--transition-normal), border var(--transition-normal);
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 36px;
    overflow: hidden;
}

.sidebar.collapsed .inspector-header h2,
.sidebar.collapsed .inspector-content {
    display: none;
}

.sidebar.collapsed .inspector-header {
    padding: 10px 0;
    justify-content: center;
    border-bottom: none;
}

#elements-panel {
    grid-area: elements;
}

#inspector-panel {
    grid-area: inspector;
}

.inspector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.inspector-header h2 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.inspector-content {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.inspector-section {
    padding: 12px;
}

.inspector-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent-muted);
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    padding: 0 5px;
}

.inspector-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
}

.inspector-row label {
    color: var(--text-secondary);
    font-weight: 500;
}

.inspector-row span {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-size: 11px;
}

.inspector-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.inspector-grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px;
}

.inspector-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.inspector-field.full-width {
    grid-column: 1 / -1;
}

.inspector-field label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.inspector-field input,
.inspector-field select {
    padding: 5px 6px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
    width: 100%;
    transition: border var(--transition-fast);
}

.inspector-field select {
    padding-right: 24px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.inspector-field input:focus,
.inspector-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.inspector-field input[type="number"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.inspector-field input[type="number"]::-webkit-inner-spin-button,
.inspector-field input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

.inspector-actions {
    margin-top: 12px;
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--accent-danger);
    border-radius: var(--radius-sm);
    background: rgba(248, 81, 73, 0.1);
    color: var(--accent-danger);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.2);
}

/* No Selection State */
.no-selection-msg {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
}

.no-selection-msg p {
    margin-top: 8px;
    font-size: 12px;
}

.no-selection-msg .hint {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 4px;
    line-height: 1.4;
}

.elements-list {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
}

.no-elements {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    padding: 10px 0;
}

.element-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    transition: background var(--transition-fast);
}

.element-item:hover {
    background: var(--bg-hover);
}

.element-item.selected {
    background: var(--accent-muted);
    color: var(--accent);
}

.element-item .el-icon {
    width: 14px;
    text-align: center;
    font-size: 10px;
    flex-shrink: 0;
}

.element-item .el-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.element-item .el-pos {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
}

/* ============ BOTTOM BAR ============ */
#bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--bottom-bar-height);
    min-height: var(--bottom-bar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-default);
    padding: 0 12px;
    z-index: 100;
    flex-shrink: 0;
}

.bottom-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

#page-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    user-select: none;
}

#page-indicator strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Coordinate Display */
#coord-display {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    gap: 4px;
    background: var(--bg-surface);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-muted);
}

.coord-label {
    color: var(--text-muted);
    font-weight: 600;
}

.coord-value {
    color: var(--accent);
    font-weight: 500;
    min-width: 44px;
    display: inline-block;
    text-align: right;
}

.coord-unit {
    color: var(--text-muted);
    font-size: 10px;
}

.coord-sep {
    color: var(--border-default);
    margin: 0 2px;
}

/* Zoom Controls */
#zoom-controls {
    gap: 4px;
}

.zoom-value {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
    text-align: center;
    user-select: none;
}

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 90vw;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease;
}

.modal-lg {
    width: 640px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 16px;
}

.modal-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.modal-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal-field input,
.modal-field select {
    padding: 8px 10px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    transition: border var(--transition-fast);
}

.modal-field input:focus,
.modal-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-default);
}

/* Buttons */
.btn {
    padding: 7px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

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

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

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

.modal-hint {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-sm);
}

.modal-hint small {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-hint code {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Code Block */
.code-block {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    overflow: auto;
    max-height: 400px;
    white-space: pre;
    tab-size: 4;
}

/* ============ TOAST NOTIFICATIONS ============ */
#toast-container {
    position: fixed;
    bottom: 56px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease;
    max-width: 320px;
}

.toast.toast-success {
    border-left: 3px solid var(--accent-success);
}

.toast.toast-error {
    border-left: 3px solid var(--accent-danger);
}

.toast.toast-info {
    border-left: 3px solid var(--accent);
}

.toast-exit {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============ CLICK MARKER ============ */
.click-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: clickPulse 0.6s ease forwards;
    z-index: 100;
}

@keyframes clickPulse {
    0% {
        width: 4px;
        height: 4px;
        opacity: 1;
        border-width: 2px;
    }

    100% {
        width: 24px;
        height: 24px;
        opacity: 0;
        border-width: 1px;
    }
}

/* ============ COORDINATE TOOLTIP ============ */
.coord-tooltip {
    position: absolute;
    padding: 3px 7px;
    background: rgba(13, 17, 23, 0.92);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
    pointer-events: none;
    white-space: nowrap;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============ DIMENSION LABEL (during drawing) ============ */
.dim-label {
    position: absolute;
    padding: 2px 6px;
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
    pointer-events: none;
    white-space: nowrap;
    z-index: 200;
}

/* ============ PROJECTS MODAL ============ */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.project-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

.project-item.active-project {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

.project-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.project-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.project-date {
    font-size: 11px;
    color: var(--text-muted);
}

.project-actions {
    display: flex;
    gap: 8px;
}

.project-actions .btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.project-actions .btn-icon:hover {
    color: var(--accent-danger);
    background: rgba(248, 81, 73, 0.1);
}

#export-library-select {
    padding: 6px 10px;
    background-color: var(--bg-tertiary);
    color: var(--text-base);
    border: 1px solid var(--border-color);
    border-radius: 6px;

    /* Important fixes */
    color-scheme: dark;
    /* Helps modern browsers */
}

/* Dropdown items */
#export-library-select option {
    background-color: var(--bg-tertiary);
    /* Dark background */
    color: var(--text-base);
}

/* Selected item */
#export-library-select option:checked {
    background-color: var(--accent);
    /* Blue highlight */
    color: #ffffff;
}

/* Disabled-looking options fix */
#export-library-select option:disabled {
    color: #888888;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    :root {
        --inspector-width: 220px;
    }
}

@media (max-width: 768px) {
    :root {
        --inspector-width: 0px;
    }

    #inspector-panel {
        display: none;
    }

    .toolbar-brand .brand-text {
        display: none;
    }

    .tool-label {
        display: none;
    }

    .tool-btn {
        min-width: 36px;
        height: 36px;
    }

    #toolbar {
        height: 44px;
        min-height: 44px;
    }
}

/* ============ DATABASE EXPLORER (GLASSMORPHISM) ============ */
.db-explorer {
    grid-area: db-explorer;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    background: rgba(22, 27, 34, 0.75);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all var(--transition-normal);
    z-index: 60;
}

.db-explorer.collapsed {
    width: 36px;
    opacity: 1;
    pointer-events: auto;
}

.db-explorer.collapsed .inspector-header h2,
.db-explorer.collapsed .inspector-content {
    display: none;
}

.db-explorer.collapsed .inspector-header {
    padding: 10px 0;
    justify-content: center;
    border-bottom: none;
}

.db-explorer.collapsed #btn-toggle-db-sidebar {
    transform: rotate(180deg);
}

.db-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.db-table-node {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.db-table-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.db-table-header:hover {
    background: rgba(88, 166, 255, 0.1);
}

.db-table-icon {
    color: var(--accent);
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.db-table-node.expanded .db-table-icon {
    transform: rotate(90deg);
}

.db-table-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

.db-column-list {
    list-style: none;
    padding: 0 0 8px 34px;
    display: none;
}

.db-table-node.expanded .db-column-list {
    display: block;
}

.db-column-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: grab;
    transition: color var(--transition-fast);
}

.db-column-item:hover {
    color: var(--accent);
}

.db-column-item:active {
    cursor: grabbing;
}

.db-column-type {
    font-size: 9px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Animations */
@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.db-table-node {
    animation: slideIn 0.3s ease forwards;
}

.db-search-wrapper {
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.db-search-inner {
    position: relative;
    display: flex;
    align-items: center;
}

.db-search-inner .search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.db-search-input {
    width: 100%;
    padding: 8px 30px 8px 32px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-sans);
    transition: all var(--transition-normal);
}

.db-search-input:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.db-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.db-search-input:focus + .search-icon {
    color: var(--accent);
}

.clear-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.db-search-input:not(:placeholder-shown) ~ .clear-btn {
    display: flex;
}

/* Highlight matching text */
.db-highlight {
    background: rgba(255, 215, 0, 0.3);
    color: #fff;
    border-radius: 2px;
    padding: 0 1px;
}
