:root {
    --ui-scale: 0.75;
    --workspace-section-body-bg: #ffffff;
    --workspace-section-border: #000000;
    --workspace-section-border-width: 4px;
    --workspace-section-title-size: clamp(16.5px, calc(1.05rem + 0.41vw), 24px);
    --toolbox-btn-border-width: 3px;
    --demo-toolbox-width: 56px;
    --demo-toolbox-btn-size: 64px;
    --demo-toolbox-pad-block: 14px;
    --demo-toolbox-height: calc((2 * var(--demo-toolbox-pad-block)) + var(--demo-toolbox-btn-size) + var(--workspace-section-border-width));
    --collab-chat-border-width: 2px;
    --workspace-pane-inset: 4px;
    --workspace-row-gutter: 4px;
    --workspace-header-height: 58px;
    --workspace-section-split: minmax(0, 2.4fr) var(--workspace-row-gutter) minmax(0, 1fr);
    --workspace-gutter-size: 2px;
    --optimization-action-btn-size: 76px;
    --optimization-action-btn-inset: 14px;
}

html {
    height: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    width: 100vw;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    color: #1a1a1a;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button,
textarea {
    font: inherit;
}

#ui-scale-root {
    width: calc(100vw / var(--ui-scale));
    height: calc(100vh / var(--ui-scale));
    transform: scale(var(--ui-scale));
    transform-origin: top left;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

#app-shell,
#main-column {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

#main-column {
    flex-direction: column;
}

.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;
}

.demo-workspace {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 6px;
    display: grid;
    grid-template-columns: minmax(240px, 3fr) var(--workspace-gutter-size) minmax(240px, 1fr);
    grid-template-rows: var(--workspace-header-height) 6px minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    align-content: stretch;
}

.demo-workspace > .workspace-twin-diagrams-outer {
    grid-column: 1;
    grid-row: 1 / -1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.demo-workspace > .workspace-gutter-col-main {
    grid-column: 2;
    grid-row: 1 / -1;
}

.demo-workspace > .workspace-ransac-right {
    grid-column: 3;
    grid-row: 1 / -1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: var(--workspace-header-height) 6px minmax(0, 2.4fr) var(--workspace-row-gutter) minmax(0, 1fr);
    align-items: stretch;
}

.demo-workspace .workspace-twin-diagrams {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(120px, 1fr) var(--workspace-gutter-size) minmax(120px, 1fr);
    grid-template-rows: var(--workspace-header-height) 6px minmax(0, 2.4fr) var(--workspace-row-gutter) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    overflow: visible;
}

.demo-workspace .demo-experiment-mode-header {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: stretch;
    width: calc(100% - (2 * var(--workspace-pane-inset)));
    margin: 0 var(--workspace-pane-inset);
    padding: 0;
}

.demo-workspace .demo-experiment-progress {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--workspace-header-height);
    min-height: var(--workspace-header-height);
    width: calc(100% - (2 * var(--workspace-pane-inset)));
    margin: 0 var(--workspace-pane-inset);
    padding: 8px 12px;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 6px;
    background: #ffffff;
}

body.demo-display-session .demo-experiment-progress-meta {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
    min-width: 0;
    font-size: 18px;
    font-weight: 700;
}

body.demo-display-session .demo-experiment-progress-time,
body.demo-display-session .demo-experiment-progress-track {
    display: none !important;
}

body.demo-display-session .demo-workspace .demo-experiment-progress {
    flex-direction: column;
    gap: 7px;
    padding: 7px 12px;
}

body.demo-display-session .demo-experiment-progress-meta {
    flex: 0 0 auto;
    width: 100%;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    line-height: 1;
}

body.demo-display-session #demo-experiment-progress-label {
    width: 100%;
    text-align: center;
}

body.demo-display-session .demo-experiment-progress-track {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    height: 14px;
}

body.demo-display-session .demo-experiment-progress-track[hidden] {
    display: none !important;
}

.demo-experiment-progress-segment {
    display: block;
    min-width: 0;
    height: 100%;
    border: 2px solid #000000;
    border-radius: 999px;
    background: #ffffff;
}

.demo-experiment-progress-segment.is-complete {
    background: #111111;
}

.demo-experiment-progress-segment.is-active {
    background: #111111;
    border-color: #000000;
}

.demo-workspace .demo-experiment-time-header {
    position: relative;
    grid-row: 1;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--workspace-header-height);
    min-height: var(--workspace-header-height);
    width: calc(100% - (2 * var(--workspace-pane-inset)));
    margin: 0 var(--workspace-pane-inset);
    padding: 4px 48px;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 6px;
    background: var(--workspace-section-body-bg);
    color: #111111;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 18px;
    font-weight: 900;
}

.speaker-pause-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 2px solid #000000;
    border-radius: 6px;
    background: #ffffff;
    color: #111111;
    cursor: pointer;
}

.speaker-pause-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.speaker-pause-btn:hover:not(:disabled) {
    background: #f3f3f3;
}

.speaker-pause-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.speaker-pause-dialog {
    width: min(420px, calc(100vw - 40px));
    margin: auto;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
}

.speaker-pause-dialog::backdrop {
    background: rgba(32, 33, 36, 0.45);
}

.speaker-pause-card {
    box-sizing: border-box;
    padding: 22px 24px 18px;
    border: 3px solid #000000;
    border-radius: 10px;
    background: #ffffff;
    color: #202124;
    text-align: left;
}

.speaker-pause-card h2 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 800;
}

.speaker-pause-card p {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.5;
    color: #3c4043;
}

.speaker-pause-card button {
    display: block;
    width: 100%;
    padding: 10px 18px;
    border: 2px solid #000000;
    border-radius: 6px;
    background: #ffffff;
    color: #111111;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.speaker-pause-card button:hover {
    background: #f3f3f3;
}

.demo-workspace .demo-emboss-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: var(--workspace-header-height);
    margin: 0;
    padding: 14px 18px;
    border: var(--workspace-section-border-width) solid #000000;
    border-radius: 6px;
    background: #ffffff;
    color: #111111;
    font-size: clamp(18px, calc(1.05rem + 0.35vw), 22px);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    cursor: pointer;
}

.demo-workspace .demo-emboss-btn:hover:not(:disabled):not(.demo-emboss-btn-readonly) {
    background: #e0e0e0;
}

.demo-emboss-btn-readonly {
    cursor: default;
    pointer-events: none;
}

.demo-workspace .workspace-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.demo-workspace .workspace-twin-diagrams > .pane-target {
    grid-column: 1;
    grid-row: 3;
    display: contents !important;
}

.demo-workspace .pane-target .demo-target-upper {
    grid-column: 1;
    grid-row: 3;
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    margin: var(--workspace-pane-inset);
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--workspace-section-body-bg);
    container-type: size;
    container-name: demo-target-guide;
}

.demo-workspace .pane-target .workspace-gutter-row-demo-target {
    grid-column: 1 / 4;
    grid-row: 4;
}

.demo-workspace .pane-target .demo-target-desc-panel {
    grid-column: 1 / 4;
    grid-row: 5;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    margin: var(--workspace-pane-inset);
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--workspace-section-body-bg);
}

.demo-workspace .workspace-twin-diagrams > .pane-editor {
    grid-column: 3;
    grid-row: 3;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--workspace-section-split);
    height: 100%;
    min-height: 0;
    padding: var(--workspace-pane-inset);
    overflow: visible;
}

.demo-workspace .pane-editor .canvas-full-card {
    grid-row: 1 / -1;
    grid-column: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--workspace-section-body-bg);
}

.workspace-section-title,
.pane-label {
    flex: 0 0 auto;
    display: block;
    width: 100%;
    margin: 0;
    padding: 13px 16px;
    border-bottom: var(--workspace-section-border-width) solid var(--workspace-section-border);
    background: #ffffff;
    color: #000000;
    font-size: var(--workspace-section-title-size);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.035em;
    text-align: center;
    text-transform: lowercase;
    cursor: default;
}

.demo-primary-section-title {
    font-size: clamp(20px, calc(1.25rem + 0.5vw), 30px);
    text-transform: none;
}

/* "Match this" names the Target in plain words; the small line ties it to "Target". */
.pane-label-sub {
    display: inline;
    margin-left: 8px;
    font-size: 14px;
    letter-spacing: normal;
    font-weight: 500;
    color: #5f6368;
}

/* Study Guides scroll: every box between the panel and the list must be a
   shrinkable flex column, or the list grows past the panel and is clipped. */
.demo-target-desc-panel > .demo-target-guide-variant:not([hidden]),
.demo-target-guide-variant > .demo-target-guide-i18n:not([hidden]) {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.demo-target-guide-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 12px 14px 14px;
    overflow: auto;
    color: #3c4043;
    font-size: clamp(18px, min(17cqh, 5cqw), 22px);
    font-weight: 500;
    line-height: 1.5;
    background: var(--workspace-section-body-bg);
    list-style-position: inside;
}

.demo-target-guide-list > li {
    margin: 0 0 clamp(4px, 1.2cqh, 8px);
    padding-left: 0;
}

.study-guide-rating-focus {
    color: #dc2626;
    font-weight: 700;
}

.demo-target-guide-metrics {
    margin: 6px 0 0;
    padding: 0 0 0 1.35em;
    list-style: disc;
    list-style-position: outside;
}

.demo-target-guide-metrics li {
    margin: 0 0 4px;
    padding-left: 0;
}

.demo-target-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: var(--demo-toolbox-height);
    min-height: var(--demo-toolbox-height);
    max-height: var(--demo-toolbox-height);
    box-sizing: border-box;
    padding: var(--demo-toolbox-pad-block) 16px;
    border-top: var(--workspace-section-border-width) solid var(--workspace-section-border);
    background: #ffffff;
    overflow: hidden;
}

.demo-target-random-bar {
    display: flex;
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 12px;
}

/* Researcher (preview) mode: the Random button takes the whole bar, spans the
   Target image (app.js sets --target-preview-width) and looks like the canvas
   toolbox buttons. The typed instruction is not mirrored here. */
body[data-preview-mode="true"] .demo-target-actions {
    justify-content: center;
}

body[data-preview-mode="true"] .demo-target-instruction-display {
    display: none;
}

body[data-preview-mode="true"] .demo-target-random-bar {
    width: min(100%, var(--target-preview-width, 100%));
    margin: 0;
    padding: 0;
    gap: 12px;
}

/* Random fills the bar under the Target. */
body[data-preview-mode="true"] .demo-target-random-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
    height: var(--demo-toolbox-btn-size);
}

.demo-target-random-btn {
    padding: 0 24px;
    border: var(--toolbox-btn-border-width) solid var(--workspace-section-border);
    border-radius: 10px;
    background: #ffffff;
    color: #2c3338;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.demo-target-random-btn:hover:not(:disabled) {
    background: #eef1f5;
    border-color: #000000;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.demo-target-random-btn:disabled {
    background: #f1f3f4;
    border-color: #c5cdd8;
    color: #9aa0a6;
    cursor: not-allowed;
    box-shadow: none;
}

.demo-target-instruction-display {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 100%;
    margin: 0;
    overflow: auto;
    color: #111111;
    font-size: clamp(16px, 1.05rem, 20px);
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.canvas-workspace {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
}

.demo-toolbox {
    order: 2;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    align-self: stretch;
    box-sizing: border-box;
    padding: var(--demo-toolbox-pad-block) 12px;
    border-top: var(--workspace-section-border-width) solid var(--workspace-section-border);
    background: var(--workspace-section-body-bg);
    container-type: inline-size;
}

.toolbox-btn {
    box-sizing: border-box;
    width: min(var(--demo-toolbox-btn-size), calc((100cqw - (7 * 12px)) / 8));
    height: min(var(--demo-toolbox-btn-size), calc((100cqw - (7 * 12px)) / 8));
    padding: 0;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: var(--toolbox-btn-border-width) solid var(--workspace-section-border);
    border-radius: 10px;
    background: #ffffff;
    color: #2c3338;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.toolbox-btn[hidden] {
    display: none;
}

.toolbox-btn:hover:not(:disabled) {
    background: #eef1f5;
    border-color: #000000;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.toolbox-btn.active:not(:disabled) {
    background: #e8f0fe;
    border-color: #1a73e8;
    border-width: calc(var(--toolbox-btn-border-width) + 1px);
    color: #174ea6;
    box-shadow: inset 0 0 0 1px rgba(26, 115, 232, 0.25);
}

.toolbox-btn:disabled {
    background: #f1f3f4;
    border-color: #c5cdd8;
    color: #9aa0a6;
    cursor: not-allowed;
    box-shadow: none;
}

.toolbox-icon {
    width: 52%;
    height: 52%;
}

.canvas-container {
    --canvas-hint-room: 40px;
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 16px 16px;
    container-type: size;
    background: #ffffff;
}

.canvas-main {
    /* Sized by the canvas, so the canvas and the hint under it stay together, centered. */
    flex: 0 1 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cad-canvas-frame {
    box-sizing: border-box;
    /* Nothing on the canvas (lock labels, hint) may be selected as text: pressing selected
       text makes the browser start a text drag and cancel the red-pen stroke or shape drag. */
    -webkit-user-select: none;
    user-select: none;
    /* Square, leaving room under it for the tool hint (.canvas-tool-hint). */
    width: min(100cqw, calc(100cqh - var(--canvas-hint-room)), 800px);
    height: min(100cqw, calc(100cqh - var(--canvas-hint-room)), 800px);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    flex: 0 0 auto;
    position: relative;
    background: #ffffff;
    border: 3px solid #c5cdd8;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    touch-action: none;
}

.cad-canvas,
.aux-preview-svg {
    width: 100%;
    height: 100%;
    display: block;
    background: #ffffff;
}

.cad-canvas {
    border: 0;
    border-radius: 5px;
    cursor: default;
}

.cad-canvas.uses-custom-cursor,
.cad-canvas-frame.uses-custom-cursor {
    cursor: none;
}

.cad-canvas-frame.uses-custom-cursor .curve-element,
.cad-canvas-frame.uses-custom-cursor .handle {
    cursor: none;
}

.cad-canvas-frame.is-readonly-preview {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.16);
}

.cad-canvas-frame.is-readonly-preview .cad-canvas {
    pointer-events: none;
    cursor: not-allowed;
}

.canvas-preview-notice {
    position: absolute;
    z-index: 5;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border: 1px solid #1a73e8;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #174ea6;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

.grid-layer .grid-dot {
    fill: #b4becd;
    stroke: none;
    pointer-events: none;
}

.curves-layer,
.target-projection-layer,
.preview-curves {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.target-projection-layer {
    pointer-events: none;
}

/* After release the Target stays 4 s, then fades out over its last second
   (TARGET_PROJECTION_LINGER_MS = 5000 in tools/canvas-tools.js). */
.target-projection-layer.is-fading {
    animation: target-projection-fade 5s linear forwards;
}

@keyframes target-projection-fade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; }
}

.target-projection-layer .curve-projected {
    stroke: #ff7a00;
    opacity: .72;
}

.target-projection-layer .target-projection-handle {
    fill: #ffffff;
    stroke: #ff7a00;
    stroke-width: 0.1;
    opacity: .95;
}

.handle {
    fill: #ffffff;
    stroke: #202124;
    stroke-width: 0.08;
    cursor: grab;
    transition: fill 0.1s, stroke 0.1s;
}

.handle:hover {
    fill: #f1f3f4;
    stroke: #000000;
}

.handle.shared {
    fill: #eceff1;
    stroke: #202124;
}

.drag-handle {
    fill: #ffffff;
    stroke: #1a73e8;
    stroke-width: 0.1;
    cursor: grab;
}

.drag-handle:hover,
.drag-handle--active {
    fill: #1a73e8;
    stroke: #174ea6;
    cursor: grabbing;
}

.drag-handle--radius {
    stroke-dasharray: 0.18 0.1;
}

.drag-handle--move {
    fill: #1a73e8;
    fill-opacity: 0.35;
    stroke: #174ea6;
}

.drag-handle--center {
    fill: #e8f0fe;
}

/* The rotation knob (↻) of the pressed object, on a short stem towards its centre. */
.drag-handle--rotate {
    fill: #ffffff;
    stroke: #1a73e8;
    stroke-width: 0.1;
    cursor: grab;
}

.drag-handle--rotate.drag-handle--active,
.drag-handle--rotate:hover {
    fill: #e8f0fe;
    cursor: grabbing;
}

.drag-rotate-stem {
    stroke: #1a73e8;
    stroke-width: 0.07;
    stroke-dasharray: 0.15 0.1;
    pointer-events: none;
}

.canvas-center-mark {
    stroke: #5f6368;
    stroke-width: 0.09;
    pointer-events: none;
}

/* A dragged point has snapped onto this key point (another end, a centre, the canvas centre). */
.drag-snap {
    fill: none;
    stroke: #f29900;
    stroke-width: 0.12;
    pointer-events: none;
}

.drag-rotate-glyph {
    fill: #1a73e8;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

/* Locks, shown by the Drag tool for the pressed object (tools/constraint-drag.js):
   a padlock badge with a word for what it keeps; an open padlock right after unlocking. */
.lock-badge { cursor: pointer; }
.lock-badge-pill { fill: #ffffff; stroke: #8430ce; stroke-width: 0.07; }
.lock-badge:hover .lock-badge-pill { fill: #f3e8fd; }
.lock-badge-body { fill: #8430ce; }
.lock-badge-shackle { fill: none; stroke: #8430ce; }
.lock-badge-word { fill: #5b1a91; font-weight: 800; }
.lock-badge--open { cursor: default; }
.lock-badge--open .lock-badge-pill { stroke: #9aa0a6; fill: #f8f9fa; }
.lock-badge--open .lock-badge-body { fill: #9aa0a6; }
.lock-badge--open .lock-badge-shackle { stroke: #9aa0a6; }
.lock-badge--open .lock-badge-word { fill: #5f6368; }


.connection-marker-tie {
    stroke: #8430ce;
    stroke-width: 0.06;
    stroke-dasharray: 0.12 0.08;
    pointer-events: none;
}

.connection-marker:hover .connection-marker-ring {
    fill: #f3e8fd;
}
.connection-marker {
    cursor: pointer;
}

.connection-marker-ring {
    fill: #ffffff;
    stroke: #8430ce;
    stroke-width: 0.1;
}

.connection-marker--tangent .connection-marker-ring {
    fill: #f3e8fd;
}

.connection-marker-dot {
    fill: #8430ce;
    pointer-events: none;
}

.connection-marker-cross {
    stroke: #8430ce;
    stroke-width: 0.08;
    stroke-linecap: round;
    pointer-events: none;
}

.connection-marker--hover .connection-marker-ring,
.connection-marker--selected .connection-marker-ring {
    fill: #8430ce;
    stroke: #5b1a91;
}

.connection-marker--hover .connection-marker-dot,
.connection-marker--selected .connection-marker-dot {
    fill: #ffffff;
}

.connection-marker--hover .connection-marker-cross,
.connection-marker--selected .connection-marker-cross {
    stroke: #ffffff;
}

/* Who made the lock (constraints/locks.py): purple = COMICA (default above),
   blue = the user stated it, amber = auto-align snapped it. */
.connection-marker-glyph {
    fill: #8430ce;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

.connection-marker--from-user .connection-marker-ring { stroke: #1f63d6; }
.connection-marker--from-user .connection-marker-dot,
.connection-marker--from-user .connection-marker-glyph { fill: #1f63d6; }
.connection-marker--from-user .connection-marker-cross { stroke: #1f63d6; }
.connection-marker--from-user.connection-marker--hover .connection-marker-ring,
.connection-marker--from-user.connection-marker--selected .connection-marker-ring {
    fill: #1f63d6;
    stroke: #143f88;
}

.connection-marker--from-aligned .connection-marker-ring { stroke: #b06a00; }
.connection-marker--from-aligned .connection-marker-dot,
.connection-marker--from-aligned .connection-marker-glyph { fill: #b06a00; }
.connection-marker--from-aligned .connection-marker-cross { stroke: #b06a00; }
.connection-marker--from-aligned.connection-marker--hover .connection-marker-ring,
.connection-marker--from-aligned.connection-marker--selected .connection-marker-ring {
    fill: #b06a00;
    stroke: #6e4300;
}

.connection-marker--hover .connection-marker-glyph,
.connection-marker--selected .connection-marker-glyph {
    fill: #ffffff;
}

.handles-layer .curve-connection-related {
    stroke: #8430ce;
    stroke-opacity: 0.4;
    stroke-width: 0.42;
    pointer-events: none;
}

.handles-layer .curve-connection-detach {
    stroke: #8430ce;
    stroke-opacity: 0.9;
    stroke-width: 0.42;
    stroke-linecap: butt;
    stroke-dasharray: 0.7 0.45;
    pointer-events: none;
}

/* Under the canvas (index.html), in the room the canvas leaves for it: it never
   covers the drawing. Hidden, it keeps its room so the canvas does not jump. */
.canvas-tool-hint {
    flex: 0 0 auto;
    align-self: center;
    box-sizing: border-box;
    width: max-content;
    max-width: 100%;
    min-height: 28px;
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid #8430ce;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    color: #5b1a91;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
}

/* "Updating the design…" while a drag waits for the solver: grey, not a lock note. */
.canvas-tool-hint.is-status {
    border-color: #c5cdd8;
    color: #5f6368;
}

.canvas-tool-hint[hidden] {
    display: block;
    visibility: hidden;
}

.handle.dragging {
    cursor: grabbing;
    fill: #dfe1e5;
    stroke: #000000;
}

.eraser-cursor {
    fill: #ffffff;
    stroke: #8a9099;
    stroke-width: 0.1;
    pointer-events: none;
}

.creation-cursor {
    fill: #000000;
    stroke: none;
    pointer-events: none;
}

.preview-layer .preview-point {
    fill: #1a73e8;
    stroke: none;
    pointer-events: none;
}

.target-metrics-panel {
    display: flex;
    align-self: stretch;
    min-height: 4.5rem;
    margin: 0 12px 12px;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.canvas-metrics-panel {
    display: none;
}

.target-metrics-card {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    min-height: 100%;
}

.target-metrics-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border-right: var(--workspace-section-border-width) solid var(--workspace-section-border);
}

.target-metrics-cell:last-child {
    border-right: none;
}

.target-metrics-label {
    color: #000000;
    font-size: clamp(13px, 1.1rem, 16px);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.target-metrics-value {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: clamp(10px, 0.9rem, 13px);
    font-weight: 600;
    color: #202124;
}

.target-metrics-value--empty {
    color: #80868b;
    font-weight: 500;
}

.aux-raster-container,
.result-container,
.target-container {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    container-type: size;
    padding: 8px 12px 0;
}

.demo-target-upper .target-container {
    padding: 12px 16px 16px;
}

.aux-preview-wrap {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.aux-preview-img,
.aux-preview-svg {
    box-sizing: border-box;
    width: min(100cqmin, 800px);
    height: min(100cqmin, 800px);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
    background: #ffffff;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 8px;
    box-shadow: none;
    object-fit: contain;
}

.demo-workspace .aux-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100cqmin, 800px);
    height: min(100cqmin, 800px);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    padding: 16px;
    box-sizing: border-box;
    color: #5f6368;
    background: #ffffff;
    border: 3px solid #000000;
    border-radius: 8px;
}

.demo-target-upper .aux-preview-img,
.demo-target-upper .aux-preview-svg,
.demo-target-upper .aux-preview-empty {
    width: min(100cqmin, 800px);
    height: min(100cqmin, 800px);
    border-color: #c5cdd8;
}

.demo-workspace .aux-preview-empty.hidden,
.demo-workspace .aux-preview-img.hidden {
    display: none;
}

.workspace-gutter {
    flex-shrink: 0;
    background: #ffffff;
    touch-action: none;
    z-index: 2;
}

.workspace-gutter:hover {
    background: #1a73e8;
}

.workspace-gutter-col-main,
.workspace-gutter-col-demo-target {
    width: var(--workspace-gutter-size);
    min-width: var(--workspace-gutter-size);
    cursor: col-resize;
}

.demo-workspace .workspace-twin-diagrams > .workspace-gutter-col-demo-target {
    grid-column: 2;
    grid-row: 3;
}

.workspace-gutter-row-demo-target,
.workspace-gutter-row-human-instruction {
    height: var(--workspace-row-gutter);
    min-height: var(--workspace-row-gutter);
    width: 100%;
    cursor: row-resize;
}

.workspace-ransac-optimization {
    grid-row: 3 / 6;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.demo-workspace .workspace-pane-llm-code,
.demo-workspace .pane-optimization {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 2.4fr) var(--workspace-row-gutter) minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
    padding: 0;
    border: none;
    background: transparent;
    overflow: visible;
}

.demo-result-upper {
    display: none;
}

.collaboration-upper {
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    margin: var(--workspace-pane-inset);
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--workspace-section-body-bg);
}

.collaboration-main {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 2.4fr) var(--workspace-row-gutter) minmax(0, 1fr);
}

.collaboration-thread-wrap {
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.optimization-panel {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.collaboration-thread {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.collaboration-self-edit-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    gap: 10px;
    align-items: stretch;
    padding: 8px 12px 12px;
    margin: 0;
    background: var(--workspace-section-body-bg);
}

.collaboration-do-it-myself-btn,
.collaboration-rollback-btn,
.collaboration-finish-btn {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 10px 8px;
    border: var(--workspace-section-border-width) solid var(--workspace-section-border);
    border-radius: 6px;
    color: #000000;
    background: #ffffff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
}

.collaboration-do-it-myself-btn:hover:not(:disabled),
.collaboration-rollback-btn:hover:not(:disabled),
.collaboration-finish-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #000000;
}

.collaboration-do-it-myself-btn:disabled,
.collaboration-rollback-btn:disabled,
.collaboration-finish-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.collaboration-empty {
    margin: 0;
    padding: 10px 12px;
    color: #5f6368;
    font-size: 14px;
    line-height: 1.45;
}

.rating-required-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.72);
}

.rating-required-dialog {
    width: min(360px, calc(100vw - 48px));
    padding: 22px;
    border: 4px solid #000000;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.rating-required-dialog h2 {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 1.2;
}

.rating-required-dialog p {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.4;
}

.rating-required-ok {
    min-width: 96px;
    padding: 8px 16px;
    border: 3px solid #000000;
    border-radius: 6px;
    background: #ffffff;
    color: #000000;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.finish-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

#comica-error-modal .rating-required-dialog {
    width: min(440px, calc(100vw - 48px));
}

#comica-error-modal .finish-confirm-actions {
    flex-wrap: wrap;
}

#comica-error-modal .comica-error-save-status {
    min-height: 1.4em;
    margin: 14px 0 0;
    color: #8a3400;
}

.collab-turn {
    margin-bottom: 18px;
    padding: 0 4px;
    border: none;
    background: transparent;
    box-shadow: none;
}

.collab-turn:last-child {
    margin-bottom: 0;
}

.collab-chat-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 30px;
    column-gap: 8px;
    align-items: start;
    width: 100%;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.collab-chat-row--agent .collab-chat-avatar {
    grid-column: 1;
}

.collab-chat-row--user .collab-chat-avatar {
    grid-column: 3;
}

.collab-chat-row .collab-chat-bubble {
    grid-column: 2;
}

.collab-chat-avatar {
    width: 30px;
    height: 30px;
    border: var(--collab-chat-border-width) solid var(--workspace-section-border);
    border-radius: 6px;
    background: #ffffff;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: none;
    box-sizing: border-box;
}

.collab-chat-bubble {
    width: 100%;
    padding: 10px 14px;
    border: var(--collab-chat-border-width) solid var(--workspace-section-border);
    border-radius: 12px;
    color: #000000;
    background: #ffffff;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: none;
    box-sizing: border-box;
}

.collab-chat-bubble--user {
    padding: 6px 10px;
}

.collab-chat-bubble--user-with-thumb {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
}

.collab-chat-bubble--agent-with-thumb {
    padding: 8px;
}

.collab-chat-text {
    margin: 0;
}

.collab-agent-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 68px;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 8px;
    align-items: start;
}

.collab-agent-layout--gpt {
    grid-template-rows: auto auto;
}

.collab-gpt-result-copy {
    min-height: 52px;
    justify-content: center;
    color: #3c4043;
    font-size: 13px;
}

.collab-agent-message-body {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.collab-agent-thumb-square {
    grid-column: 2;
    grid-row: 1;
    width: 52px;
    height: 52px;
    min-width: 0;
    align-self: start;
    justify-self: center;
    position: relative;
    overflow: hidden;
}

.collab-agent-debug-slot {
    grid-column: 1 / 3;
    grid-row: 2;
    min-width: 0;
}

.collab-agent-debug-slot--inline {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
}

.collab-agent-debug-slot .collab-debug {
    margin-top: 0;
}

.collab-debug-stack {
    overflow: hidden;
    border: 1px solid #d7dce2;
    border-radius: 8px;
    background: #f8f9fa;
}

.collab-debug-stack .collab-debug {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.collab-debug-stack .collab-turn-footer {
    margin-top: 0;
    padding: 6px 8px;
    border-top: 1px solid #d7dce2;
    align-items: center;
    justify-content: space-between;
}

.collab-debug-stack .collab-turn-status-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.collab-debug-stack .collab-turn-footer--rating-only {
    justify-content: flex-end;
}

.collab-debug-stack .collab-turn-footer--actions-only {
    justify-content: flex-end;
}

.collab-debug {
    margin: 4px 0 8px;
    padding: 6px 8px;
    border: 1px solid #d7dce2;
    border-radius: 8px;
    background: #f8f9fa;
}

.collab-debug > summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    cursor: pointer;
    font-size: var(--collab-font-debug, 13px);
    font-weight: 700;
    list-style-position: inside;
}

.collab-debug-total {
    margin-left: auto;
    color: #5f6368;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 500;
    white-space: nowrap;
}

.collab-debug-body {
    display: grid;
    gap: 8px;
    margin-top: 6px;
}

.collab-debug-section-title {
    margin: 0 0 4px;
    color: #3c4043;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.collab-error-section {
    padding: 8px;
    border: 1px solid #f1b8b4;
    border-radius: 7px;
    background: #fce8e6;
}

.collab-error-section p {
    margin: 0;
    color: #8c1d18;
    font-size: var(--collab-font-debug, 13px);
    overflow-wrap: anywhere;
}

.collab-usage-rows {
    display: grid;
    gap: 6px;
}

.collab-usage-row {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    font-size: var(--collab-font-debug, 13px);
}

.collab-usage-label {
    color: #3c4043;
    font-weight: 600;
    white-space: nowrap;
}

.collab-usage-value {
    min-width: 0;
    color: #202124;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

.generation-timing-rows {
    margin-top: 6px;
}

.generation-timing-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) max-content;
    gap: 5px;
    align-items: baseline;
    padding: 2px 0;
    font-size: 12px;
}

.generation-timing-status {
    color: #188038;
    font-weight: 700;
}

.generation-timing-status--error {
    color: #d93025;
}

.generation-timing-status--running {
    color: #1a73e8;
}

.generation-timing-duration {
    color: #3c4043;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.generation-timing-empty {
    color: #80868b;
    font-size: 12px;
}

.collab-agent-thumb-square .collab-drawing-thumb,
.collab-agent-thumb-square .collab-result-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.collab-agent-thumb-verdict {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.collab-agent-thumb-verdict .collab-verdict-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    justify-items: stretch;
}

.collab-agent-thumb-verdict .collab-rating-btn {
    width: 100%;
    height: 22px;
    min-width: 0;
    font-size: 12px;
}

.collab-agent-thumb-verdict .collab-verdict-mark-rating {
    height: 24px;
    min-width: 76px;
    padding: 0 6px;
    font-size: 12px;
}

.collab-drawing-thumb {
    width: 52px;
    height: 52px;
    padding: 0;
    border: var(--collab-chat-border-width) solid #000000;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
    display: block;
}

.collab-drawing-thumb:hover,
.collab-drawing-thumb:focus-visible {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.16);
    outline: none;
}

.collab-drawing-thumb.is-canvas-preview-active {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.25);
}

.collab-drawing-thumb svg {
    display: block;
    width: 100%;
    height: 100%;
}

.collab-drawing-thumb-cad {
    fill: none;
    stroke: #9aa0a6;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.collab-result-thumb .collab-drawing-thumb-cad {
    stroke: #000000;
    stroke-width: 1.8;
}

.collab-drawing-thumb-red {
    fill: none;
    stroke: #e53935;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.collab-chat-bubble--running {
    border-style: dashed;
}

.comica-live-progress {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-width: 220px;
}

.comica-live-progress-indicator {
    width: 14px;
    height: 14px;
    margin-top: 2px;
    border: 2px solid #d2e3fc;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: comica-progress-spin 0.9s linear infinite;
}

.comica-live-progress-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #3c4043;
    font-size: 12px;
    line-height: 1.35;
}

.comica-live-progress-copy strong {
    color: #202124;
    font-size: 13px;
}

.comica-live-progress-safe {
    color: #5f6368;
}

.collab-cancel-btn {
    height: 26px;
    padding: 0 10px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    background: #ffffff;
    color: #3c4043;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
}

.collab-cancel-btn:hover,
.collab-cancel-btn:focus-visible {
    border-color: #1a73e8;
    color: #174ea6;
    outline: none;
}

@keyframes comica-progress-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .comica-live-progress-indicator {
        animation: none;
    }
}

.collab-agent-summary-line {
    margin: 0 0 6px;
    font-weight: 700;
}

.collab-turn-log {
    margin: 0;
    padding: 0;
    color: #3c4043;
}

.collab-log-line {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 12px;
    align-items: baseline;
    margin: 2px 0;
    font-size: 13px;
    line-height: 1.4;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
}

.collab-log-ts {
    display: block;
    margin-right: 0;
    color: #80868b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.collab-log-msg {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.collab-log-line.collab-log-milestone {
    display: block;
    color: #202124;
    font-size: 14px;
    font-weight: 600;
}

.collab-log-line.collab-log-milestone .collab-log-ts {
    display: none;
}

.collab-log-line.collab-log-file {
    display: block;
    font-size: 13px;
}

.collab-log-open {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    color: #1a73e8;
    font: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.collab-log-open:hover {
    color: #174ea6;
}

.collab-log-line.collab-log-detail {
    color: #5f6368;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
}

.collab-log-line.collab-log-reject {
    color: #c5221f;
    font-weight: 600;
}

.collab-log-line.collab-log-reject-detail {
    color: #b31412;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.4;
    padding-left: 1.25rem;
}

.collab-turn-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.collab-turn-status {
    flex: 0 0 auto;
    color: #5f6368;
    font-size: 12px;
    font-weight: 700;
}

.collab-turn-status-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.collab-turn-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.collab-turn--running .collab-turn-status {
    color: #1a73e8;
}

.collab-turn--error .collab-turn-status,
.collab-turn--rejected .collab-turn-status {
    color: #c5221f;
}

.collab-turn--cancelled .collab-turn-status {
    color: #5f6368;
}

.collab-turn--accepted .collab-turn-status {
    color: #137333;
}

.collab-turn--partial .collab-turn-status {
    color: #e37400;
}

.collab-verdict-actions {
    display: inline-grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}

.collab-rating-btn,
.collab-verdict-mark-rating {
    min-width: 1.5rem;
    height: 1.5rem;
    border: 1px solid #1a73e8;
    border-radius: 999px;
    color: #1a73e8;
    background: #ffffff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.collab-rating-btn {
    cursor: pointer;
}

.collab-rating-btn:hover {
    background: #e8f0fe;
}

.collab-verdict-mark-rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    padding: 0 8px;
}

.optimization-instruction-field {
    grid-row: 3;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0 12px 12px;
    border: none;
    border-radius: 0;
    background: #ffffff;
}

textarea.optimization-instruction-textarea {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    resize: none;
    padding: 14px;
    border: 3px solid #c5cdd8;
    border-radius: 8px;
    color: #202124;
    background: #ffffff;
    font-size: 20px;
    line-height: 1.4;
    outline: none;
}

textarea.optimization-instruction-textarea:placeholder-shown {
    text-align: center;
}

.optimization-instruction-btn {
    position: absolute;
    bottom: var(--optimization-action-btn-inset);
    width: var(--optimization-action-btn-size);
    height: var(--optimization-action-btn-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #000000;
    border-radius: 8px;
    color: #000000;
    background: #ffffff;
    font-weight: 800;
    cursor: pointer;
}

.optimization-draw-btn-infield {
    left: var(--optimization-action-btn-inset);
}

.optimization-instruction-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
}

body[data-preview-mode="true"] #demo-btn-optimization-apply-gpt6 {
    order: -1;
}

/* Demo server (python server.py --demo): no countdown, pause or help button for visitors. */
body[data-demo-mode="true"] #demo-experiment-time-label,
body[data-demo-mode="true"] #demo-btn-speaker-pause,
body[data-demo-mode="true"] #demo-btn-help,
body[data-demo-mode="true"] [data-study-only],
body:not([data-demo-mode="true"]) [data-demo-only] {
    display: none !important;
}

/* No Rollback button: the toolbar's Undo goes back one round when there are no
   sketch strokes. It stays in the page, hidden, because Undo reads its enabled
   state; Submit takes the whole row. */
#demo-btn-collab-rollback {
    display: none !important;
}

/* Demo: no header row (mode label, Target progress, timer box) and no Quick
   reminders panel; Target, canvas and conversation fill the whole height. */
body[data-demo-mode="true"] .demo-workspace .demo-experiment-mode-header,
body[data-demo-mode="true"] .demo-workspace .demo-experiment-progress,
body[data-demo-mode="true"] .demo-workspace .demo-experiment-time-header,
body[data-demo-mode="true"] .demo-workspace .pane-target .workspace-gutter-row-demo-target,
body[data-demo-mode="true"] .demo-workspace .pane-target .demo-target-desc-panel,
body[data-demo-mode="true"] #study-end-actions {
    display: none !important;
}
/* (#study-end-actions: Rollback and Submit. Undo already goes back one round and
   Random loads another Target. The buttons stay in the page, hidden, because
   Undo reads Rollback's enabled state.) */

body[data-demo-mode="true"] .demo-workspace .workspace-twin-diagrams,
body[data-demo-mode="true"] .demo-workspace > .workspace-ransac-right {
    grid-template-rows: 0 0 minmax(0, 1fr) 0 0;
}

.optimization-apply-btn-infield {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    width: auto;
    height: 64px;
    flex: 1 1 0;
    font-size: 22px;
}

.optimization-instruction-btn:disabled {
    background: #f1f3f4;
    border-color: #c5cdd8;
    color: #9aa0a6;
    box-shadow: none;
    cursor: default;
}

.demo-toolbox .optimization-draw-btn {
    color: #d93025;
    border-color: #d93025;
}

.demo-toolbox .optimization-draw-btn:hover:not(:disabled),
.demo-toolbox .optimization-draw-btn.active:not(:disabled) {
    background: #fce8e6;
    border-color: #d93025;
    color: #d93025;
    box-shadow: 0 0 0 2px rgba(217, 48, 37, 0.16);
}

.demo-toolbox .optimization-draw-btn:disabled {
    background: #f1f3f4;
    border-color: #c5cdd8;
    color: #9aa0a6;
    box-shadow: none;
}

.optimization-instruction-btn:hover {
    background: #e0e0e0;
}

.optimization-draw-btn {
    border-color: #d93025;
    color: #d93025;
}

.optimization-draw-btn:hover,
.optimization-draw-btn.active {
    background: #fce8e6;
    border-color: #d93025;
    box-shadow: 0 0 0 2px rgba(217, 48, 37, 0.16);
}

.optimization-apply-btn {
    border-color: #1e8e3e;
    color: #1e8e3e;
}

.optimization-apply-btn:hover {
    background: #e6f4ea;
    border-color: #137333;
    box-shadow: 0 0 0 2px rgba(30, 142, 62, 0.16);
}

.optimization-apply-btn-label {
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: normal;
    line-height: 1;
}

.curve-line {
    fill: none;
    stroke: #000000;
    stroke-width: 0.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.curves-layer .curve-element {
    cursor: pointer;
    stroke: #202124;
}

.curves-layer .curve-element:hover {
    stroke: #1a73e8;
}

.curve-target {
    stroke: #000000;
}

.curve-canvas {
    stroke: #000000;
}

.curve-coincided {
    stroke: #18864b;
}

.curve-result {
    stroke: #1a73e8;
}

.curve-ghost {
    stroke: #5f6368;
    stroke-dasharray: 0.3 0.2;
    stroke-width: 0.15;
}

.draw-cursor {
    fill: #d93025;
    stroke: none;
    pointer-events: none;
}

.draw-layer .draw-stroke {
    fill: none;
    stroke: #d93025;
    stroke-width: 0.18;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.9;
    pointer-events: none;
}

.dialog {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(32, 33, 36, 0.35);
}

.dialog.hidden {
    display: none;
}

.dialog-content {
    min-width: min(420px, calc(100vw - 48px));
    max-width: min(460px, calc(100vw - 48px));
    padding: 24px;
    border: 1px solid #e2e6ec;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.dialog-content h3 {
    margin: 0 0 16px;
    color: #1a1a1a;
    font-size: 18px;
    font-weight: 600;
}

.dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.dialog-buttons button {
    padding: 6px 16px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    background: #ffffff;
    color: #2c3338;
    cursor: pointer;
    font-size: 13px;
}

.collab-agent-progress {
    margin: 0 0 8px;
    color: #1a73e8;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.collab-review-btn {
    padding: 4px 12px;
    border: 1px solid #1a73e8;
    border-radius: 999px;
    background: #ffffff;
    color: #1a73e8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.collab-failure-reason {
    margin: 8px 0 2px;
    padding: 8px 10px;
    border-left: 3px solid #b7791f;
    background: #fff8e8;
    color: #202124;
}

.collab-recovery-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.collab-recovery-actions button {
    border: 1px solid #b7b7b7;
    border-radius: 6px;
    padding: 6px 10px;
    background: #fff;
    cursor: pointer;
}
.collab-recovery-actions button:disabled { opacity: .5; cursor: default; }


.comica-result-status { font-size: 12px; color: #596575; padding: 2px 8px; min-height: 18px; }

/* Protocol B (single stage): no Target metrics during a task; task actions. */
body[data-study-protocol="single_stage_v1"] #demo-target-metrics-panel {
    display: none;
}

.study-end-actions {
    display: none;
}

body[data-study-protocol="single_stage_v1"] .study-end-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
}

.study-end-btn {
    flex: 1 1 0;
    height: 44px;
    border: 2px solid #5f6368;
    border-radius: 8px;
    background: #ffffff;
    color: #202124;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.study-end-btn--primary {
    border-color: #000000;
    border-width: 3px;
}

.study-end-btn--quiet {
    color: #5f6368;
}

.study-end-btn:disabled {
    border-color: #c5cdd8;
    background: #f1f3f4;
    color: #9aa0a6;
    cursor: not-allowed;
}

.collab-chat-bubble--drag .collab-chat-text {
    color: #5f6368;
    font-style: italic;
}

/* Network retry notice (api/net.js): shown only while a request is being retried. */
.net-status-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 8px 16px;
    border: 1px solid #f0b46b;
    border-radius: 8px;
    background: #fff4e5;
    color: #8a4b00;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.net-status-banner[hidden] { display: none; }
