:root {
    color-scheme: light;
    --bg: #f6f6f6;
    --panel: rgba(255, 255, 255, 0.96);
    --panel-border: rgba(0, 0, 0, 0.08);
    --text: #111;
    --muted: #5b5b5b;
    --bad: #9f1d1d;
    --accent: #5a3ea1;
}

html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: var(--bg);
    color: var(--text);
}

body {
    box-sizing: border-box;
    padding: 18px;
}

body.isCanvasExpanded {
    overflow: hidden;
}

h1, h2, h3, p {
    margin: 0;
}

h1 {
    letter-spacing: 0.12em;
    font-size: 24px;
}

h2 {
    font-size: 15px;
}

h3 {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.microcosmLayout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    height: calc(100vh - 36px);
    min-height: 620px;
}

.panel {
    min-width: 0;
    min-height: 0;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
    overflow: auto;
}

.visualPanel {
    position: relative;
    display: grid;
    padding: 0;
    overflow: hidden;
}

.visualPanel:fullscreen {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
    background: var(--bg);
}

.visualPanel.isExpanded {
    position: fixed;
    inset: 12px;
    z-index: 100;
    border-radius: 12px;
}

.canvasControls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    pointer-events: auto;
}

.visualPanel:fullscreen .canvasControls, .visualPanel.isExpanded .canvasControls {
    top: 14px;
    right: 14px;
}

.visualPanel:fullscreen #wasmgpuCanvas, .visualPanel.isExpanded #wasmgpuCanvas {
    width: 100%;
    height: 100%;
}

#wasmgpuCanvas {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    background: #f6f6f6;
}

.summaryPanel, .diagnosticsPanel, .detailsPanel {
    display: grid;
    align-content: start;
    gap: 14px;
}

.diagnosticsPanel {
    grid-template-rows: auto minmax(0, 1fr);
}

.detailsPanel {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch;
    gap: 14px;
    min-height: 0;
    overflow: auto;
}

.detailsPanel > .infoBlock {
    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 0 0 auto;
}

.detailsPanel > .inspectorBlock, .detailsPanel > .memoryBlock, .detailsPanel > .errorBlock {
    position: static;
}

.titleBlock {
    display: grid;
    gap: 4px;
}

.subtitle {
    color: var(--muted);
    font-size: 13px;
}

.controls {
    display: grid;
    gap: 10px;
}

.buttonRow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compactButtons {
    justify-content: flex-end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    font-size: 12px;
    color: var(--muted);
}

.field input, .field select {
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

button {
    padding: 9px 13px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

button:hover {
    background: #f0f0f0;
}

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

#status {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.infoBlock {
    min-width: 0;
    min-height: 0;
}

.growBlock {
    overflow: auto;
}

.sectionHeader {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.brushControls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.inspectionGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.inspectorPane {
    min-height: 70px;
    padding: 9px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 10px;
    background: #fff;
}

.detailRow {
    display: grid;
    grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1fr);
    gap: 8px;
    padding: 3px 0;
    font-size: 12px;
}

.detailRow span {
    color: var(--muted);
}

.detailRow strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 650;
}

.smallNote {
    color: var(--muted);
    font-size: 12px;
}

.modeExplore {
    color: #164d72;
}

.modeEdit {
    color: var(--accent);
}

#diagnostics, #renderStats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.datum {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 9px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 10px;
    background: #fff;
}

.datum span {
    color: var(--muted);
    font-size: 11px;
}

.datum strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12px;
}

th, td {
    padding: 6px 7px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    text-align: left;
}

th {
    color: var(--muted);
    font-weight: 600;
}

tr.isBad td {
    color: var(--bad);
}

#samples {
    margin-top: 10px;
    display: grid;
    gap: 7px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.errorBlock {
    min-height: 0;
}

#errors {
    margin: 10px 0 0;
    min-height: 42px;
    max-height: 220px;
    white-space: pre-wrap;
    color: var(--bad);
    font-size: 12px;
    overflow: auto;
}

@media (max-width: 1050px) {
    .microcosmLayout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(280px, 42vh) auto auto auto;
        height: auto;
        min-height: 0;
    }

    .brushControls, .inspectionGrid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.richInspectionGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.wideInspectorSection {
    grid-column: 1 / -1;
}

.subsectionHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.copyButtonRow {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.inlineButton {
    padding: 5px 8px;
    border-radius: 7px;
    font-size: 11px;
}

.richPane {
    min-height: 88px;
}

.scrollPane {
    max-height: 280px;
    overflow: auto;
}

.detailSubsection {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.dataTable {
    margin-top: 0;
    font-size: 11px;
}

.dataTable th, .dataTable td {
    vertical-align: top;
}

.warningText {
    color: #7b4b00;
}

.errorText {
    color: var(--bad);
}

.jsonPreview {
    margin: 0;
    white-space: pre-wrap;
    font-size: 11px;
}

@media (max-width: 1050px) {
    .richInspectionGrid {
        grid-template-columns: minmax(0, 1fr);
    }
}
.genomeEditControls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.genomeEditActions {
    justify-content: flex-end;
    margin: 10px 0;
}

@media (max-width: 1050px) {
    .genomeEditControls {
        grid-template-columns: minmax(0, 1fr);
    }
}

#startupInfoModal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 14px;
    box-sizing: border-box;
    background: rgba(0,0,0,0.5);
}

#startupInfoModal[hidden] {
    display: none;
}

#startupInfoCard {
    position: relative;
    width: min(86vw, 86vh);
    height: min(86vw, 86vh);
    max-width: 820px;
    max-height: 820px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    background: #fff;
    color: #111;
    border-radius: 12px;
    box-shadow: 0 16px 42px rgba(0,0,0,0.3);
    line-height: 1.45;
}

#startupInfoCard h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

#startupInfoCard h3 {
    margin: 14px 0 6px;
    font-size: 15px;
}

#startupInfoCard ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

#startupInfoCard li {
    margin: 6px 0;
}

#startupInfoCard hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.15);
    margin: 10px 0;
}

#startupInfoCard h2 {
    margin: 0 0 6px;
    font-size: 17px;
}

#startupInfoClose {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 6px 10px;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 6px;
    background: #fff;
    color: #111;
    cursor: pointer;
    font: inherit;
}

#startupInfoScroll {
    height: 100%;
    overflow: auto;
    padding: 48px 20px 20px;
    box-sizing: border-box;
}

.startupLead {
    margin: 0 0 8px;
    text-align: center;
}

.startupTitle {
    text-align: center;
    letter-spacing: 0.22em;
}

.startupSection {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

#startupInfoCard .startupSection:first-of-type {
    margin-top: 10px;
    padding-top: 0;
    border-top: none;
}

.startupSection p {
    margin: 7px 0;
}

.mathBlock {
    margin: 6px 0;
    padding: 6px 8px;
    overflow-x: auto;
    background: #fff;
    border-radius: 6px;
}

#startupInfoCard .katex-display, #startupInfoCard .katex {
    background: #fff;
}

.inlineInfoHeader {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.inlineCopyReactionsButton {
    padding: 4px 8px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 6px;
    background: #fff;
    color: #111;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    line-height: 1.2;
}
