:root {
    --bg-dark: #0D0D0D;
    --bg-panel: #1A1A1A;
    --text-primary: #DFE6E9;
    --text-secondary: #636E72;
    --accent: #E17055;
    --accent-hover: #D63031;
    --border: #2D3436;
    
    --success: #00B894;
    --error: #FF7675;
    
    --font-ui: 'Inter', sans-serif;
    --font-mono: 'Courier Prime', monospace;
    
    --radius: 12px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.6;
    min-height: 100vh;
}

#app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

header h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.db-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    background: var(--bg-panel);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.indicator.error { background-color: var(--error); box-shadow: 0 0 8px var(--error); }
.indicator.success { background-color: var(--success); box-shadow: 0 0 8px var(--success); }

/* Layout */
.container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    flex: 1;
    min-height: 0; /* Important for flex-child scrolling */
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.mt-4 { margin-top: 16px; }

.panel-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

/* Story elements */
.typewriter-text {
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.8;
    color: #B2BEC3;
    animation: fadeIn 1.5s ease;
}

.typewriter-text strong {
    color: var(--text-primary);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.schema-hint {
    margin-top: 24px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.schema-hint h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

#schema-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#schema-list li {
    font-family: var(--font-mono);
    font-size: 12px;
    background: #2D3436;
    padding: 4px 10px;
    border-radius: 4px;
    color: #81ECEC;
}

.clues-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: rgba(225, 112, 85, 0.05); /* very subtle accent bg */
}

.clues-container h3 {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 12px;
}

#clues-list {
    list-style: none;
}

#clues-list li {
    font-size: 14px;
    padding: 12px;
    background: rgba(0,0,0,0.2);
    border-left: 3px solid var(--accent);
    margin-bottom: 8px;
    border-radius: 0 4px 4px 0;
    color: #DFE6E9;
    font-family: var(--font-mono);
    animation: fadeIn 0.5s ease;
}

.empty-clues {
    color: var(--text-secondary) !important;
    border-left: 3px solid var(--text-secondary) !important;
    font-family: var(--font-ui) !important;
    font-style: italic;
}

/* SQL Editor */
.editor-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
}

textarea#sql-editor {
    width: 100%;
    background: #000;
    color: #F8F8F2;
    font-family: var(--font-mono);
    font-size: 15px;
    padding: 16px;
    border: 1px solid #333;
    border-radius: 8px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}

textarea#sql-editor:focus {
    border-color: var(--accent);
}

.editor-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

button {
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    transition: all 0.2s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

button.primary:not(:disabled):hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

button.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

button.secondary:hover {
    background: rgba(255,255,255,0.05);
}

/* Results Table */
.results-container {
    flex: 1;
    overflow: auto;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 13px;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    box-shadow: 0 1px 0 var(--border);
}

td.empty-results {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
    font-style: italic;
    font-family: var(--font-ui);
}

tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.meta-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-content h2 {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.schema-table-info {
    margin-bottom: 20px;
}
.schema-table-info h4 {
    color: var(--accent);
    font-family: var(--font-mono);
    margin-bottom: 8px;
}
.schema-table-info ul {
    list-style: none;
    font-family: var(--font-mono);
    font-size: 13px;
    color: #B2BEC3;
}
.schema-table-info li {
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }
    #app {
        height: auto;
    }
}
