:root {
    /* Kainos light brand system (tokens from workday-agent-factory studio) */
    --k-blue: #1b2db5;
    --k-navy: #252d4f;
    --k-green: #61a83f;
    --k-forest: #004631;
    --k-lime: #cfd600;
    --k-tint: #edf3ff;
    --bg: #f0f0ed;
    --surface: #ffffff;
    --surface-hover: #f6f6f2;
    --surface-alpha: rgba(255, 255, 255, 0.96);
    --border: #dcdcd6;
    --text: #252d4f;
    --text-muted: #5a5f73;
    --accent: #1b2db5;
    --accent-hover: #3947d1;
    --accent-subtle: rgba(27, 45, 181, 0.08);
    --success: #2e7d32;
    --warning: #9a6a00;
    --error: #b3261e;
    --radius: 10px;
    --neuron-sensory: #3b82f6;
    --neuron-central: #8b5cf6;
    --neuron-drives: #f59e0b;
    --neuron-motor: #ef4444;
    --glow-purple: rgba(139, 92, 246, 0.15);
    --glow-blue: rgba(59, 130, 246, 0.1);
}

html,
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* --- Custom Scrollbars --- */
.connectome-grid,
#neuro-renderer-wrap,
.education-content,
.b3d-tip-neurons {
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.connectome-grid::-webkit-scrollbar,
#neuro-renderer-wrap::-webkit-scrollbar,
.education-content::-webkit-scrollbar,
.b3d-tip-neurons::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.connectome-grid::-webkit-scrollbar-track,
#neuro-renderer-wrap::-webkit-scrollbar-track,
.education-content::-webkit-scrollbar-track,
.b3d-tip-neurons::-webkit-scrollbar-track {
    background: transparent;
}

.connectome-grid::-webkit-scrollbar-thumb,
#neuro-renderer-wrap::-webkit-scrollbar-thumb,
.education-content::-webkit-scrollbar-thumb,
.b3d-tip-neurons::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 164, 0.3);
    border-radius: 3px;
}

.connectome-grid::-webkit-scrollbar-thumb:hover,
#neuro-renderer-wrap::-webkit-scrollbar-thumb:hover,
.education-content::-webkit-scrollbar-thumb:hover,
.b3d-tip-neurons::-webkit-scrollbar-thumb:hover {
    background: rgba(136, 146, 164, 0.5);
}

.connectome-grid::-webkit-scrollbar-corner,
#neuro-renderer-wrap::-webkit-scrollbar-corner,
.education-content::-webkit-scrollbar-corner,
.b3d-tip-neurons::-webkit-scrollbar-corner {
    background: transparent;
}

canvas {
    display: block;
    background-color: #fafaf7;
    transition: background-color 0.5s ease;
    touch-action: none;
}

.brainNode {
    border-radius: 50%;
    display: inline-block;
    height: 8px;
    width: 8px;
    flex-shrink: 0;
    transition: opacity .3s, box-shadow .3s;
    cursor: default;
}

.cg-dot {
    border-radius: 50%;
    display: inline-block;
    width: 3px;
    height: 3px;
    flex-shrink: 0;
    cursor: default;
    margin: 0.5px;
    vertical-align: middle;
}

.connectome-grid {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem 0;
}

.cg-region-badge {
    font-size: 0.4rem;
    font-weight: 700;
    width: 0.8rem;
    height: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid;
    border-radius: 2px;
    flex-shrink: 0;
    opacity: 0.7;
}

.cg-nodes {
    column-width: 140px;
    column-gap: 0.35rem;
    column-fill: auto;
    height: 100%;
}

.cg-node {
    display: flex;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    cursor: default;
    transition: background 0.15s;
    break-inside: avoid;
    margin-bottom: 1px;
}

.cg-dot-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    flex: 1;
    min-width: 0;
    line-height: 0;
}

.cg-node:hover {
    background: rgba(37, 45, 79, 0.05);
}

.cg-node.cg-active {
    background: rgba(37, 45, 79, 0.04);
}

.cg-name {
    font-size: 0.45rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: lowercase;
    letter-spacing: 0.01em;
    flex-shrink: 0;
    line-height: 1.2;
    padding-top: 1px;
}

#githubButton {
    height: 20px;
    filter: grayscale(1) brightness(0.35);
    opacity: 0.6;
    transition: opacity 0.2s ease;
    vertical-align: middle;
}

#githubButton:hover {
    opacity: 1;
}

.noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* --- Toolbar --- */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--surface-alpha);
    /* Kainos signature: lime rule under the top bar */
    border-bottom: 3px solid var(--k-lime);
    box-shadow: 0 1px 12px rgba(37, 45, 79, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    z-index: 20;
    font-family: system-ui, -apple-system, sans-serif;
    box-sizing: content-box;
}

.toolbar-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

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

.toolbar-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.toolbar-title:hover {
    color: var(--text);
}

.toolbar-icon {
    cursor: pointer;
    filter: grayscale(1) brightness(0.35);
    opacity: 0.6;
    transition: opacity 0.2s ease;
    vertical-align: middle;
}

.toolbar-icon:hover {
    opacity: 1;
}

.workday-logo {
    border-radius: 6px;
    flex-shrink: 0;
}

.tool-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: system-ui, -apple-system, sans-serif;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--k-tint);
    border-color: var(--accent);
    color: var(--text);
}

.tool-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    border-color: var(--border);
}

.tool-btn.active {
    border-color: var(--accent);
    background: var(--k-tint);
    color: var(--accent);
}

.tool-btn.claude-highlight:not(.active) {
    border-color: var(--accent);
    background: var(--k-tint);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(27, 45, 181, 0.25);
    transition: all 0.2s ease;
}

.tool-btn.active.claude-highlight {
    box-shadow: 0 0 12px rgba(27, 45, 181, 0.25);
    transition: box-shadow 0.2s ease;
}

.claude-status {
    position: fixed;
    right: 1rem;
    /* Bottom-right corner of the enclosure, above the connectome strip */
    bottom: calc(180px + 0.9rem);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 15;
    font-family: system-ui, -apple-system, sans-serif;
}

@media (max-width: 768px) {
    .claude-status {
        bottom: calc(140px + 0.9rem);
    }
}

/* Kainos watermark, studio-style: small wordmark in the corner of the
   fly's space (mirrors the agent builder diagram attribution) */
.coe-watermark {
    position: fixed;
    left: calc(320px + 16px);
    bottom: calc(180px + 12px);
    width: 104px;
    z-index: 5;
    pointer-events: none;
    color: var(--text-muted);
    opacity: 0.4;
    font-family: system-ui, -apple-system, sans-serif;
}

.coe-watermark svg {
    display: block;
    width: 100%;
    height: auto;
}

.coe-watermark .coe-sub {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    margin-top: 2px;
    text-align: center;
}

@media (max-width: 768px) {
    .coe-watermark {
        left: 12px;
        bottom: calc(140px + 10px);
    }
}

.claude-spark {
    color: #c65d3b;
    font-size: 0.95rem;
    line-height: 1;
    width: 1em;
    text-align: center;
    cursor: default;
}

.claude-status-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 400;
    color: #c65d3b;
}

/* --- Bottom Panel --- */
#left-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 180px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface-alpha);
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 16px rgba(37, 45, 79, 0.12);
    display: flex;
    flex-direction: row;
    z-index: 20;
    padding-top: 0.3rem;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
    overflow: hidden;
    gap: 0.5rem;
    box-sizing: content-box;
    font-family: system-ui, -apple-system, sans-serif;
}

#bottom-panel {
    display: none;
    gap: 1rem;
    font-family: system-ui, -apple-system, sans-serif;
}

#connectome-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.connectome-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

#drive-meters {
    flex-shrink: 0;
    width: 170px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
    justify-content: center;
}

.drive-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
}

.drive-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    width: auto;
    flex-shrink: 0;
    text-align: right;
}

.drive-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(37, 45, 79, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.drive-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}

#driveHunger {
    background: var(--warning);
}

#driveFear {
    background: var(--error);
}

#driveFatigue {
    background: var(--text-muted);
}

#driveCuriosity {
    background: var(--success);
}

#driveGroom {
    background: var(--accent);
}

.behavior-state {
    font-size: 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Help Overlay --- */
.help-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    /* margin:auto on the child centers it AND keeps tall content
       scrollable; align-items:center clips overflow at the edges */
    padding: 1.5rem;
    overflow-y: auto;
    background: rgba(37, 45, 79, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 90;
    font-family: system-ui, -apple-system, sans-serif;
}

.help-modal {
    position: relative;
    margin: auto;
    width: min(620px, 100%);
    max-height: none;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(37, 45, 79, 0.25);
    animation: help-modal-in 0.18s ease-out;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

@keyframes help-modal-in {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .help-modal {
        animation: none;
    }
}

.help-modal::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    /* Kainos lime-to-green hairline */
    background: linear-gradient(170deg, rgba(207, 214, 0, 0.45) 0%, rgba(0, 152, 63, 0.2) 40%, transparent 70%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* The communication chain: how a drive becomes a Workday request */
.help-chain {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.25rem 1.25rem 0.75rem;
    padding: 0.7rem 0.75rem;
    background: var(--k-tint);
    border: 1px solid #ccd6f6;
    border-radius: 12px;
}

.help-chain-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.15rem;
    flex: 1;
}

.help-chain-eyebrow {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--accent);
}

.help-chain-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.25;
}

.help-chain-arrow {
    align-self: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.help-modal-cta {
    display: block;
    margin: 0 1.25rem 1.25rem;
    padding: 0.55rem 1rem;
}

.help-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.25rem 0.7rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.help-close-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    line-height: 1;
    border-radius: 8px;
    transition: all 0.15s;
}

.help-close-btn:hover {
    background: var(--k-tint);
    color: var(--accent);
    border-color: var(--accent);
}

.help-about {
    padding: 0 1.25rem 0.6rem;
}

.help-about p {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.65;
    margin: 0 0 0.75rem 0;
}

.help-about p strong {
    font-weight: 700;
    color: var(--k-blue);
}

/* Standalone headline line keeps the gradient treatment */
.help-about p.help-headline strong {
    display: block;
    font-size: 0.95rem;
    margin: 0.4rem 0 0.2rem;
    background: linear-gradient(90deg, #1b2db5, #00983F);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.help-about em {
    font-style: italic;
    color: var(--text);
}

.help-about a {
    color: #8b9cf6;
    text-decoration: none;
    transition: color 0.15s;
}

.help-about a:hover {
    color: var(--accent);
}

.help-credits {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    padding: 0.65rem 1.25rem 0;
    border-top: 1px solid var(--border);
    line-height: 1.5;
    text-align: center;
}

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

.help-credits a:hover {
    color: var(--text);
}

.help-overlay-divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.15), transparent);
    margin: 0;
}

.help-overlay-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 0.8rem 1.25rem 0.4rem;
}

.help-item {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    padding: 0.4rem 1.25rem;
    line-height: 1.5;
    transition: all 0.12s;
    border-left: 2px solid transparent;
}

.help-item:last-child {
    padding-bottom: 1rem;
}

.help-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border-left-color: rgba(139, 92, 246, 0.4);
}

.help-item strong {
    color: var(--text);
    font-weight: 600;
}

/* --- Connectome Header (label + toggle) --- */
.connectome-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Telemetry line retired from the UI; JS still writes to the element */
.connectome-subtitle {
    display: none;
}

.scale-indicator {
    display: none;
}

/* --- Zoom Controls --- */
.zoom-controls {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 18;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    background: var(--surface-alpha);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, -apple-system, sans-serif;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
    padding: 0;
}

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

.zoom-btn:active {
    background: var(--border);
}

.connectome-subtitle.loading {
    color: var(--accent);
    opacity: 1;
}

.neuron-tooltip {
    display: none;
    position: fixed;
    background: var(--surface-alpha);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.7rem;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    pointer-events: none;
    z-index: 40;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(37, 45, 79, 0.2);
}

.connectome-toggle-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.6rem;
    font-family: system-ui, -apple-system, sans-serif;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.connectome-toggle-btn:hover {
    background: var(--k-tint);
    border-color: var(--accent);
    color: var(--text);
}

#nodeHolder.hidden {
    display: none;
}

#neuro-renderer-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#neuro-canvas {
    display: block;
    image-rendering: pixelated;
}

#neuro-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
}

/* --- Brain 3D Overlay --- */
#brain3d-overlay {
    position: fixed;
    top: calc(44px + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    bottom: 180px;
    z-index: 15;
    background: #0a0a1a;
}

#brain3d-overlay canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* --- Brain 3D Tooltip --- */
#brain3d-tooltip {
    position: fixed;
    z-index: 45;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-family: system-ui, -apple-system, sans-serif;
    pointer-events: none;
    max-width: 260px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.b3d-tip-name {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.b3d-tip-desc {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.b3d-tip-type {
    color: var(--accent);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.b3d-tip-neurons {
    border-top: 1px solid var(--border);
    padding-top: 0.3rem;
    max-height: 180px;
    overflow-y: auto;
}

.b3d-tip-neuron {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    padding: 0.1rem 0;
}

.b3d-tip-neuron-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b3d-tip-neuron-val {
    flex-shrink: 0;
    color: var(--text);
    font-weight: 500;
    min-width: 32px;
    text-align: right;
}

/* --- Education Panel (slide-out sidebar) --- */
.education-panel {
    position: fixed;
    top: 44px;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 90vw;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 25;
    font-family: system-ui, -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.education-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.education-panel-title {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
}

.education-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.education-close-btn:hover {
    color: var(--text);
}

.education-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.edu-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.edu-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.edu-section-title {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.edu-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0 0 0.5rem 0;
}

.edu-analogy {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0 0 0.5rem 0;
    font-style: italic;
}

.edu-analogy strong {
    font-style: normal;
    color: var(--text);
}

.edu-interaction {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0 0 0.5rem 0;
}

.edu-interaction strong {
    color: var(--accent);
}

.edu-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.edu-column {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.edu-column-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-align: center;
}

.edu-region-card {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: background 0.15s ease;
}

.edu-region-card:hover {
    background: var(--surface-hover);
}

.edu-detail-panel {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    background: var(--surface-hover);
}

.edu-region-link {
    cursor: pointer;
    color: var(--text);
    transition: color 0.2s ease;
}

.edu-region-link:hover {
    color: var(--accent);
}

.edu-type-badge {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.edu-type-sensory {
    color: var(--neuron-sensory);
    background: rgba(59, 130, 246, 0.15);
}

.edu-type-central {
    color: var(--neuron-central);
    background: rgba(139, 92, 246, 0.15);
}

.edu-type-drives {
    color: var(--neuron-drives);
    background: rgba(245, 158, 11, 0.15);
}

.edu-type-motor {
    color: var(--neuron-motor);
    background: rgba(239, 68, 68, 0.15);
}

.edu-neuron-list {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
    line-height: 1.6;
}

.edu-neuron-list strong {
    color: var(--text);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.edu-neuron-tag {
    display: inline-block;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin: 0.1rem;
    font-family: monospace;
}

.edu-population {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.25rem;
}

.edu-signal-flow {
    width: 100%;
    height: auto;
    margin: 0.5rem 0;
}

.edu-list {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.edu-list li {
    margin-bottom: 0.4rem;
}

.edu-links {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.edu-links li {
    margin-bottom: 0.5rem;
}

.edu-links a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.edu-links a:hover {
    color: var(--accent-hover);
}

/* --- Caretaker Activity Sidebar --- */
.caretaker-sidebar {
    position: fixed;
    top: 42px;
    left: 0;
    /* Stop above the 180px connectome strip so the neuron view stays fully visible */
    bottom: 180px;
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 30;
    font-family: system-ui, -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(37, 45, 79, 0.12);
    /* Desktop: permanent panel, never hidden. Mobile overrides below. */
    transform: none;
    transition: transform 0.3s ease;
}

.caretaker-sidebar.sheet-peek,
.caretaker-sidebar.sheet-full {
    transform: none;
}

/* Desktop: no closing the panel */
.caretaker-sidebar-close {
    display: none;
}

.caretaker-sidebar-handle {
    display: none;
}

@media (min-width: 1200px) {
    .caretaker-sidebar {
        width: 320px;
    }
}

.caretaker-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.caretaker-sidebar-title {
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
}

.caretaker-sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.caretaker-sidebar-close:hover {
    color: var(--text);
}

/* --- Sidebar Tabs --- */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0;
}

.sidebar-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-family: system-ui, -apple-system, sans-serif;
    white-space: nowrap;
    min-width: 0;
    padding: 0.85rem 0.25rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    text-align: center;
}

.sidebar-tab:hover {
    color: var(--text);
}

.sidebar-tab.active {
    color: var(--text);
    border-bottom-color: var(--k-lime);
}

.kainos-mark {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.kainos-mark:hover svg {
    opacity: 1;
}

.kainos-mark svg {
    display: block;
    height: 15px;
    width: auto;
    color: var(--text);
    opacity: 0.85;
    /* Optical alignment with the FlyBrain wordmark baseline; the svg
       viewBox carries descender space that sits the glyphs low */
    margin-top: -2px;
}

.sidebar-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar-tab-content.active {
    display: flex;
}

.activity-feed {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.activity-feed::-webkit-scrollbar {
    width: 6px;
}

.activity-feed::-webkit-scrollbar-track {
    background: transparent;
}

.activity-feed::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 164, 0.3);
    border-radius: 3px;
}

.activity-feed::-webkit-scrollbar-thumb:hover {
    background: rgba(136, 146, 164, 0.5);
}

.chat-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
    font-size: 0.8rem;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 164, 0.3);
    border-radius: 3px;
}

.chat-msg {
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    margin-bottom: 0.35rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg-user {
    background: var(--k-tint);
    color: var(--text);
    text-align: right;
}

/* Claude speaks in Claude terracotta */
.chat-msg-assistant {
    background: rgba(217, 119, 87, 0.16);
    color: var(--text);
}

.chat-msg-error {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
}

.chat-msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.chat-input-row {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-family: system-ui, -apple-system, sans-serif;
    outline: none;
}

.chat-input:focus {
    border-color: var(--accent);
}

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

.chat-send-btn {
    background: #d97757;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: system-ui, -apple-system, sans-serif;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: #e08b6d;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-loading {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
}

.chat-loading::after {
    content: '...';
    animation: chatDots 1.2s steps(4, end) infinite;
}

@keyframes chatDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.activity-entry {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    cursor: pointer;
    border-left: 3px solid var(--text-muted);
    background: transparent;
    transition: background 0.2s ease;
}

.activity-entry:hover {
    background: var(--surface-hover);
}

.activity-entry-header {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.3;
}

.activity-icon {
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    min-width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.activity-time {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.activity-desc {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-entry-detail {
    display: none;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 0.3rem;
    padding-left: 1.4rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.activity-entry.expanded .activity-entry-detail {
    display: block;
}

.activity-entry.expanded .activity-desc {
    white-space: normal;
}

/* Color-coded left borders and icon colors */
.activity-feed .activity-entry.activity-feed {
    border-left-color: var(--success);
}

.activity-feed .activity-entry.activity-feed .activity-icon {
    color: var(--success);
}

.activity-feed .activity-entry.activity-comfort {
    border-left-color: var(--neuron-sensory);
}

.activity-feed .activity-entry.activity-comfort .activity-icon {
    color: var(--neuron-sensory);
}

.activity-feed .activity-entry.activity-warning {
    border-left-color: var(--warning);
}

.activity-feed .activity-entry.activity-warning .activity-icon {
    color: var(--warning);
}

.activity-feed .activity-entry.activity-incident {
    border-left-color: var(--error);
}

.activity-feed .activity-entry.activity-incident .activity-icon {
    color: var(--error);
}

.activity-feed .activity-entry.activity-neutral {
    border-left-color: var(--text-muted);
}

.activity-feed .activity-entry.activity-neutral .activity-icon {
    color: var(--text-muted);
}

/* Activity toggle button (desktop) */
#activityToggle {
    display: inline-block;
}

#activityToggle.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

/* --- Caretaker Analytics Panel --- */
.analytics-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.analytics-section::-webkit-scrollbar {
    width: 6px;
}

.analytics-section::-webkit-scrollbar-track {
    background: transparent;
}

.analytics-section::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 164, 0.3);
    border-radius: 3px;
}

.analytics-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    gap: 0.5rem;
}

.analytics-content.collapsed {
    display: none;
}

.analytics-metric {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.analytics-score {
    align-items: center;
    padding: 0.5rem 0;
}

.analytics-score-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.analytics-metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.analytics-metric-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 0.15rem;
}

.analytics-metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analytics-legend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    margin-left: auto;
}

.analytics-legend-marker {
    display: inline-block;
    width: 8px;
    height: 3px;
    border-radius: 1px;
}

.analytics-sparkline-container {
    width: 100%;
    height: 40px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.25rem;
    box-sizing: border-box;
}

.analytics-sparkline-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.analytics-sparkline-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
    text-align: center;
}

/* --- Caretaker Calendar Panel --- */
.calendar-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.calendar-section::-webkit-scrollbar {
    width: 6px;
}

.calendar-section::-webkit-scrollbar-track {
    background: transparent;
}

.calendar-section::-webkit-scrollbar-thumb {
    background: rgba(136, 146, 164, 0.3);
    border-radius: 3px;
}

.calendar-content {
    padding: 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.calendar-content.collapsed {
    display: none;
}

.cal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cal-nav-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1;
}

.cal-nav-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.cal-nav-title {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-dow {
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    padding: 0.15rem 0;
    font-weight: 600;
}

.cal-cell {
    background: var(--bg);
    border-radius: 4px;
    padding: 0.2rem;
    min-height: 2.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.cal-cell:hover {
    border-color: var(--accent);
}

.cal-cell.cal-empty {
    background: transparent;
    cursor: default;
    border: none;
}

.cal-cell.cal-empty:hover {
    border-color: transparent;
}

.cal-cell.cal-selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.cal-cell.cal-green {
    background: rgba(74, 222, 128, 0.12);
}

.cal-cell.cal-yellow {
    background: rgba(251, 191, 36, 0.12);
}

.cal-cell.cal-red {
    background: rgba(248, 113, 113, 0.12);
}

.cal-cell.cal-nodata {
    background: var(--bg);
}

.cal-day {
    font-size: 0.65rem;
    color: var(--text);
    font-weight: 600;
    line-height: 1;
}

.cal-score {
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cal-green .cal-score {
    color: var(--success);
}

.cal-yellow .cal-score {
    color: var(--warning);
}

.cal-red .cal-score {
    color: var(--error);
}

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

.cal-details {
    display: flex;
    gap: 0.2rem;
    font-size: 0.5rem;
    color: var(--text-muted);
    line-height: 1;
}

.cal-no-activity {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 1rem 0.5rem;
    text-align: center;
}

.cal-feed-date-header {
    font-size: 0.75rem;
    color: var(--accent);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* --- Hamburger toggle (hidden on desktop) --- */
#sidebarToggle {
    display: none;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

/* --- Lite mode button (hidden on desktop) --- */
#liteBtn {
    display: none;
}

#liteBtn.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
}

/* --- Drawer backdrop --- */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(37, 45, 79, 0.4);
    z-index: 19;
}

.drawer-backdrop.visible {
    display: block;
}

/* ========================================
   FLY @ WORK (Workday tab)
   ======================================== */
.workday-section {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    font-family: system-ui, -apple-system, sans-serif;
}

.workday-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--surface-hover);
}

.workday-blurb {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Status is plain small-caps text, color-coded -- no pill chrome */
.workday-pill {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

.workday-pill-mock,
.workday-pill-live {
    color: var(--text-muted);
}

.workday-pill-ok {
    color: var(--success);
}

.workday-pill-fail {
    color: var(--error);
}

.workday-pill-fulfilled {
    color: var(--accent);
}

.sidebar-tab-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Public site: Chat and Analytics require the private local server.
   With Inbox as the only tab left, the whole tab row goes too. */
.public-mode .sidebar-tab[data-tab="chat"],
.public-mode .sidebar-tab[data-tab="analytics"],
.public-mode [data-tab-content="chat"],
.public-mode [data-tab-content="analytics"],
.public-mode .sidebar-tabs {
    display: none !important;
}

.sidebar-tabs .caretaker-sidebar-close {
    flex: 0 0 auto;
    align-self: center;
    padding: 0 0.6rem;
}

.workday-entry-actor {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.workday-entry-observed {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.15rem;
    line-height: 1.35;
}

/* Observer mode: Claude runs the enclosure; user interaction tools hidden.
   Buttons stay in the DOM (caretaker-bridge updates lightBtn/tempBtn text). */
#toolbar .tool-btn[data-tool],
#clearButton {
    display: none !important;
}

.workday-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 0.55rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.workday-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.workday-stat-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#wd-stat-meal_voucher { color: #c25705; }
#wd-stat-pto_request { color: var(--accent); }
#wd-stat-career_goal { color: var(--success); }
#wd-stat-kudos { color: var(--warning); }
#wd-stat-safety_concern { color: var(--error); }

.workday-actions-title {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.6rem 0.5rem 0;
    text-align: center;
}

.workday-stat-label {
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.workday-feed {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.workday-entry {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    background: transparent;
}

.workday-entry-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.workday-entry-summary {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

.workday-entry-reasoning {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    line-height: 1.35;
}

.workday-entry-meta {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-top: 0.2rem;
    word-break: break-all;
}

.wd-meta-time {
    color: var(--accent);
}

.wd-meta-ref {
    color: var(--success);
}

.wd-meta-tool {
    color: #c25705;
    cursor: pointer;
}

.wd-tool-pop {
    position: fixed;
    z-index: 60;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.7rem;
    box-shadow: 0 12px 40px rgba(37, 45, 79, 0.2);
    font-family: system-ui, -apple-system, sans-serif;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(136, 146, 164, 0.3) transparent;
}

.wd-tool-pop-title {
    font-family: monospace;
    font-size: 0.68rem;
    color: #c25705;
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.wd-tool-pop-desc {
    font-size: 0.7rem;
    color: var(--text);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.wd-tool-pop-block {
    margin-top: 0.5rem;
    background: #f6f6f2;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
}

.wd-tool-pop-label {
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.wd-tool-pop pre {
    margin: 0;
    font-size: 0.62rem;
    line-height: 1.5;
    color: #004631;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.workday-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.75rem 0.5rem;
    text-align: center;
}

/* ========================================
   MOBILE LAYOUT (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
    /* --- Region labels overlap on a squeezed strip; colors suffice --- */
    #neuro-labels {
        display: none;
    }

    /* --- Hamburger visible on mobile --- */
    #sidebarToggle {
        display: inline-block;
    }

    /* --- Compact toolbar: smaller buttons, tighter spacing --- */
    #toolbar {
        height: 36px;
        padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
    }

    .toolbar-left {
        gap: 0.25rem;
    }

    .toolbar-right {
        gap: 0.35rem;
    }

    .tool-btn {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }

    .toolbar-title {
        font-size: 0.75rem;
    }

    /* Hide non-essential toolbar items on mobile */
    #centerButton,
    #clearButton,
    #githubButton,
    #scaleIndicator {
        display: none !important;
    }

    /* Also hide the GitHub link anchor */
    .toolbar-right a {
        display: none;
    }

    /* --- Bottom panel: always visible, compact on mobile --- */
    #left-panel {
        height: 140px;
        flex-direction: row;
        padding-top: 0.3rem;
        z-index: 21;
        border-radius: 0;
        transform: none;
        transition: none;
    }


    #left-panel.drawer-open {
        height: 50vh;
        flex-direction: column;
    }


    /* Drawer handle indicator */
    #left-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0 auto 0.25rem auto;
        flex-shrink: 0;
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
    }

    /* Drive meters sit beside connectome, compact */
    #drive-meters {
        width: 100px;
        border-left: 1px solid var(--border);
        border-top: none;
        padding-left: 0.4rem;
        padding-top: 0;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.1rem;
    }

    #drive-meters.drawer-open {
        width: auto;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 0.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }

    .drive-row {
        min-width: 0;
    }

    /* --- Brain 3D overlay goes edge-to-edge on mobile --- */
    #brain3d-overlay {
        bottom: 0 !important;
    }

    /* --- Education panel full-width on mobile --- */
    .education-panel {
        width: 100%;
        max-width: 100vw;
        top: calc(36px + env(safe-area-inset-top, 0px));
    }

    .caretaker-sidebar {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100vw;
        height: 65vh;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 23;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .caretaker-sidebar {
        transform: translateY(100%);
    }

    .caretaker-sidebar.sheet-peek {
        transform: translateY(50%);
    }

    .caretaker-sidebar.sheet-full {
        transform: translateY(0);
    }

    /* Mobile keeps the close control for the bottom sheet */
    .caretaker-sidebar-close {
        display: inline-block;
    }

    .caretaker-sidebar-handle {
        display: block;
        box-sizing: content-box;
        width: 36px;
        height: 4px;
        /* Big invisible touch zone; the visible bar stays 36x4 */
        padding: 14px 60px 10px;
        background: var(--text-muted);
        background-clip: content-box;
        border-radius: 2px;
        margin: 0 auto;
        flex-shrink: 0;
        opacity: 0.5;
        cursor: grab;
        touch-action: none;
    }

    #activityToggle {
        display: none;
    }

    /* --- Help modal breathing room on small screens --- */
    .help-overlay {
        padding: 0.75rem;
    }
}

/* ========================================
   LANDSCAPE on mobile devices
   ======================================== */
@media (orientation: landscape) and (max-height: 500px) {
    #toolbar {
        height: 32px;
    }

    .tool-btn {
        padding: 0.15rem 0.4rem;
        font-size: 0.65rem;
    }

    /* In landscape, neuron panel sits beside canvas on right side */
    #left-panel {
        left: auto;
        right: 0;
        top: calc(32px + env(safe-area-inset-top, 0px));
        bottom: 0;
        width: 280px;
        max-height: none;
        height: auto;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        flex-direction: column;
        border-top: none;
        border-left: 1px solid var(--border);
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    #left-panel.drawer-open {
        transform: translateX(0);
    }

    #left-panel::before {
        display: none;
    }

    .caretaker-sidebar {
        top: calc(32px + env(safe-area-inset-top, 0px));
        left: 0;
        bottom: 0;
        right: auto;
        width: 260px;
        height: auto;
        border-radius: 0;
        border-top: none;
        border-right: 1px solid var(--border);
        box-shadow: 2px 0 10px rgba(37, 45, 79, 0.12);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .caretaker-sidebar.sheet-peek,
    .caretaker-sidebar.sheet-full {
        transform: translateX(0);
    }

    #drive-meters {
        border-top: 1px solid var(--border);
        flex-direction: column;
        flex-wrap: nowrap;
        width: auto;
        padding-top: 0.5rem;
    }

    .drive-row {
        flex: none;
        min-width: 0;
    }
}

/* Experiment links share the enclosure's light controls. */
.toolbar-right .experiment-link {
    display: inline-flex;
    color: var(--k-navy);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.toolbar-right .experiment-link:hover { background: var(--surface-hover); border-color: var(--k-green); }
.toolbar-right .experiment-link:focus-visible { outline: 2px solid var(--k-blue); outline-offset: 2px; }
@media (max-width: 600px) {
    .toolbar-right .experiment-link { padding: 5px 6px; font-size: 11px; }
}
