/* Tokyo Night */
:root {
    --bg: #1a1b26;
    --bg-alt: #16161e;
    --panel: #24283b;
    --border: #3b4261;
    --fg: #c0caf5;
    --muted: #9aa5ce;
    --blue: #7aa2f7;
    --green: #9ece6a;
    --red: #f7768e;
    --orange: #ff9e64;
    --purple: #bb9af7;
    --teal: #7dcfff;
    --topbar: 44px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
}

a {
    color: var(--blue);
    text-decoration: none;
    cursor: pointer;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1rem;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}

.topbar .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--fg);
}

.topbar nav {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.topbar .user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

main {
    height: calc(100% - var(--topbar));
}

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.page-fill {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.lead {
    font-size: 1.15rem;
}

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

.error {
    color: var(--red);
    white-space: pre-wrap;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.card {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--fg);
}

.card:hover {
    border-color: var(--blue);
    text-decoration: none;
}

button, .button {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    background: var(--panel);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
}

button:hover, .button:hover {
    border-color: var(--blue);
}

button.primary {
    background: var(--blue);
    color: var(--bg);
    border-color: var(--blue);
}

input, select, textarea {
    background: var(--bg-alt);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.5rem;
    font: inherit;
}

table {
    border-collapse: collapse;
    width: 100%;
}

td, th {
    text-align: left;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
    word-break: break-all;
}

.dropzone {
    margin: 3rem auto;
    max-width: 640px;
    padding: 3rem 2rem;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: 12px;
}

.dropzone.over {
    border-color: var(--blue);
    background: var(--panel);
}

.subbar {
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

/* Diagram viewer */
.viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.toolbar .spacer {
    flex: 1;
}

.toolbar .zoom {
    color: var(--muted);
    min-width: 3rem;
    justify-content: center;
    padding: 0 0.25rem;
    text-align: center;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* Toolstrip: icon tools in bordered groups */
.toolbar {
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    min-height: 2.6rem;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.tool-group {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding-right: 0.4rem;
    border-right: 1px solid var(--border);
}

.tool-group:last-of-type {
    border-right: none;
}

button.tool {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 1.85rem;
    padding: 0 0.55rem;
    border-color: transparent;
    background: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

button.tool.icon {
    width: 1.85rem;
    padding: 0;
    justify-content: center;
}

button.tool:hover:not(:disabled) {
    background: var(--panel);
    border-color: var(--border);
}

button.tool:disabled {
    opacity: 0.35;
    cursor: default;
}

button.tool.active {
    background: var(--panel);
    border-color: var(--blue);
    color: var(--blue);
}

button.tool.primary {
    background: var(--blue);
    color: var(--bg);
    border-color: var(--blue);
    font-weight: 600;
}

button.tool.primary:hover:not(:disabled) {
    background: var(--teal);
    border-color: var(--teal);
}

svg.icon {
    flex: none;
    display: block;
}

.problems-button .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--panel);
    color: var(--muted);
}

.problems-button.has-errors .error-count {
    background: var(--red);
    color: var(--bg);
}

.problems-button.has-warnings .warning-count,
.problems-button.has-errors .warning-count {
    color: var(--orange);
}

.save-group {
    gap: 0.4rem;
    padding: 0 0 0 0.6rem;
    border-left: 1px solid var(--border);
    border-right: none;
}

.save-group .changes {
    color: var(--orange);
    font-size: 0.8rem;
    white-space: nowrap;
}

.save-group .change-message {
    width: 12rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* Breadcrumbs over the canvas */
.diagram nav.crumbs {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    max-width: calc(100% - 1rem);
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: color-mix(in srgb, var(--bg-alt) 88%, transparent);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.diagram nav.crumbs .crumb {
    cursor: pointer;
}

.diagram nav.crumbs .crumb:last-child {
    color: var(--blue);
    font-weight: 600;
}

.diagram.light nav.crumbs {
    background: rgba(255, 255, 255, 0.9);
    border-color: #c8ccd8;
}

.diagram.light nav.crumbs .crumb {
    color: #1a1b26;
}

/* A block's name or an annotation being edited where it shows */
.diagram textarea.annotate-in-place {
    position: absolute;
    z-index: 6;
    padding: 0.25rem 0.4rem;
    font: inherit;
    font-size: 0.85rem;
    border: 1px solid var(--blue);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    resize: both;
}

.diagram input.rename-in-place {
    position: absolute;
    z-index: 6;
    padding: 0.1rem 0.3rem;
    font-size: 0.85rem;
    text-align: center;
    border: 1px solid var(--blue);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* Hover card: what the block under a resting pointer is */
.hover-card {
    position: absolute;
    z-index: 4;
    max-width: 18rem;
    padding: 0.4rem 0.6rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    animation: hover-card-in 0.12s ease-out 0.45s forwards;
}

@keyframes hover-card-in {
    to {
        opacity: 1;
    }
}

.hover-card .hover-name {
    font-weight: 600;
}

.hover-card .muted {
    color: #a9b1d6;
}

.hover-card table {
    margin-top: 0.25rem;
    border-collapse: collapse;
}

.hover-card td {
    padding: 0 0.6rem 0 0;
    vertical-align: top;
    overflow-wrap: anywhere;
}

/* A line's data tip stays within the box `diagram.rs` keeps in view. */
.hover-card.line-tip {
    box-sizing: border-box;
    max-width: 300px;
    max-height: 110px;
    overflow: hidden;
}

.hover-card.line-tip > div {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Shortcut help */
.shortcut-help {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    max-height: calc(100% - 1rem);
    overflow: auto;
    padding: 0.6rem 0.8rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    font-size: 0.85rem;
    cursor: default;
    z-index: 5;
}

.shortcut-help .shortcut-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.shortcut-help th {
    text-align: left;
    padding-top: 0.6rem;
    color: var(--muted);
    font-weight: 600;
}

.shortcut-help td {
    padding: 0.12rem 0.8rem 0.12rem 0;
    vertical-align: top;
}

kbd {
    font-family: inherit;
    font-size: 0.78rem;
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--bg-alt);
    white-space: nowrap;
}

.context-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.context-menu {
    position: fixed;
    display: flex;
    flex-direction: column;
    min-width: 13rem;
    padding: 0.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
}

.context-menu .menu-item {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    border: none;
    background: none;
    text-align: left;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.context-menu .menu-item:hover {
    background: var(--bg-alt);
}

.context-menu .shortcut {
    color: var(--muted);
}

.context-menu .submenu {
    display: flex;
    flex-direction: column;
    padding-left: 0.8rem;
}

.crumbs .crumb {
    color: var(--fg);
}

.crumb-sep {
    color: var(--muted);
    margin: 0 0.35rem;
}

.viewer-body {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

.viewer-body .inspector-close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 8;
}

/* Room for the close button beside the inspector's heading. */
.viewer-body .inspector > :first-child {
    margin-right: 1.8rem;
}

/* Narrow screens: the side panel and inspector lie over the canvas */
@media (max-width: 760px) {
    .viewer-body .tree {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 7;
        width: min(85vw, 280px);
        box-shadow: 4px 0 18px rgba(0, 0, 0, 0.45);
    }

    .viewer-body .inspector {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        z-index: 7;
        width: min(90vw, 320px);
        box-shadow: -4px 0 18px rgba(0, 0, 0, 0.45);
    }

    /* Tools keep their icons; names show in their tooltips. */
    .toolbar button.tool > span:not(.count) {
        display: none;
    }

    .toolbar .save-group .change-message,
    .toolbar .save-group .changes {
        display: none;
    }
}

.tree {
    width: 240px;
    overflow: auto;
    padding: 0.75rem;
    border-right: 1px solid var(--border);
    background: var(--bg-alt);
}

.system-tree ul {
    list-style: none;
    padding-left: 0.7rem;
    margin: 0.1rem 0;
}

.system-tree li {
    white-space: nowrap;
}

.system-tree .twisty {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: none;
    background: none;
    vertical-align: middle;
}

.system-tree button.twisty::before {
    content: "";
    display: block;
    width: 0;
    height: 0;
    margin: 0.3rem 0 0 0.35rem;
    border-left: 5px solid var(--muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.1s;
}

.system-tree button.twisty.open::before {
    transform: rotate(90deg);
}

.system-tree button.twisty:hover::before {
    border-left-color: var(--fg);
}

.system-tree a {
    color: var(--fg);
    display: inline-block;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
}

.system-tree a.active {
    background: var(--panel);
    color: var(--blue);
}

.diagram {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: var(--bg);
    user-select: none;
    /* Panning and pinching are the diagram's, not the page's. */
    touch-action: none;
}

.diagram.light {
    background: #ffffff;
}

/* The editing grid shows through the diagram's own background */
.diagram.editing {
    background-image: radial-gradient(circle, rgba(192, 202, 245, 0.16) 1px, transparent 1.4px);
}

.diagram.editing.light {
    background-image: radial-gradient(circle, rgba(26, 27, 38, 0.18) 1px, transparent 1.4px);
}

.diagram.editing .canvas svg rect.canvas {
    fill: transparent;
}

.diagram:active {
    cursor: grabbing;
}

.diagram .canvas {
    position: absolute;
    top: 0;
    left: 0;
}

.diagram.glide {
    transition: background-size 180ms ease-out, background-position 180ms ease-out;
}

.diagram.glide .canvas {
    transition: transform 180ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .diagram.glide,
    .diagram.glide .canvas {
        transition: none;
    }
}

.diagram .canvas svg {
    display: block;
}

.diagram g.block {
    cursor: pointer;
}

.diagram g.block[data-subsystem],
.diagram g.state[data-subchart] {
    cursor: zoom-in;
}

.inspector pre.script {
    margin: 0;
    padding: 0.5rem;
    max-height: 60vh;
    overflow: auto;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    white-space: pre;
    background: var(--panel);
    border-radius: 4px;
}

.inspector {
    width: 320px;
    overflow: auto;
    padding: 0.75rem 1rem;
    border-left: 1px solid var(--border);
    background: var(--bg-alt);
}

.inspector .selection-names {
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.inspector .selection-actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* A line's ends: buttons that read as links */
.inspector button.line-end {
    padding: 0;
    border: none;
    background: none;
    color: var(--blue);
    text-align: left;
    cursor: pointer;
}

.inspector button.line-end:hover {
    text-decoration: underline;
}

.inspector h3 {
    margin: 0 0 0.25rem;
}

.inspector h4 {
    margin: 1rem 0 0.4rem;
    color: var(--purple);
}

.inspector td:first-child {
    color: var(--teal);
    white-space: nowrap;
}

.page.narrow {
    max-width: 480px;
}

.page.wide {
    max-width: 1200px;
}

.login-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.5rem;
}

.avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

ul.plain {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

h2 {
    margin-top: 2rem;
    color: var(--purple);
}

table.audit code {
    color: var(--muted);
}

.file-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-bar .spacer {
    flex: 1;
}

.file-bar .error {
    margin: 0;
}

.file-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.file-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: auto;
}

.history {
    width: 260px;
    overflow: auto;
    padding: 0.75rem 1rem;
    border-left: 1px solid var(--border);
    background: var(--bg-alt);
}

.history h4 {
    margin: 0 0 0.5rem;
    color: var(--purple);
}

ul.versions {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.versions li {
    padding: 0.35rem 0.4rem;
    border-radius: 4px;
}

ul.versions li.active {
    background: var(--panel);
}

pre.source {
    margin: 0;
    padding: 1rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 13px;
    white-space: pre;
}

/* Tabs and simulation */
.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.4rem 1rem 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.tab {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.tab.active {
    background: var(--bg);
    color: var(--blue);
}

.sim-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sim-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sim-form label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.sim-form input[type=number] {
    width: 7rem;
}

.sim-form .grow {
    flex: 1;
    min-width: 16rem;
}

.sim-notice {
    margin: 0;
    padding: 0.75rem 1rem 0;
}

.sim-form .sim-inputs {
    flex-basis: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.sim-inputs p {
    flex-basis: 100%;
    margin: 0.25rem 0;
}

.sim-inputs label {
    flex: 1;
    min-width: 10rem;
}

.sim-form textarea {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    resize: vertical;
}

.sim-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.running {
    color: var(--orange);
}

.ok {
    color: var(--green);
}

.sim-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.plot-host {
    flex: 1;
    min-width: 0;
    padding: 0.75rem;
    overflow: auto;
}

.signal-list {
    width: 260px;
    overflow: auto;
    padding: 0.75rem 1rem;
    border-left: 1px solid var(--border);
    background: var(--bg-alt);
}

.signal-list h4 {
    margin: 0.5rem 0;
    color: var(--purple);
}

.signal {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    padding: 0.1rem 0;
    word-break: break-all;
}

ul.runs li {
    padding: 0.25rem 0;
}

/* Version comparison */
.legend {
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    border: 2px solid;
    font-size: 0.8rem;
}

.legend.added, .change.added { border-color: var(--green); }
.legend.modified, .change.modified { border-color: var(--orange); }
.legend.moved, .change.moved { border-color: var(--teal); }
.legend.nested { border-color: var(--purple); border-style: dashed; }
.change.removed { border-color: var(--red); }

.changes .change {
    border-left: 3px solid;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.4rem;
    word-break: break-word;
}

a.compare {
    font-size: 0.8rem;
}

/* Editing */
.edit-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.edit-bar .spacer {
    flex: 1;
}

.edit-bar.error {
    color: var(--red);
}

button.active {
    border-color: var(--blue);
    color: var(--blue);
}

/* Model settings */
.settings-panel {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.6rem 1rem;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.setting > span {
    color: var(--muted);
    font-size: 0.8rem;
}

.setting input[title] {
    opacity: 0.6;
}

/* Block parameter dialog */
.parameter-dialog fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 0.6rem 0;
    padding: 0.3rem 0.6rem 0.6rem;
}

.parameter-dialog legend {
    color: var(--purple);
    font-size: 0.8rem;
    padding: 0 0.3rem;
}

.dialog-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.4rem;
}

.dialog-field input[type="checkbox"] {
    align-self: flex-start;
}

.dialog-label {
    font-size: 0.85rem;
}

/* Problems */
.problem {
    font-size: 0.8rem;
    padding: 0.15rem 0 0.15rem 0.5rem;
    border-left: 3px solid var(--muted);
}

.problem.error {
    border-left-color: var(--red);
    color: var(--red);
}

.problem.warning {
    border-left-color: #e0af68;
}

.toolbar .problems-button.has-errors {
    color: var(--red);
}

.problems-panel {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 30vh;
    overflow-y: auto;
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
}

.problems-panel .problem-row {
    display: flex;
    gap: 1rem;
    text-align: left;
    border: none;
    border-left: 3px solid var(--muted);
    background: none;
    border-radius: 0;
}

.problems-panel .problem-row.error {
    border-left-color: var(--red);
}

.problems-panel .problem-row.warning {
    border-left-color: #e0af68;
}

.problems-panel .problem-row:hover {
    background: var(--panel);
}

.compile-check {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.3rem;
}

.problem-place {
    color: var(--muted);
    min-width: 14rem;
}

.diagram.editing g.block {
    cursor: move;
}

.diagram.editing circle.port-hit {
    cursor: crosshair;
}

.diagram.editing circle.port-hit:hover {
    fill: rgba(122, 162, 247, 0.45);
}

.diagram.editing :is(polyline.wire-hit, polyline.trunk-hit) {
    cursor: pointer;
}

.diagram.editing rect.annotation-hit {
    cursor: move;
}

.inspector textarea.annotation-text {
    width: 100%;
    font-family: inherit;
}

.diagram.editing :is(polyline.wire-hit, polyline.trunk-hit):hover {
    stroke: rgba(122, 162, 247, 0.3);
}

.diagram .canvas svg.overlay {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    overflow: visible;
}

.overlay polyline.wire-preview,
.overlay polyline.route-preview,
.overlay rect.resize-outline {
    stroke: var(--orange);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
    fill: none;
}

.overlay polyline.wire-preview.snapped {
    stroke: var(--green);
    stroke-dasharray: none;
}

/* Running the simulation from the diagram */
button.tool.run-button {
    color: var(--green);
    font-weight: 600;
}

button.tool.run-button.running {
    color: var(--red);
}

.run-error {
    padding: 0.35rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(247, 118, 142, 0.12);
    color: var(--red);
    font-size: 0.85rem;
}

/* Port value labels: recorded values at each line's source */
.overlay .port-values text {
    fill: #9ece6a;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.diagram.light .overlay .port-values text {
    fill: #2d6a00;
    stroke: #ffffff;
}

.overlay .display-values rect {
    fill: var(--bg);
}

.overlay .display-values text {
    fill: #9ece6a;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.diagram.light .overlay .display-values rect {
    fill: #ffffff;
}

.diagram.light .overlay .display-values text {
    fill: #2d6a00;
}

.overlay .display-values.stale text,
.diagram.light .overlay :is(.display-values, .port-values).stale text {
    fill: var(--muted);
    font-style: italic;
}

.overlay .port-values.stale text {
    fill: var(--muted);
    font-style: italic;
}

/* The readable dark-page muted token is too pale against the light canvas. */
.diagram.light .overlay :is(.port-values, .display-values).stale text {
    fill: #565f89;
}

button.tool.stale {
    color: var(--muted);
}

.inspector .recorded {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.inspector .recorded button.tool {
    height: 1.5rem;
    border-color: var(--border);
}

.inspector .recorded h4 {
    margin: 0 0 0.3rem;
    font-size: 0.85rem;
}

svg.sparkline {
    display: block;
    width: 100%;
    height: auto;
    margin: 0.2rem 0 0.4rem;
    background: var(--bg-alt);
    border-radius: 4px;
}

svg.sparkline .sample-mark {
    stroke: var(--orange);
    stroke-dasharray: 2 2;
}

.overlay line.guide {
    stroke: var(--teal);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}

.overlay circle.snap-ring {
    fill: rgba(158, 206, 106, 0.25);
    stroke: var(--green);
    stroke-width: 1.5;
}

.overlay rect.select-box {
    fill: rgba(122, 162, 247, 0.12);
    stroke: var(--blue);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 3 2;
}

.overlay rect.resize-handle {
    fill: var(--orange);
    stroke: var(--bg);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    pointer-events: all;
}

.overlay rect.resize-handle[data-corner="nw"],
.overlay rect.resize-handle[data-corner="se"] {
    cursor: nwse-resize;
}

.overlay rect.resize-handle[data-corner="ne"],
.overlay rect.resize-handle[data-corner="sw"] {
    cursor: nesw-resize;
}

/* Block library: search, collapsible categories, tiles with thumbnails */
.palette {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
}

.palette-search {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--muted);
}

.palette-search:focus-within {
    border-color: var(--blue);
}

.palette-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    padding: 0.35rem 0;
    outline: none;
}

.palette-group summary {
    margin: 0.7rem 0 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-transform: uppercase;
    cursor: pointer;
}

.palette ul {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 4px;
}

.palette-group ul {
    margin: 0;
}

.palette-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: grab;
    text-align: center;
}

.palette-block:hover {
    background: var(--panel);
    border-color: var(--border);
}

.palette-label {
    font-size: 0.68rem;
    line-height: 1.15;
    color: var(--fg);
    overflow-wrap: anywhere;
}

.thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 32px;
    flex: none;
}

.thumb svg {
    width: 100%;
    height: 100%;
}

/* Quick insert: double-click the canvas and type */
.quick-insert {
    position: absolute;
    z-index: 6;
    width: 20rem;
    padding: 0.4rem;
    background: var(--panel);
    border: 1px solid var(--blue);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.quick-insert ul {
    list-style: none;
    margin: 0.3rem 0 0;
    padding: 0;
    max-height: 22rem;
    overflow-y: auto;
}

.quick-insert.find-blocks {
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 28rem;
    max-width: calc(100% - 1rem);
}

.find-blocks .quick-row {
    justify-content: space-between;
    padding: 0.3rem 0.5rem;
}

.quick-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    cursor: pointer;
}

.quick-row .thumb {
    width: 36px;
    height: 24px;
    color: var(--fg);
}

.quick-row.chosen {
    background: var(--bg-alt);
    outline: 1px solid var(--border);
}

.quick-label {
    flex: 1;
}

.quick-detail {
    font-size: 0.75rem;
    color: var(--muted);
}

.diagram:focus {
    outline: none;
}

.inspector input.param {
    width: 100%;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
}

.inspector input.block-name {
    width: 100%;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

button.danger {
    border-color: var(--red);
    color: var(--red);
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Lines are not interactive; let clicks reach the blocks beneath them. */
.diagram g.lines {
    pointer-events: none;
}

/* The plot figure is light; frame it on the dark page. */
.plot-host canvas {
    border-radius: 6px;
}

/* Scope settings in the inspector */
.inspector table.scope {
    margin-bottom: 0.5rem;
}

.inspector table.scope th {
    color: var(--muted);
    font-weight: normal;
}

.inspector details.raw {
    margin-top: 1rem;
}

.inspector details.raw summary {
    cursor: pointer;
    color: var(--muted);
}

.inspector details.raw pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.75rem;
}

.signal.generated {
    color: var(--muted);
}

.signal.toggle {
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.85rem;
}

/* App workspace: persistent diagram/simulation views and file navigation. */
[hidden] { display: none !important; }
.workspace-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.workspace-caption { color: var(--muted); font-size: 12px; margin: auto 0 auto auto; padding: 0.35rem 0 0.6rem 1rem; }
.workspace-notice { margin: 0; padding: 0.65rem 1rem; background: #332c28; color: var(--orange); border-bottom: 1px solid var(--border); }
.file-breadcrumbs { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.file-breadcrumbs strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-breadcrumbs > span { color: var(--muted); }
.file-breadcrumbs a { flex-shrink: 0; }
.version-badge { display: inline-flex; align-items: center; padding: 0.15rem 0.45rem; border: 1px solid var(--border); border-radius: 4px; color: var(--teal); font-size: 12px; white-space: nowrap; }
.history { flex-shrink: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (max-width: 1100px) { .workspace-caption { display: none; } .file-bar { flex-wrap: wrap; } .file-breadcrumbs { flex: 1 1 55%; } }
@media (max-width: 700px) { .history { width: 210px; } .file-bar { gap: 0.4rem; padding: 0.5rem; } .file-breadcrumbs { flex-basis: 80%; } .file-bar .spacer { display: none; } }

/* Simulation controls: visible run state, draft validation and compact setup. */
.sim-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-alt); flex-wrap: wrap; }
.sim-heading { display: flex; gap: 0.65rem; align-items: center; }
.sim-actions { flex-wrap: wrap; }
.sim-status { max-width: 50vw; overflow-wrap: anywhere; }
.stop-button { color: var(--red); border-color: var(--red); }
.sim-form { display: block; flex-shrink: 0; }
.sim-primary-options, .sim-advanced-options { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.75rem 1rem; }
.sim-primary-options select { min-width: 12rem; }
.sim-number { width: 10rem; }
.sim-number input { width: 100%; font-variant-numeric: tabular-nums; }
.sim-form label { color: #a9b1d6; }
.sim-number.invalid input { border-color: var(--red); }
.field-error { color: var(--red); font-size: 11px; line-height: 1.4; }
.sample-estimate { font-size: 12px; color: #a9b1d6; padding-top: 1.65rem; }
.sim-options-details { margin-top: 0.65rem; }
.sim-options-details summary, .sim-assumptions summary { cursor: pointer; color: var(--blue); font-size: 12px; padding: 0.25rem 0; }
.sim-options-details[open] summary { margin-bottom: 0.6rem; }
.sim-advanced-options small { max-width: 32rem; line-height: 1.45; }
.sim-assumptions { padding: 0.35rem 1rem; border-bottom: 1px solid var(--border); }
.sim-assumptions p, .sim-assumptions ul { margin: 0.5rem 0; font-size: 12px; color: #a9b1d6; }
.sim-progress { display: flex; align-items: center; gap: 0.75rem; padding: 0.4rem 1rem; border-bottom: 1px solid var(--border); font-size: 12px; color: #a9b1d6; }
.sim-progress progress { accent-color: var(--blue); width: 12rem; height: 6px; }
.sim-empty { max-width: 32rem; margin: 6vh auto; text-align: center; padding: 1.5rem; line-height: 1.6; }
.sim-empty-icon { color: var(--blue); font-size: 4rem; }
.sim-empty h3 { font-size: 1.15rem; margin: 0.5rem 0; }
.sim-empty p { color: #a9b1d6; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
@media (max-width: 700px) { .sim-status { max-width: 100%; } .sim-number { width: 8rem; } .sim-toolbar, .sim-form { padding: 0.6rem; } .sample-estimate { padding-top: 0.3rem; } }

/* Simulation signal inspector: searchable traces and sampled measurements. */
.sim-body .results-main { flex: 1; min-width: 0; overflow: auto; }
.results-main .plot-host { overflow: auto; }
.results-identity { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; padding: .7rem 1rem 0; font-size: .85rem; }
.results-identity span { color: #a9b1d6; }
.sim-body .signal-list { width: 285px; flex-shrink: 0; }
.signal-search { box-sizing: border-box; width: 100%; margin-bottom: .5rem; }
.signal-selection-actions { display: flex; gap: .4rem; margin-bottom: .6rem; }
.signal-selection-actions button { font-size: .8rem; padding: .3rem .5rem; }
.signal-options { max-height: 320px; overflow: auto; }
.signal-options .signal { padding: .35rem .2rem; border-radius: 4px; }
.signal-options .signal:hover { background: rgba(122,162,247,.1); }
.signal-name { min-width: 0; overflow-wrap: anywhere; word-break: normal; }
.signal-swatch { display: inline-block; flex: 0 0 16px; width: 16px; height: 4px; border-radius: 2px; margin-right: .3rem; vertical-align: middle; }
.run-history-item { width: 100%; text-align: left; padding: .4rem .5rem; }
.signal-measurements { margin: .2rem .75rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-alt); }
.measurements-toggle { width: 100%; text-align: left; border: 0; padding: .65rem .75rem; background: transparent; }
.measurement-controls { padding: .4rem .75rem; display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; }
.measurement-controls label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; }
.measurement-controls input { width: 120px; }
.measurement-controls input[aria-invalid=true] { border-color: var(--red); }
.measurement-modes { display: flex; gap: .3rem; }
.measurement-modes button { font-size: .8rem; }
.measurement-note, .signal-measurements > p { margin: .5rem .75rem; font-size: .8rem; color: #a9b1d6; }
.measurement-table-scroll { overflow-x: auto; }
.measurement-table { width: 100%; border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; }
.measurement-table td, .measurement-table th { text-align: right; padding: .45rem .7rem; border-top: 1px solid var(--border); white-space: nowrap; }
.measurement-table th:first-child { text-align: left; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.measurement-table tbody th { font-weight: normal; }
.sim-panel .muted { color: #a9b1d6; }
@media (max-width: 850px) {
    .sim-body { flex-direction: column; overflow: auto; }
    .sim-body .results-main { flex: none; overflow: visible; }
    .sim-body .signal-list { box-sizing: border-box; width: 100%; border-left: 0; border-top: 1px solid var(--border); flex-shrink: 0; }
    .signal-options { max-height: 220px; }
}

/* Plot controls stay legible while the figure follows its available width. */
.plot-actions { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem 0; font-size: .8rem; }
.plot-actions span { color: #a9b1d6; }
.plot-actions button { font-size: .8rem; }
/* Project browser: folders, global search, and bounded file lists. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.project-files { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 1rem 0 2rem; }
.file-browser-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; background: var(--bg-alt); padding: .8rem; }
.file-browser-tools .file-search { flex: 1 1 240px; min-width: 0; }
.file-browser-tools label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: #a9b1d6; }
.folder-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .5rem .7rem; border-bottom: 1px solid var(--border); }
.folder-breadcrumbs button { background: transparent; border-color: transparent; color: var(--blue); padding: .25rem .4rem; overflow-wrap: anywhere; }
.folder-breadcrumbs button[aria-current=page] { color: var(--fg); font-weight: 600; }
.file-search-note { margin-left: auto; color: #a9b1d6; font-size: .8rem; }
.file-table-scroll { overflow: auto; max-height: 65vh; }
.file-browser-table { width: 100%; margin: 0; }
.file-browser-table th { position: sticky; top: 0; background: var(--bg-alt); z-index: 1; color: #a9b1d6; font-size: .8rem; font-weight: 500; text-align: left; }
.file-browser-table td, .file-browser-table th { padding: .7rem .8rem; }
.file-browser-table tbody tr:hover { background: rgba(122,162,247,.05); }
.project-files .muted { color: #a9b1d6; }
.file-name-cell { min-width: 180px; overflow-wrap: anywhere; }
.file-kind { display: inline-block; color: #a9b1d6; border: 1px solid var(--border); font-size: .6rem; padding: .2rem; border-radius: 3px; margin-right: .5rem; vertical-align: middle; }
.file-kind.model { color: var(--teal); }
.file-author { display: block; font-size: .75rem; margin-top: .3rem; }
.file-row-actions { white-space: nowrap; text-align: right; }
.file-row-actions button, .file-row-actions .button { font-size: .8rem; padding: .3rem .5rem; margin-left: .3rem; }
.folder-link { padding: 0; background: transparent; border: 0; color: var(--blue); display: inline-flex; gap: .6rem; align-items: center; }
.file-browser-footer { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; padding: .7rem .8rem; font-size: .8rem; color: #a9b1d6; border-top: 1px solid var(--border); }
.file-browser-footer > span:first-child { margin-right: auto; }
.file-browser-empty { padding: 2.5rem 1rem; text-align: center; }
.file-browser-empty p { color: #a9b1d6; }
@media (max-width: 700px) { .file-browser-tools label { flex: 1; } .file-browser-tools select { flex: 1; min-width: 0; } .file-search-note { margin-left: .4rem; } }

.file-browser-table td:nth-child(2), .file-browser-table td:nth-child(3), .file-browser-table td:nth-child(4) { white-space: nowrap; }

/* Simulation comparison: one clearly identified reference over current traces. */
.comparison-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin: .75rem; padding: .7rem .8rem; border: 1px solid var(--border); border-left: 3px dashed var(--blue); border-radius: 5px; background: var(--bg-alt); font-size: .85rem; }
.comparison-banner strong { font-weight: 600; }
.comparison-banner p { margin: .4rem 0 0; color: #a9b1d6; line-height: 1.4; }
.comparison-banner button { flex-shrink: 0; font-size: .8rem; }
.comparison-loading { display: flex; align-items: center; gap: .7rem; margin: .75rem; font-size: .85rem; }
.comparison-error { margin: .75rem; }
.runs .compare-run { margin-top: .3rem; padding: .2rem .5rem; font-size: .75rem; }
@media (max-width: 650px) { .comparison-banner { flex-direction: column; } }

/* Application navigation: stable two-row layout on phones. */
.topbar { position: relative; }
.topbar nav { align-self: stretch; align-items: stretch; gap: .25rem; min-width: 0; }
.topbar nav a { display: flex; align-items: center; padding: 0 .65rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.topbar nav a.current { color: var(--fg); border-bottom-color: var(--blue); background: rgba(122,162,247,.07); }
.topbar .brand, .topbar .user button { white-space: nowrap; flex-shrink: 0; }
.topbar .user { min-width: 0; }
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-error { position: absolute; top: 100%; right: .5rem; padding: .65rem; max-width: min(400px,95vw); background: var(--panel); color: var(--red); border: 1px solid var(--red); z-index: 100; }
.skip-link { position: fixed; left: 1rem; top: -100px; padding: .6rem; background: var(--panel); z-index: 1000; }
.skip-link:focus { top: .3rem; }
@media (max-width: 760px) {
    :root { --topbar: 88px; }
    .topbar { flex-wrap: wrap; gap: 0; padding: 0 .6rem; }
    .topbar .brand { height: 44px; display: flex; align-items: center; }
    .topbar .user, .topbar > a:not(.brand):not(.skip-link) { margin-left: auto; }
    .topbar nav { order: 3; flex: 1 0 100%; height: 44px; overflow-x: auto; }
    .topbar nav a { padding: 0 .55rem; font-size: .85rem; }
    .topbar .user { gap: .4rem; }
    .topbar .user-name { max-width: 120px; }
    .topbar .avatar { display: none; }
}
/* Parameter help and validation remain usable with keyboard and touch. */
.dialog-label-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.dialog-label-row label { flex: 1; }
.parameter-help-button { border-radius: 50%; padding: 0; width: 24px; height: 24px; flex: 0 0 24px; font-size: .8rem; color: var(--blue); }
.parameter-help-button[aria-expanded=true] { border-color: var(--blue); }
.parameter-help-text { font-size: .8rem; line-height: 1.5; color: #a9b1d6; margin: .25rem 0; }
.parameter-search { width: 100%; margin-top: .6rem; }
.dialog-field input[aria-invalid=true], .dialog-field select[aria-invalid=true], .setting input[aria-invalid=true], .setting select[aria-invalid=true] { border-color: var(--red); }
.settings-panel .setting > label, .settings-panel > .muted, .parameter-dialog .muted { color: #a9b1d6; }
.setting-inactive input { color: #a9b1d6; }
.setting small { font-size: .75rem; line-height: 1.4; }
.settings-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.settings-grid input, .settings-grid select { min-width: 0; max-width: 100%; }

.settings-panel .setting > label { font-size: .8rem; }
/* Recorded run setup stays distinct from the editable simulation form. */
.recorded-setup { margin: .7rem .75rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; }
.recorded-setup summary { cursor: pointer; color: var(--blue); }
.recorded-setup p { color: #a9b1d6; line-height: 1.5; }
.recorded-setup pre { max-height: 220px; overflow: auto; padding: .6rem; background: var(--bg); }
.recorded-setup h5 { margin-bottom: .5rem; }
.setup-options { display: grid; grid-template-columns: minmax(100px, max-content) minmax(0, 1fr); gap: .45rem 1rem; }
.setup-options dt { color: #a9b1d6; }
.setup-options dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.setup-notice { margin: 0; padding: .6rem 1rem; background: var(--bg-alt); color: var(--teal); font-size: .85rem; }

/* Scrub actual recorded samples; the cursor never interpolates values. */
.sample-scrubber { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; padding: .25rem .75rem; font-size: .8rem; color: #a9b1d6; }
.sample-scrubber input[type=range] { flex: 1 1 120px; min-width: 90px; accent-color: var(--blue); }
.sample-scrubber button { padding: .25rem .5rem; }
.sample-scrubber button[aria-pressed=true] { border-color: var(--blue); color: var(--blue); }
.sample-index { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Simulation: reach signals and recordings before the plot on narrow screens. */
.mobile-signals-toggle { display: none; }
.sim-body > .signal-list { order: 1; }
@media (max-width: 850px) {
    .mobile-signals-toggle {
        display: block;
        flex-shrink: 0;
        margin: .5rem .75rem;
        text-align: left;
    }
    .sim-body > .signal-list { display: none; order: 0; }
    .sim-body > .signal-list.mobile-expanded {
        display: block;
        max-height: 45vh;
        border-bottom: 1px solid var(--border);
    }
    .sim-body > .results-main { order: 1; }
}
/* Native file inputs remain keyboard-accessible within their styled labels. */
.file-picker { position: relative; }
.file-picker:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.local-viewer.over { outline: 2px dashed var(--blue); outline-offset: -3px; }
.local-viewer.over .dropzone { border-color: var(--blue); background: var(--panel); }
.local-file-error:not(:empty) { padding: .5rem 1rem; }

/* Plot image export keeps actions usable on narrow screens. */
.plot-actions { flex-wrap: wrap; }
/* Administrative tables scroll within the page on narrow screens. */
.admin-table-scroll { max-width: 100%; overflow-x: auto; }
.admin-table-scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.admin-table-scroll td:first-child { overflow-wrap: anywhere; }

/* User-chosen project and organization names can be long identifiers. */
.page h1, .page .card { overflow-wrap: anywhere; }

/* History drawers preserve the canvas width on phones, like canvas panels. */
.file-body { position: relative; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.history-heading h4 { margin: 0; }
.history-heading button { padding: .1rem .45rem; }
.history { overflow-wrap: anywhere; }
@media (max-width: 760px) {
    .file-body > .history { position: absolute; top: 0; right: 0; bottom: 0; width: min(300px, 85%); z-index: 20; box-shadow: -6px 0 18px #0006; }
}
