/* Base */
html, body { overflow-x: hidden; }
body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    padding: 1rem;
    margin: 0;
}
@media (min-width: 768px) {
    body { padding: 2rem; }
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Layout */
.container {
    max-width: 80rem;
    margin: 0 auto;
}

.app-header {
    margin-bottom: 2rem;
    text-align: center;
}
.app-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem;
}
@media (min-width: 768px) {
    .app-header h1 { font-size: 2.25rem; }
}
.app-header p {
    color: #475569;
    max-width: 42rem;
    margin: 0 auto;
}

.app-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
}
@media (min-width: 1024px) {
    .app-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .controls-col { grid-column: span 3 / span 3; min-width: 0; }
    .viz-col { grid-column: span 9 / span 9; min-width: 0; }
}

.controls-col { min-width: 0; }
.controls-col > * + * { margin-top: 1.5rem; }

.viz-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    min-width: 0;
}
@media (min-width: 1024px) {
    .viz-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .viz-pane { grid-column: span 2 / span 2; }
}
.viz-col > * { min-width: 0; }

/* Cards */
.card {
    background-color: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease;
}
.card.pad-lg { padding: 1.5rem; }

/* Headings */
.panel-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}
.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem;
}
.section-desc {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0 0 1rem;
}

/* Form fields */
.field { margin-bottom: 1.5rem; }
.field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}
.field-select {
    width: 100%;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    padding: 0.625rem;
    display: block;
}
.field-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 1px #6366f1;
}

/* Ligand list */
.ligand-list {
    max-height: 16rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}
.ligand-list > * + * { margin-top: 0.5rem; }
.ligand-row {
    display: flex;
    align-items: center;
    background-color: #f8fafc;
    padding: 0.25rem;
    border-radius: 0.25rem;
}
.ligand-swatch {
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
}
.ligand-name {
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    width: 4rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: 0.5rem;
}
.ligand-select {
    flex: 1 1 0;
    font-size: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

/* Orbital buttons */
.orbital-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}
.orbital-btn {
    background-color: #f1f5f9;
    color: #475569;
    padding: 0.5rem 0;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.orbital-btn:hover { background-color: #e2e8f0; }
.orbital-btn.active {
    background-color: #e0e7ff;
    color: #4338ca;
}
.orbital-btn.active:hover { background-color: #c7d2fe; }
.orbital-btn.wide { grid-column: span 2 / span 2; }

/* Slider */
.slider-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}
.slider {
    width: 100%;
    cursor: pointer;
}
.slider-label {
    font-size: 0.875rem;
    color: #475569;
    position: absolute;
    bottom: -1.25rem;
}
.slider-label.start { inset-inline-start: 0; }
.slider-label.end { inset-inline-end: 0; }

/* Checkboxes */
.check-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}
.check-row:last-child { margin-bottom: 0; }
.check-box {
    width: 1rem;
    height: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.125rem;
    background-color: #f1f5f9;
}
.check-label {
    user-select: none;
    margin-inline-start: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e293b;
}

/* 3D viz pane */
.viz-pane {
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
}
.viz-pane__header {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.viz-pane__heading {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.viz-pane__desc {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
}
.viz-pane__hint {
    font-size: 0.75rem;
    text-align: right;
    color: #94a3b8;
}
.viz-canvas {
    position: relative;
    width: 100%;
    height: 24rem;
    background-color: #000;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    overflow: hidden;
}

/* Chart panes */
.chart-pane {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-container-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

#orbital-viz { width: 100%; height: 100%; min-height: 400px; }
#energy-viz { width: 100%; height: 100%; }

.chart-constrained {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 300px;
    max-height: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Footer */
.app-footer {
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
    padding: 2rem 0;
    margin-top: 2rem;
}
.app-footer p { margin: 0; }
