/* ============================================================================
   Arcadia Designer — mobile-first layout.

   The base rules define the phone layout (fluid, full-bleed canvas, bottom
   pill toolbar, bottom-sheet inspector, full-screen overlays). The desktop
   layout is restored in the @media (min-width: 768px) block at the bottom,
   using the original desktop values.

   Touch devices keep enlarged canvas handles at any width via the
   @media (pointer: coarse) block (touch laptops).
   ========================================================================== */

:root {
    --shell: #2C3E50;
    --blue: #2980B9;
    --green: #27AE60;
    --red: #C0392B;
    --grey: #7F8C8D;
    --panel: #34495E;
    --border: rgba(255, 255, 255, 0.12);
    --canvas: #ECF0F1;
    --text: #FFFFFF;
    --muted: rgba(255, 255, 255, 0.6);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body, #main {
    height: 100%;
}

/* One zoom only: the canvas. 'manipulation' kills the browser's double-tap
   page zoom on the app chrome (the meta above kills its pinch zoom; the
   canvas is touch-action:none, so its pinch drives the canvas zoom). */
html {
    touch-action: manipulation;
}

/* dvh tracks the visual viewport, so the app does not jump when the mobile
   browser URL bar shows/hides. */
#main {
    height: 100dvh;
}

.app-root {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--shell);
    overflow: hidden;
}

/* Mobile base: border-box so width-specified containers (cards, sheets,
   overlays) include their padding and never overflow the viewport. The
   desktop block restores content-box (the pre-existing behavior). */
* {
    box-sizing: border-box;
}

/* ---- Gate (login / boot) ------------------------------------------------- */

.gate {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.card {
    width: min(380px, calc(100vw - 32px));
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.card h1 {
    font-size: 20px;
    margin-bottom: 4px;
}

.card .tagline {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0;
}

.ok {
    color: #28a745;
    font-size: 13px;
    margin: 8px 0;
}

.error-text {
    color: #E74C3C;
    font-size: 12px;
    margin: 8px 0;
}

/* ---- Buttons & inputs ------------------------------------------------------
   16px inputs stop iOS from zooming on focus; targets are >= 44px. */

.btn {
    padding: 13px 24px;
    border-radius: 6px;
    border: none;
    background: var(--blue);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(0.95);
}

.btn.secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 11px 16px;
    font-size: 14px;
}

.btn.danger {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 11px 16px;
    font-size: 14px;
}

.btn.deploy {
    background: var(--green);
    padding: 11px 16px;
    font-size: 14px;
}

.input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 16px;
    margin-top: 4px;
    font-family: inherit;
    background: var(--shell);
    color: #fff;
}

.save-status {
    font-size: 11px;
    color: var(--muted);
    margin-top: 12px;
}

/* ---- Shell ---------------------------------------------------------------- */

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

/* Mobile header: title + design name + Deploy + overflow menu. The version
   and state badges, the deploy status line, and the secondary actions live
   in the overflow sheet (".header-menu") on phones. */
.header {
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

/* The home crumb: a real button (it navigates), styled as the old title. */
.header .title {
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 2px 0;
    cursor: pointer;
    white-space: nowrap;
}

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

.header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.deploy-status {
    display: none;
    margin-left: 12px;
    font-size: 11px;
    color: var(--muted);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.badge-state,
.badge-save {
    display: none;
}

/* Secondary header actions move into the overflow menu on phones. */
.btn-freeze,
.btn-designs,
.btn-logout {
    display: none;
}

.header-menu-btn {
    display: inline-flex;
}

.main-row {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

/* Mobile toolbar: a floating pill along the bottom edge (the category norm
   for canvas apps on phones). 12 tools do not fit in 375px, so the pill
   scrolls horizontally. */
.rail {
    position: absolute;
    left: 50%;
    bottom: calc(12px + var(--safe-bottom));
    transform: translateX(-50%);
    flex: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: auto;
    max-width: calc(100vw - 16px);
    height: auto;
    padding: 6px 8px;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    z-index: 18;
    scrollbar-width: none;
}

.rail::-webkit-scrollbar {
    display: none;
}

.tool {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 2px;
    text-align: center;
}

/* The whole button is painted the element's color (matching the canvas
   boxes), text contrast per type. Colors live in CSS, one rule per type,
   because a style attribute on a view! element is not applied in this
   Leptos version. */
.tool.tool-command { background: #4A90D9; color: #fff; }
.tool.tool-event { background: #F5A623; color: #1F2933; }
.tool.tool-aggregate { background: #F8E71C; color: #1F2933; }
.tool.tool-policy { background: #9B59B6; color: #fff; }
.tool.tool-readmodel { background: #7ED321; color: #1F2933; }
.tool.tool-external { background: #E91E8C; color: #fff; }
.tool.tool-actor { background: #FFEB3B; color: #1F2933; }
.tool.tool-hotspot { background: #FF5722; color: #fff; }
.tool.tool-boundedcontext { background: #607D8B; color: #fff; }
.tool.tool-flow { background: #00897B; color: #fff; }

/* The selected tool: a ring, not a fill (the fill is the type color). */
.tool.active {
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--blue);
}

/* The version-compare button sits in its own section of the rail. */
.tool.tool-diff {
    background: var(--blue);
    color: #fff;
    margin-top: 0;
    margin-left: 6px;
}

.tool.tool-deployments {
    background: var(--green);
    color: #fff;
}

.tool.tool-console {
    background: #FF9800;
    color: #1F2933;
}

/* The tools that do not fit a phone dock (13 buttons would not fit in
   375px): hidden in the mobile pill, reachable from the "⋯" sheet.
   The desktop media block below restores all of them. */
.tool.tool-external,
.tool.tool-actor,
.tool.tool-hotspot,
.tool.tool-flow,
.tool.tool-diff,
.tool.tool-deployments,
.tool.tool-console {
    display: none;
}

/* The "more tools" opener: a neutral button at the end of the dock row
   (mobile only; the desktop rail shows everything, so it is hidden there). */
.tool.tool-more {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 18px;
}

/* Undo/redo in the dock row (mobile only; hidden in the desktop media
   block, where the rail keeps its original shape and the ⌘/Ctrl+Z
   shortcuts take over). Dimmed while the stack is empty. */
.tool.tool-undo,
.tool.tool-redo {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 17px;
}

.tool.tool-undo.disabled,
.tool.tool-redo.disabled {
    opacity: 0.35;
}

/* ---- Canvas ---------------------------------------------------------------- */

.canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--canvas);
    touch-action: none;
}

/* The canvas island on the home page: hidden, never unmounted (its node
   ref would re-attach the canvas). */
.canvas-wrap.canvas-hidden {
    display: none;
}

.canvas-host {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: none;
}

.canvas-viewport {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    touch-action: none;
}

.canvas-content {
    position: absolute;
    top: 0;
    left: 0;
}

.canvas-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

/* ---- Inspector (mobile: bottom sheet) --------------------------------------
   Out of the flex row so the canvas is full-width; slides over the canvas.
   The collapsed state (nothing selected) shrinks to zero and parks the
   chevron as a floating button above the toolbar pill. */

.inspector {
    position: absolute;
    left: 0;
    right: 0;
    /* Above the toolbar pill (58px tall + 12px offset) so the pill stays
       reachable while the sheet is open. */
    bottom: calc(70px + var(--safe-bottom));
    flex: none;
    width: auto;
    /* Full sheet height: the sheet is only shown when the user opens it
       (chevron), so it is no longer in the way of dragging. */
    height: 72vh;
    height: 72dvh;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    background: var(--panel);
    /* Small bottom margin only; the dock row sits under the sheet, so there
       is no floating control to clear (the chevron is gone on phones). */
    padding: 10px 16px calc(10px + var(--safe-bottom));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    z-index: 25;
}

/* The sheet's drag handle: a real element (not a pseudo) so it can carry
   the pointer drag that resizes the sheet and snaps on release. Desktop
   hides it in the media block below. */
.sheet-grabber {
    position: relative;
    width: 100%;
    height: 24px;
    margin: -4px 0 6px;
    flex: none;
    cursor: ns-resize;
    touch-action: none;
}

.sheet-grabber::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.3);
}

/* The sheet's own dismiss, top right (mobile only): visible while the sheet
   is open, and sticky so the content scrolling cannot take it away. */
.inspector-x {
    position: sticky;
    top: 10px;
    float: right;
    width: 30px;
    height: 30px;
    margin: 0 0 10px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

/* A collapsible sheet section (mobile only): keeps the open sheet short.
   Desktop renders the same blocks as flat label rows instead (inspector.rs
   branches on the viewport width). */
.insp-section {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px 10px;
}

.insp-section summary {
    padding: 10px 2px 8px;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
}

/* The frame's deployment block: the badge values and the action row. */
.insp-value {
    font-size: 13px;
    margin: 2px 0 8px;
}

.insp-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0 4px;
}

/* The "more tools" sheet (mobile only): the six dock tools that do not fit
   a phone width, in a small bottom sheet just above the dock row. */
.tools-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(70px + var(--safe-bottom));
    flex: none;
    width: auto;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    background: var(--panel);
    padding: 10px 16px calc(12px + var(--safe-bottom));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    z-index: 26;
}

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

.sheet-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
}

.sheet-tool svg {
    width: 20px;
    height: 20px;
}

.sheet-tool-glyph {
    font-size: 18px;
    line-height: 1.2;
}

/* Zero-sized states: "collapsed" (nothing selected, user closed it) and
   "selected-only" (an element is selected but the user has not opened the
   sheet - Freeform-style: selection and inspector are distinct actions).
   On desktop the media block below re-expands "selected-only" into the full
   panel. The fixed chevron escapes the zero-sized panel either way. */
.inspector.collapsed,
.inspector.selected-only {
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    /* Clip the (zero-sized) panel's content; the fixed chevron escapes. */
    overflow: hidden;
}

/* The chevron FAB is a mobile leftover of the pre-sheet design: hidden on
   phones now that the context bar opens the sheet and its X closes it. The
   desktop media block restores the sliver chevron (the original behavior). */
.chevron {
    display: none;
    position: fixed;
    right: 12px;
    bottom: calc(74px + var(--safe-bottom));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--panel);
    cursor: pointer;
    font-weight: bold;
    color: var(--muted);
    z-index: 20;
}

.inspector h2 {
    font-size: 13px;
    margin-bottom: 12px;
}

.inspector .type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #9E9E9E;
}

.inspector .type-badge.element-command { background: #4A90D9; }
.inspector .type-badge.element-event { background: #F5A623; }
.inspector .type-badge.element-aggregate { background: #F8E71C; color: #222; }
.inspector .type-badge.element-policy { background: #9B59B6; }
.inspector .type-badge.element-readmodel { background: #7ED321; color: #222; }
.inspector .type-badge.element-external { background: #E91E8C; }
.inspector .type-badge.element-actor { background: #FFEB3B; color: #222; }
.inspector .type-badge.element-hotspot { background: #FF5722; }
.inspector .type-badge.element-boundedcontext { background: #607D8B; }
.inspector .type-badge.element-flow { background: #00897B; color: #fff; }
.inspector .type-badge.element-step { background: #26A69A; color: #1F2933; }

.field-label {
    font-size: 11px;
    color: var(--muted);
    margin-top: 10px;
}

/* Field editor rows (inspector). */
.field-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
/* Zero-height full-width spacer: pushes a field row's optional controls
   (op/value for invariants, op/key/source for projections) onto a second
   line so the name input keeps its full width on a 320px panel. */
.field-row2-break {
    flex: 1 1 100%;
    width: 0;
    height: 0;
}

/* Per-event effect rows: field + op (numbers) + source. */
.effect-field {
    flex: 1 1 auto;
    min-width: 70px;
    font-size: 12px;
}
.effect-op {
    flex: 0 0 52px;
    width: 52px;
    font-size: 12px;
}
.effect-source {
    flex: 1 1 auto;
    min-width: 96px;
    font-size: 12px;
}
.effect-const {
    flex: 0 0 64px;
    width: 64px;
    font-size: 12px;
}
/* The "add field" row has no second line; keep it on one line. */
.field-add {
    flex-wrap: nowrap;
}
.field-row .input {
    margin-top: 0;
    flex: 1;
    min-width: 0;
}
.field-row .field-type {
    flex: 0 0 84px;
}
.field-row .field-of {
    flex: 0 1 90px;
}
.field-row .field-op {
    flex: 0 0 52px;
}
.field-row .field-value {
    flex: 0 1 70px;
}
.field-inv {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}
.field-del {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--shell);
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.field-del:hover {
    color: #fff;
    border-color: var(--red);
}
/* A pinned-area row (the flow inspector's pin section): name + version +
   unpin. */
.pin-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.pin-ver {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted);
}
.field-add .btn {
    flex: 0 0 auto;
    padding: 11px 14px;
    font-size: 14px;
    margin-top: 0;
}
/* The inspector's Delete button: full width on the phone sheet. */
.btn-delete {
    width: 100%;
}
/* The inspector's Tidy button (above Delete): full width to match. */
.btn-tidy {
    width: 100%;
}
/* The inspector's "Move connected elements" section (#172) and the drop
   group-move dialog share one preview: the destination row (a picker in the
   inspector, a fixed label in the dialog), the member rows, the blockers,
   and the Move / Cancel actions. */
.move-connected .gm-dest {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 5px;
    font-size: 13px;
}
.move-connected .gm-dest .input {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0;
}
.gm-dest-name {
    color: var(--blue);
    font-weight: 600;
}
.move-connected .gm-caption {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}
.move-connected .gm-rows {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 180px;
    overflow-y: auto;
}
.gm-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    padding: 3px 4px;
}
.gm-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blue);
    flex: none;
}
.gm-row.gm-more {
    color: var(--muted);
}
.gm-blocked {
    font-size: 12px;
    color: var(--red);
    padding: 3px 4px;
}
.move-connected .gm-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.move-connected .gm-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
}
.move-connected .btn-move-connected {
    padding: 11px 14px;
    font-size: 14px;
}
.move-connected .btn-move-connected:disabled {
    opacity: 0.5;
    cursor: default;
}
/* The drop group-move dialog (#172): a centered card over a backdrop; the
   backdrop click cancels (the model ends as before the drag). Base rules
   are the phone layout (edge-to-edge, like .diff-card). */
.gm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gm-card {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Behavior section (inspector). */
.behavior-label {
    margin-top: 14px;
}
.behavior-row {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.45;
}
.behavior-row .behavior-title {
    color: var(--text);
}
.behavior-row .behavior-fields {
    color: var(--muted);
}
.behavior-row .kind-select {
    margin-top: 6px;
    width: 96px;
    font-size: 11px;
    padding: 3px 6px;
}

/* ---- Overlays (mobile: full-screen) ----------------------------------------
   The picker overlay, the diff card, and the console/deployments cards (which
   ride inside .diff-overlay) all go edge-to-edge on phones. */

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 0;
}

.overlay .panel {
    width: 100vw;
    max-width: 100vw;
    max-height: 100%;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.overlay .panel h2 {
    font-size: 15px;
    margin-bottom: 12px;
}

.picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.picker-row .name {
    flex: 1;
    font-size: 14px;
    cursor: pointer;
}

.picker-row .meta {
    font-size: 11px;
    color: var(--muted);
}

.picker-new {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

.picker-new .input {
    margin-top: 0;
}

.picker-row .btn {
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.picker-row input.input {
    flex: 1;
    margin-top: 0;
}

.diff-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.diff-overlay.hidden {
    display: none;
}

.diff-card {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.diff-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.diff-title-row h2 {
    font-size: 15px;
    margin: 0;
}

.diff-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 18px;
    padding: 10px 12px;
    cursor: pointer;
}

.diff-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.diff-controls .input {
    width: auto;
    flex: 1;
    margin-top: 0;
}

.diff-summary {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 8px;
}

.diff-line {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.87);
    margin: 2px 0;
}

.diff-empty {
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0;
}

/* Migration dialog. */
.migration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
}

.migration-card {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.migration-context {
    margin-top: 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text);
}

.migration-event {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.migration-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.migration-field .migration-label {
    flex: 0 0 140px;
    font-size: 12px;
}
.migration-field .migration-strategy {
    flex: 1;
    min-width: 0;
    margin-top: 0;
}
.migration-field .migration-default {
    flex: 0 1 160px;
    margin-top: 0;
}
.migration-warn {
    margin-top: 10px;
    font-size: 12px;
    color: #e67e22;
}

/* Deployments card + watch feed (rides inside .diff-overlay). */
.deployments-card {
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
}

.deployment-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.deployment-row.watching {
    background: rgba(39, 174, 96, 0.15);
    border-radius: 6px;
}
.deployment-row .deployment-ctx {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.deployment-row .deployment-meta {
    color: var(--muted);
    font-size: 11px;
}

.badge.live {
    background: rgba(39, 174, 96, 0.3);
}
.badge.failed {
    background: rgba(192, 57, 43, 0.35);
}
.badge.retired {
    background: rgba(255, 255, 255, 0.15);
}

.watch-section {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}
.watch-section .diff-title-row h2 {
    font-size: 13px;
}
.watch-event {
    margin-top: 6px;
    padding: 6px 8px;
    border-left: 2px solid var(--blue);
    background: rgba(255, 255, 255, 0.04);
}
.watch-event .watch-line {
    font-size: 12px;
}
.watch-event .watch-data {
    font-size: 11px;
    color: var(--muted);
    font-family: ui-monospace, monospace;
    overflow-x: auto;
    white-space: nowrap;
}

/* Operator console (instances, state, commands). */
.console-card {
    width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
}

.console-agg {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.console-agg-title {
    padding: 10px 10px;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
}
.console-agg-title .muted {
    font-weight: 400;
    margin-left: 8px;
}
.console-instance {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    margin: 2px 6px;
    padding: 12px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--fg);
    cursor: pointer;
    font-size: 13px;
}
.console-instance:hover {
    background: rgba(255, 255, 255, 0.06);
}
.console-instance.selected {
    border-color: var(--blue);
    background: rgba(33, 150, 243, 0.12);
}
.console-instance .instance-id {
    font-family: ui-monospace, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.console-instance .muted {
    font-size: 11px;
}
.console-state {
    margin: 8px 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: ui-monospace, monospace;
    max-height: 40vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.console-error {
    margin: 8px 0;
    font-size: 12px;
    color: #e67e22;
}
.console-warning {
    margin: 8px 0;
    font-size: 12px;
    color: #e67e22;
}
.console-stale {
    margin-left: 6px;
    padding: 0 6px;
    border: 1px solid #e67e22;
    border-radius: 4px;
    font-size: 11px;
    color: #e67e22;
    white-space: nowrap;
}
.console-cmd {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.console-key-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.console-key-row .cmd-param {
    flex: 1;
    min-width: 0;
}
.console-cmd .cmd-name {
    font-size: 12px;
    font-weight: 600;
    min-width: 90px;
}
.console-cmd .cmd-param {
    flex: 1;
    min-width: 0;
}

/* ---- Toast & validation findings ------------------------------------------
   Parked above the toolbar pill; the findings drawer is a top strip on
   phones (a bottom strip would collide with the pill and the zoom cluster). */

.toast {
    position: fixed;
    bottom: calc(74px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--border);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 90vw;
    z-index: 30;
    cursor: pointer;
}

/* The persistent drop-refusal note (#172): viewport-anchored near the drop
   point (positioned by the canvas), red-accented, and - unlike the toast -
   it stays until dismissed or the next drag starts. */
.move-pin {
    position: absolute;
    max-width: 250px;
    background: #2C3E50;
    border: 1px solid rgba(192, 57, 43, 0.8);
    border-left: 3px solid var(--red);
    border-radius: 6px;
    padding: 8px 26px 8px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
    z-index: 25;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.move-pin.hidden {
    display: none;
}
.move-pin-line {
    overflow-wrap: anywhere;
}
.move-pin-body .move-pin-line:first-child {
    color: #fff;
    font-weight: 700;
    margin-bottom: 2px;
}
.move-pin-x {
    position: absolute;
    top: 4px;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    padding: 3px 4px;
    cursor: pointer;
}

.issues-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    /* Below the header (48px) so it never covers the header actions. */
    top: calc(56px + var(--safe-top));
    width: auto;
    max-height: 200px;
    overflow: auto;
    background: #2C3E50;
    border: 1px solid #FFFFFF22;
    border-radius: 6px;
    z-index: 20;
}
.issues-panel.hidden {
    display: none;
}
.issues-title {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    padding: 8px 10px 4px;
    margin: 0;
}
.issue-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #ffffff88;
    padding: 8px 10px 0;
    margin: 0;
}
.issue-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
}
.issue-row:hover {
    background: #ffffff14;
}
.issue-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 4px;
}
/* Severity, not kind: the question the panel answers is "can I deploy?".
   The kind is already stated in the message text. */
.issue-dot.dot-blocking { background: #E74C3C; }
.issue-dot.dot-warning { background: #F1C40F; }
.issue-msg {
    font-size: 11px;
    color: #ffffffdd;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    z-index: 50;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ---- Canvas items ----------------------------------------------------------- */

.item {
    position: absolute;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: move;
    box-sizing: border-box;
    overflow: visible;
    user-select: none;
    color: #2C3E50;
}

.item-body {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border-radius: 6px;
    padding: 6px 8px;
    overflow: hidden;
    color: #2C3E50;
}

/* The resize dot is 16px on phones: big enough for a finger, small enough
   to read as a handle, not a second element (the @media (pointer: coarse)
   block re-applies it at desktop widths on touch laptops). */
.resize-handle {
    position: absolute;
    right: -8px;
    bottom: -8px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #111;
    border: 2px solid #fff;
    cursor: nwse-resize;
}

.item.selected {
    border-color: #111;
}

/* Connection ports on the selected element: press one to draw a wiring. */
.edge-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #111;
    cursor: crosshair;
    z-index: 6;
}
.edge-handle.eh-left {
    left: -8px;
    top: calc(50% - 8px);
}
.edge-handle.eh-right {
    left: calc(100% - 8px);
    top: calc(50% - 8px);
}
.edge-handle.eh-top {
    left: calc(50% - 8px);
    top: -8px;
}
.edge-handle.eh-bottom {
    left: calc(50% - 8px);
    top: calc(100% - 8px);
}

/* Contextual action bar on the selected element: the Freeform-style
   "More" — the element-specific way to open the inspector, plus a quick
   delete (so deleting never needs the sheet). One per canvas, anchored to
   the viewport (update_bar pins it above the selection): a constant
   on-screen size through pan/zoom, and able to rise above the issues panel.
   Hidden when nothing is selected and on desktop (where the side panel is
   the inspector). */
.item-bar {
    position: absolute;
    left: 0;
    top: 0;
    /* update_bar writes the element's top-center anchor in viewport
       coordinates; the transform lifts the bar above it and centers it. */
    transform: translate(-50%, calc(-100% - 8px));
    display: flex;
    gap: 6px;
    padding: 5px 6px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    /* Above the issues panel (20) and the rail (18); below the sheet (25)
       and the overlays (40). */
    z-index: 22;
    user-select: none;
    touch-action: none;
}
.item-bar.hidden {
    display: none;
}
.item-bar .bar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hovered drop target while drawing a connection. */
.item.drop-target {
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.35);
}

/* The group an open move preview (#172) would take: outlined in the accent
   color while the dialog waits for Move / Cancel. */
.item.move-pending {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.45);
}

.item .type-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.item .item-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item .item-desc {
    font-size: 11px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item .issue-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 14px;
    height: 14px;
    border-radius: 7px;
    background: #e74c3c;
    border: 2px solid #fff;
}

.item.container {
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.35) !important;
}

.item.container .ctx-header {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    margin: -6px -8px 4px;
    border-radius: 4px 4px 0 0;
    background: rgba(255, 255, 255, 0.55);
}

/* A flow frame reads as a flow (teal), a context frame as a box (gray). */
.item.element-flow {
    border-color: rgba(0, 137, 123, 0.8);
}

.item.element-flow .ctx-header {
    background: rgba(0, 137, 123, 0.28);
    color: #00564e;
}

/* The frame header is a row: the type label, then the frame's own version
   badge and deploy dot — the deploy unit is the frame, so each carries its
   own version (the view shows none). */
.item.container .ctx-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.item.container .ctx-header .ctx-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item.container .ctx-header .ctx-ver {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    opacity: 0.9;
}

/* The deploy dot: what the runtime runs for this frame. */
.item.container .ctx-header .ctx-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 4px;
}

.item.container .ctx-header .ctx-dot.live {
    background: #2ecc71;
    box-shadow: 0 0 4px rgba(46, 204, 113, 0.8);
}

.item.container .ctx-header .ctx-dot.drift {
    background: #f39c12;
    box-shadow: 0 0 4px rgba(243, 156, 18, 0.7);
}

/* The deploy bar button: visible only while the selection is a frame. */
.item-bar .bar-btn.hidden {
    display: none;
}

.item-bar .bar-deploy {
    background: rgba(46, 204, 113, 0.25);
}

.content {
    position: absolute;
    top: 0;
    left: 0;
}

.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Projection decisions on read model field rows. */
.field-key {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}
.field-row .field-source {
    flex: 0 1 130px;
}

/* ---- Settings dropdown (issue 149: terminology mode) ---------------------- */

.settings-anchor {
    position: relative;
    display: none;
}
.settings-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    min-width: 180px;
    padding: 10px;
    background: var(--panel, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.settings-menu .field-label {
    margin-bottom: 6px;
}
.settings-option {
    display: block;
    width: 100%;
    padding: 10px 8px;
    margin-top: 4px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    background: var(--shell, transparent);
    color: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.settings-option.active {
    border-color: var(--accent, #4A90D9);
    color: var(--accent, #4A90D9);
    font-weight: 600;
}

/* ---- Workspace switcher (header) -------------------------------------------
   The active workspace's name + a dropdown of the user's workspaces.
   Switching is core, so the button shows on phones (name truncated). */

.workspace-anchor {
    position: relative;
}

.workspace-btn {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    min-width: 200px;
    max-width: 260px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.ws-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    margin-top: 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.ws-row:hover {
    border-color: var(--border);
}

.ws-row.active {
    border-color: var(--blue);
    color: #fff;
    font-weight: 600;
}

.ws-row .ws-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws-row .ws-kind {
    font-size: 11px;
    color: var(--muted);
}

.ws-row .ws-check {
    color: var(--blue);
}

.ws-sep {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 6px 0;
}

/* ---- Workspace panel (members / ledger / create) --------------------------- */

.ws-note {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 12px;
}

.ws-note .badge {
    margin-right: 4px;
}

.member-row,
.ledger-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.member-row .name,
.ledger-row .ledger-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-row .meta,
.ledger-row .ledger-when {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 12px;
}

/* The picker's hidden file input (design import). */
.file-input {
    display: none;
}

/* ---- Header overflow menu (mobile) ------------------------------------------ */

.header-menu {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.header-menu-card {
    width: min(400px, calc(100vw - 32px));
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.header-menu-card h2 {
    font-size: 15px;
    margin-bottom: 8px;
}
.header-menu-card .btn {
    display: block;
    width: 100%;
    margin-top: 8px;
}
.header-menu-card .menu-line {
    font-size: 13px;
    color: var(--muted);
    margin: 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-menu-card .settings-option {
    width: auto;
    display: inline-block;
}

/* ---- Zoom cluster ------------------------------------------------------------
   Standalone pill: hidden on phones - the dock row carries the controls there
   (in-rail copy, below). On desktop the media block restores this as the
   original bottom-right pill. */
.zoom-cluster {
    position: absolute;
    right: 68px;
    bottom: calc(74px + var(--safe-bottom));
    z-index: 20;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.zoom-cluster button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zoom-cluster button:hover {
    background: rgba(255, 255, 255, 0.1);
}
.zoom-cluster .zoom-pct {
    min-width: 52px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

/* The same cluster merged into the dock row: flat inside the rail pill, so
   one pill carries tools + zoom on phones. (Desktop hides this copy and
   shows the standalone pill above.) */
.rail .zoom-cluster {
    position: static;
    right: auto;
    bottom: auto;
    display: flex;
    padding: 0 6px;
    margin-left: 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.rail .zoom-cluster button {
    width: 36px;
    height: 36px;
    font-size: 16px;
}

.rail .zoom-cluster .zoom-pct {
    min-width: 44px;
}

/* ---- Home page (the picker, repositioned as a real page) -------------------
   Work-first: where you left off, then the views and business areas as
   distinct collections. Same shape on phones and desktops. */

.home {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 24px 16px calc(24px + var(--safe-bottom));
}

.home-inner {
    width: 100%;
    max-width: 640px;
}

/* The continue card: the one thing to do next. */
.home-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    padding: 12px 16px 4px;
    margin-bottom: 12px;
}

.home-card-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
}

/* The first-time start: the page is the prompt. */
.home-hero h1 {
    font-size: 20px;
    margin-bottom: 4px;
}

.home-hero .muted {
    margin-bottom: 12px;
}

.home-section {
    margin-top: 24px;
}

.picker-section {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
}

.home-caption {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    margin: 0 0 8px;
}

/* The header views menu: go home, switch view, add a business area —
   what the old picker overlay did, in-canvas. */
.views-anchor {
    position: relative;
}

.views-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 40;
    min-width: 220px;
    max-width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.views-menu .picker-section {
    margin-top: 8px;
}

.views-menu .picker-row {
    padding: 8px;
    border-bottom: 0;
}

/* ============================================================================
   Desktop layout (>= 768px) — the original values, restored verbatim.
   ========================================================================== */

@media (min-width: 768px) {
    * {
        box-sizing: content-box;
    }

    .card {
        width: 380px;
    }

    .btn {
        padding: 8px 22px;
        font-size: 14px;
    }
    .btn.secondary,
    .btn.danger,
    .btn.deploy {
        padding: 6px 14px;
        font-size: 12px;
    }

    .input {
        padding: 6px 8px;
        font-size: 13px;
    }

    .header {
        padding: 0 16px;
        gap: 12px;
    }
    .badge-state,
    .badge-save,
    .deploy-status {
        display: inline;
    }
    .header-menu-btn,
    .header-menu {
        display: none;
    }
    .settings-anchor {
        display: block;
    }
    .workspace-btn {
        max-width: 180px;
    }
    .btn-freeze,
    .btn-designs,
    .btn-logout {
        display: inline-block;
    }

    /* Toolbar: the original left rail. */
    .rail {
        position: static;
        left: auto;
        bottom: auto;
        transform: none;
        flex: 0 0 48px;
        flex-direction: column;
        width: auto;
        max-width: none;
        height: auto;
        padding: 8px 0;
        gap: 6px;
        border: 0;
        border-right: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
        touch-action: auto;
        align-items: center;
    }
    .tool {
        width: 32px;
        height: 36px;
        border-radius: 6px;
    }
    .tool.tool-diff {
        margin-top: 12px;
        margin-left: 0;
    }
    /* The rail shows the original full 13 buttons on desktop: restore the
       seven the mobile pill hides, and hide the mobile-only dock extras. */
    .tool.tool-external,
    .tool.tool-actor,
    .tool.tool-hotspot,
    .tool.tool-flow,
    .tool.tool-diff,
    .tool.tool-deployments,
    .tool.tool-console {
        display: flex;
    }
    .tool.tool-more,
    .tool.tool-undo,
    .tool.tool-redo {
        display: none;
    }
    .rail .zoom-cluster {
        display: none;
    }
    .tools-sheet {
        display: none;
    }

    /* Inspector: the original side column. */
    .inspector {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        flex: 0 0 320px;
        width: auto;
        height: auto;
        padding: 16px;
        border: 0;
        border-left: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        z-index: auto;
    }
    .sheet-grabber {
        display: none;
    }
    .inspector-x {
        display: none;
    }
    .inspector.collapsed {
        flex: 0 0 32px;
        /* The mobile base zero-sizes the sheet; the desktop sliver must
           stretch to full height again (the base height:0 otherwise wins
           on specificity and clips the chevron into an 8px box). */
        height: auto;
        padding: 4px;
        /* The mobile base clips the zero-size sheet; the desktop sliver
           scrolls its (narrow) content like the original layout. */
        overflow: auto;
    }
    /* Selection without an explicit open: the full panel, exactly the
       original desktop behavior. Re-expands the zero-sized mobile base of
       .selected-only (same specificity, later in the file). */
    .inspector.selected-only {
        width: auto;
        height: auto;
        padding: 16px;
        border: 0;
        border-left: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
        overflow-y: auto;
    }
    /* The Some-arm chevron is a mobile-only FAB; the original desktop
       expanded panel had none. */
    .inspector .chevron-form {
        display: none;
    }
    .chevron {
        display: inline-block;
        position: static;
        right: auto;
        bottom: auto;
        width: 24px;
        height: 24px;
        margin: 4px auto;
        border-radius: 4px;
        z-index: auto;
    }
    /* No chevron FAB on desktop, so the cluster keeps the right edge. */
    .zoom-cluster {
        display: flex;
        right: 12px;
    }

    .field-del {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    .field-inv,
    .field-key {
        font-size: 10px;
    }
    .field-add .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .btn-delete {
        width: auto;
    }

    /* Overlays: the original widths. */
    .overlay {
        padding-top: 48px;
    }
    .overlay .panel {
        width: 560px;
        max-width: 90vw;
        max-height: 85%;
        border-radius: 10px;
        padding: 20px;
    }
    .picker-row {
        padding: 8px;
    }
    .picker-row .name {
        font-size: 13px;
    }
    .picker-row .btn {
        padding: 4px 10px;
    }
    .diff-card {
        width: 560px;
        max-width: 90vw;
        max-height: 80vh;
        border-radius: 10px;
        padding: 20px;
    }
    /* The drop group-move dialog gets a rounded, centered card on desktop. */
    .gm-card {
        width: 420px;
        max-width: 90vw;
        max-height: 80vh;
        border-radius: 10px;
        padding: 20px;
    }
    .diff-close {
        padding: 0;
    }
    .migration-card {
        width: 620px;
        max-width: 90vw;
        max-height: 80vh;
        border-radius: 10px;
        padding: 20px;
    }
    .deployments-card {
        width: 640px;
    }
    .deployment-row {
        padding: 6px 8px;
    }
    .console-card {
        width: 640px;
        max-height: 76vh;
    }
    .console-agg-title {
        padding: 6px 10px;
    }
    .console-instance {
        padding: 4px 8px;
        font-size: 12px;
    }
    .console-state {
        font-size: 11px;
        max-height: 200px;
    }
    .console-cmd .cmd-param {
        flex: none;
        width: 140px;
        min-width: 0;
    }
    .console-key-row .cmd-param {
        flex: none;
        width: 180px;
        min-width: 0;
    }

    .toast {
        bottom: 16px;
        max-width: none;
    }

    .issues-panel {
        left: 56px;
        right: auto;
        top: auto;
        bottom: 8px;
        width: 400px;
    }
    .issue-row {
        padding: 4px 10px;
    }

    /* Canvas handles back to desktop size (touch devices re-enlarge them in
       the (pointer: coarse) block below). */
    .resize-handle {
        right: -6px;
        bottom: -6px;
        width: 12px;
        height: 12px;
    }
    .edge-handle {
        width: 12px;
        height: 12px;
    }
    /* No contextual bar on desktop: the side panel is the inspector. */
    .item-bar {
        display: none;
    }
    .edge-handle.eh-left {
        left: -6px;
        top: calc(50% - 6px);
    }
    .edge-handle.eh-right {
        left: calc(100% - 6px);
        top: calc(50% - 6px);
    }
    .edge-handle.eh-top {
        left: calc(50% - 6px);
        top: -6px;
    }
    .edge-handle.eh-bottom {
        left: calc(50% - 6px);
        top: calc(100% - 6px);
    }

    .settings-option {
        padding: 6px 8px;
        font-size: 12px;
    }

    .zoom-cluster {
        bottom: 16px;
    }
}

/* Touch devices at any width (touch laptops, tablets): keep the canvas
   handles finger-sized. */
@media (pointer: coarse) {
    .resize-handle {
        right: -8px;
        bottom: -8px;
        width: 16px;
        height: 16px;
    }
    .edge-handle {
        width: 16px;
        height: 16px;
    }
    .edge-handle.eh-left {
        left: -8px;
        top: calc(50% - 8px);
    }
    .edge-handle.eh-right {
        left: calc(100% - 8px);
        top: calc(50% - 8px);
    }
    .edge-handle.eh-top {
        left: calc(50% - 8px);
        top: -8px;
    }
    .edge-handle.eh-bottom {
        left: calc(50% - 8px);
        top: calc(100% - 8px);
    }
}
