:root {
    color-scheme: dark;
    --bg: #0b1118;
    --panel: #111a24;
    --panel-2: #162230;
    --panel-3: #1a2938;
    --border: rgba(255, 255, 255, 0.09);
    --text: #f4f7fb;
    --muted: #91a0b2;
    --accent: #bd43dc;
    --accent-2: #7d5cff;
    --success: #43ca91;
    --warning: #f0b65b;
    --danger: #ec6c78;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background:
        radial-gradient(circle at 80% 0%, rgba(125, 92, 255, 0.11), transparent 32rem),
        radial-gradient(circle at 0% 100%, rgba(189, 67, 220, 0.08), transparent 30rem),
        var(--bg);
    color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -0.025em; }
.eyebrow {
    margin: 0 0 .35rem;
    color: var(--accent);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .16em;
}
.muted { color: var(--muted); line-height: 1.55; }
.error-text { color: var(--danger); margin: 0; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}
.login-card {
    width: min(100%, 430px);
    padding: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: rgba(17, 26, 36, .94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 1.6rem;
    border-radius: 17px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-size: 1.4rem;
    font-weight: 900;
}
.stack { display: grid; gap: 1rem; }

label { display: grid; gap: .48rem; }
label > span { color: #c7d0db; font-size: .82rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .78rem .9rem;
    color: var(--text);
    background: #0c141d;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: rgba(189, 67, 220, .75);
    box-shadow: 0 0 0 3px rgba(189, 67, 220, .12);
}

.button, .icon-button, .tab, .map-list-item, .checkpoint-list-item, .checkpoint-node {
    border: 0;
    cursor: pointer;
}
.button {
    min-height: 42px;
    padding: .7rem 1rem;
    border-radius: 12px;
    font-weight: 800;
    transition: transform .14s, opacity .14s, background .14s;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { opacity: .5; cursor: wait; }
.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.button.ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--border); }
.button.danger { background: rgba(236, 108, 120, .13); color: #ff9aa4; }
.icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255,255,255,.07);
    font-size: 1.35rem;
    font-weight: 500;
}
.icon-button.small { width: 34px; height: 34px; font-size: 1.1rem; }

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: 88px minmax(0, 1fr);
}
.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 17, 24, .84);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 { margin: 0; font-size: 1.45rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.user-chip {
    padding: .55rem .8rem;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    color: #dbe3ec;
    font-size: .82rem;
    font-weight: 700;
}
.sidebar {
    padding: 1.4rem 1rem;
    border-right: 1px solid var(--border);
    background: rgba(14, 22, 31, .76);
    overflow: auto;
}
.sidebar-heading, .panel-heading, .workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.sidebar-heading { padding: 0 .35rem 1rem; }
.sidebar-heading h2, .panel-heading h3 { margin: 0; }
.map-list { display: grid; gap: .45rem; }
.map-list-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border-radius: 14px;
    text-align: left;
    background: transparent;
    transition: background .14s, border-color .14s;
    border: 1px solid transparent;
}
.map-list-item:hover { background: rgba(255,255,255,.045); }
.map-list-item.is-active {
    background: linear-gradient(135deg, rgba(189, 67, 220, .15), rgba(125, 92, 255, .1));
    border-color: rgba(189, 67, 220, .3);
}
.map-order {
    flex: 0 0 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255,255,255,.07);
    color: #d9e0e8;
    font-weight: 900;
}
.map-list-copy { min-width: 0; display: grid; gap: .18rem; }
.map-list-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-list-copy small { color: var(--muted); }
.sidebar-empty, .panel-empty { color: var(--muted); padding: 1rem; text-align: center; }

.workspace { padding: 1.6rem; overflow: auto; }
.workspace-header { margin-bottom: 1rem; }
.workspace-header h2 { margin: 0; font-size: 1.7rem; }
.workspace-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; }
.empty-state {
    min-height: calc(100vh - 150px);
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--muted);
}
.empty-state h2 { color: var(--text); margin-bottom: .5rem; }
.empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.25rem;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: rgba(189, 67, 220, .12);
    color: var(--accent);
    font-size: 2rem;
}
.card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17, 26, 36, .86);
    box-shadow: 0 16px 45px rgba(0,0,0,.18);
}
.tabs {
    display: flex;
    gap: .35rem;
    margin-bottom: 1rem;
    padding: .35rem;
    width: fit-content;
    border-radius: 14px;
    background: rgba(255,255,255,.045);
}
.tab {
    padding: .65rem .95rem;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
}
.tab.is-active { background: var(--panel-3); color: var(--text); }

.editor-grid {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) 320px;
    gap: 1rem;
    align-items: start;
}
.map-panel {
    max-height: calc(100vh - 210px);
    overflow: auto;
    padding: .75rem;
}
.map-canvas {
    position: relative;
    width: min(100%, 900px);
    margin: 0 auto;
    overflow: hidden;
    border-radius: 14px;
    background: #0b121a;
    isolation: isolate;
    user-select: none;
    touch-action: none;
}
.map-canvas.empty-map {
    border: 1px dashed rgba(255,255,255,.16);
    min-height: 900px;
}
.map-missing {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: .4rem;
    text-align: center;
    color: var(--muted);
    z-index: 1;
}
.map-missing strong { color: var(--text); }
.map-canvas > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 0;
}
.link-layer, .checkpoint-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.link-layer { z-index: 2; pointer-events: none; }
.link-layer line {
    stroke: rgba(255,255,255,.72);
    stroke-width: .55;
    stroke-linecap: round;
    stroke-dasharray: 1.6 1.2;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.45));
}
.checkpoint-layer { z-index: 3; pointer-events: none; }
.checkpoint-node {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #0b1118;
    background: #f6f9fd;
    font-size: .72rem;
    font-weight: 950;
    box-shadow: 0 5px 15px rgba(0,0,0,.42), 0 0 0 4px rgba(255,255,255,.18);
    pointer-events: auto;
    transition: transform .12s, opacity .12s;
}
.checkpoint-node:hover { transform: translate(-50%, -50%) scale(1.12); }
.checkpoint-node.is-dragging { transform: translate(-50%, -50%) scale(1.15); cursor: grabbing; }
.checkpoint-node.is-saving { opacity: .55; }
.checkpoint-node.type-bonus, .checkpoint-number.type-bonus { background: #f6bf56; }
.checkpoint-node.type-boss, .checkpoint-number.type-boss { background: #ef7984; }
.checkpoint-node.type-finale, .checkpoint-number.type-finale { background: linear-gradient(135deg, #f6bf56, #ef7984); }

.checkpoint-panel {
    position: sticky;
    top: 104px;
    max-height: calc(100vh - 210px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}
.panel-heading { padding: 1rem; border-bottom: 1px solid var(--border); }
.checkpoint-list { overflow: auto; padding: .55rem; }
.checkpoint-list-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .72rem;
    padding: .66rem;
    border-radius: 12px;
    background: transparent;
    text-align: left;
}
.checkpoint-list-item:hover { background: rgba(255,255,255,.045); }
.checkpoint-list-item > span:last-child { display: grid; gap: .15rem; }
.checkpoint-list-item small { color: var(--muted); }
.checkpoint-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #edf4fb;
    color: #101720;
    font-size: .75rem;
    font-weight: 950;
}

.preflight-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}
.preflight-toolbar label { width: min(280px, 100%); }
.summary-chip {
    padding: .65rem .85rem;
    border-radius: 999px;
    background: rgba(255,255,255,.055);
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}
.table-wrap { overflow: auto; }
.preflight-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.preflight-table th, .preflight-table td {
    padding: .85rem .9rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.preflight-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #111a24;
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.preflight-table tr:hover td { background: rgba(255,255,255,.024); }
.placeholder-cell { color: var(--muted); }
.loading-cell { text-align: center !important; color: var(--muted); padding: 2rem !important; }
.type-pill, .status-pill {
    display: inline-flex;
    padding: .35rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 850;
    background: rgba(255,255,255,.06);
}
.type-pill.type-bonus { color: #ffd177; background: rgba(246,191,86,.12); }
.type-pill.type-boss, .type-pill.type-finale { color: #ff9ca5; background: rgba(239,121,132,.12); }
.status-pill.status-approved, .status-pill.status-published { color: #7fe0b2; background: rgba(67,202,145,.12); }
.status-pill.status-draft, .status-pill.status-missing { color: #b9c5d2; }

.modal {
    width: min(620px, calc(100vw - 2rem));
    border: 0;
    padding: 0;
    border-radius: 22px;
    color: var(--text);
    background: transparent;
    box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(3,7,12,.72); backdrop-filter: blur(5px); }
.modal-card {
    display: grid;
    gap: 1.2rem;
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: #121c27;
}
.modal-card.compact { width: min(460px, 100%); }
.modal-card header, .modal-card footer, .split-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.modal-card header h2 { margin: 0; }
.modal-card footer { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: .65rem; }
.checkbox-row input { width: 18px; height: 18px; }
.split-footer > div { display: flex; gap: .6rem; }

.toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: min(520px, calc(100vw - 2rem));
    padding: .8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #1a2633;
    box-shadow: var(--shadow);
    font-weight: 800;
}
.toast[data-type="success"] { border-color: rgba(67,202,145,.45); }
.toast[data-type="warning"] { border-color: rgba(240,182,91,.45); }
.toast[data-type="error"] { border-color: rgba(236,108,120,.5); }

@media (max-width: 1050px) {
    .admin-shell { grid-template-columns: 220px minmax(0,1fr); }
    .editor-grid { grid-template-columns: 1fr; }
    .checkpoint-panel { position: static; max-height: 420px; }
}
@media (max-width: 760px) {
    .admin-shell { display: block; }
    .topbar { position: sticky; padding: 0 1rem; height: 76px; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .map-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .workspace { padding: 1rem; }
    .workspace-header, .preflight-toolbar { align-items: flex-start; flex-direction: column; }
    .workspace-actions { justify-content: flex-start; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .wide { grid-column: auto; }
    .user-chip { display: none; }
}

/* Phase 3: generator + detailed preflight */
.preflight-toolbar {
    display: flex;
    align-items: end;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: .75rem;
}
.preflight-toolbar > label { width: min(240px, 100%); }
.preflight-actions { margin-left: auto; display: flex; gap: .65rem; flex-wrap: wrap; }
.preflight-note {
    margin: 0 0 .8rem;
    color: var(--muted);
    font-size: .84rem;
}
.letters {
    margin: .35rem 0;
    color: #ecddff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 800;
    letter-spacing: .08em;
}
.full-words { display: flex; flex-wrap: wrap; gap: .28rem; }
.full-words .word-chip {
    display: inline-flex;
    padding: .18rem .38rem;
    border-radius: 999px;
    background: rgba(189, 67, 220, .11);
    color: #e8c9ef;
    font-size: .68rem;
    font-weight: 750;
}
.row-actions { display: grid; gap: .4rem; }
.button.small { min-height: 34px; padding: .45rem .62rem; font-size: .72rem; }
.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;
}

@media (max-width: 900px) {
    .preflight-toolbar { align-items: stretch; flex-direction: column; }
    .preflight-actions { margin-left: 0; }
}

/* Phase 4: publication */
.preflight-statuses {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
}
.publication-chip {
    border: 1px solid transparent;
}
.publication-chip.is-ready {
    color: #86e5b8;
    background: rgba(67, 202, 145, .11);
    border-color: rgba(67, 202, 145, .22);
}
.publication-chip.is-blocked {
    color: #c8a96b;
    background: rgba(240, 182, 91, .08);
    border-color: rgba(240, 182, 91, .16);
}
@media (max-width: 900px) {
    .preflight-statuses { width: 100%; }
}

/* Phase 6: generator profiles, connections and inline preflight */
.modal-wide .modal-card { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.modal-card fieldset { border: 1px solid var(--border, rgba(255,255,255,.12)); border-radius: 14px; padding: 16px; margin: 0 0 16px; }
.modal-card legend { padding: 0 8px; font-weight: 800; }
.generator-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.seed-profile-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.seed-profile { padding: 12px; border-radius: 12px; background: rgba(255,255,255,.045); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seed-profile strong { grid-column: 1 / -1; }
.seed-profile label { display: grid; gap: 5px; font-size: .82rem; }
.objective-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 14px; }
.objective-checks strong { width: 100%; }
.objective-checks label { display: inline-flex; align-items: center; gap: 6px; }
.dialog-columns { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 18px; }
.reward-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
.connection-add-grid { display: grid; gap: 9px; margin-top: 14px; }
.connection-list { display: grid; gap: 7px; max-height: 300px; overflow: auto; }
.connection-section-title { font-weight: 800; margin-bottom: 4px; }
.connection-row { display: grid; grid-template-columns: minmax(55px, .7fr) minmax(100px, 1.25fr) auto auto; gap: 6px; align-items: center; padding: 7px 8px; border-radius: 9px; background: rgba(255,255,255,.045); }
.connection-row.direction-in { opacity: .72; }
.mini-check { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: .78rem; }
.danger-text { color: #ff8c95 !important; }
.icon-button.tiny { width: 28px; height: 28px; min-width: 28px; }

.map-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.connection-banner { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 14px; margin-bottom: 10px; border-radius: 12px; background: rgba(255,196,80,.16); border: 1px solid rgba(255,196,80,.42); }
.map-canvas.is-connecting .checkpoint-node { cursor: crosshair; box-shadow: 0 0 0 3px rgba(255,196,80,.35); }
.checkpoint-node.is-start::after { content: 'S'; position: absolute; right: -7px; top: -8px; width: 18px; height: 18px; border-radius: 999px; display: grid; place-items: center; font-size: 10px; font-weight: 900; background: #fff; color: #12172b; }
.link-layer { overflow: visible; pointer-events: none; }
.checkpoint-link { stroke: rgba(255,255,255,.72); stroke-width: 8; fill: none; vector-effect: non-scaling-stroke; }
.checkpoint-link.link-bonus { stroke: #f5c75e; stroke-dasharray: 15 10; }
.checkpoint-link.link-return { stroke: #72c7ff; stroke-dasharray: 6 10; }
.checkpoint-link.is-visual-only { opacity: .42; stroke-dasharray: 4 12; }
.link-layer marker path { fill: rgba(255,255,255,.82); }
.panel-help { margin: 0 0 10px; font-size: .78rem; opacity: .68; }

.context-menu { position: fixed; z-index: 1000; min-width: 205px; padding: 6px; border-radius: 12px; background: #181d32; border: 1px solid rgba(255,255,255,.16); box-shadow: 0 18px 48px rgba(0,0,0,.45); }
.context-menu button { width: 100%; border: 0; border-radius: 8px; padding: 10px 11px; text-align: left; color: inherit; background: transparent; cursor: pointer; }
.context-menu button:hover { background: rgba(255,255,255,.08); }

.preflight-table-detailed td { vertical-align: top; }
.preflight-table tr.is-saving { opacity: .55; pointer-events: none; }
.preflight-table tr.is-saving td:first-child::after { content: ' gemmer…'; font-size: .7rem; opacity: .8; }
.low-confidence-row { background: rgba(255,196,80,.055); }
.full-words { display: flex; gap: 5px; flex-wrap: wrap; }
.word-chip, .tiny-pill { display: inline-flex; border-radius: 999px; padding: 2px 7px; background: rgba(255,255,255,.09); font-size: .72rem; }
.tiny-pill { margin-left: 5px; background: rgba(87,220,155,.16); color: #8af0bc; }
.distribution { opacity: .68; }
.mini-field { display: grid; gap: 4px; font-size: .72rem; opacity: .92; }
.mini-field input, .mini-field select { min-width: 72px; }
.preflight-reward { display: grid; grid-template-columns: repeat(2, minmax(75px, 1fr)); gap: 6px; min-width: 175px; }
.cell-meta { display: block; margin-top: 5px; opacity: .62; }
.row-actions { display: grid; gap: 6px; min-width: 90px; }
.confidence { display: inline-flex; min-width: 48px; justify-content: center; padding: 5px 8px; border-radius: 999px; font-weight: 800; }
.confidence.good { background: rgba(87,220,155,.16); color: #8af0bc; }
.confidence.medium { background: rgba(255,196,80,.16); color: #ffd985; }
.confidence.low { background: rgba(255,102,117,.16); color: #ff9aa4; }
.status-pill.missing { background: rgba(255,255,255,.08); }

@media (max-width: 980px) {
    .generator-grid, .seed-profile-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
    .dialog-columns { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
    .generator-grid, .seed-profile-grid, .reward-grid { grid-template-columns: 1fr; }
    .map-tools, .connection-banner { align-items: stretch; flex-direction: column; }
}

/* Phase 7: stable dialogs, drag-to-pan map and board-first preflight */
.modal.modal-wide {
    width: min(1180px, calc(100vw - 24px));
    max-width: none;
    overflow: visible;
}
.modal-wide .modal-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.checkpoint-modal-card,
.objective-modal-card {
    max-height: calc(100vh - 24px);
    overflow: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0;
    padding: 0;
}
.checkpoint-modal-card > header,
.checkpoint-modal-card > footer,
.objective-modal-card > header,
.objective-modal-card > footer {
    position: relative;
    z-index: 2;
    padding: 18px 20px;
    background: #121c27;
}
.checkpoint-modal-card > header,
.objective-modal-card > header { border-bottom: 1px solid var(--border); }
.checkpoint-modal-card > footer,
.objective-modal-card > footer { border-top: 1px solid var(--border); }
.checkpoint-modal-card .dialog-columns {
    min-height: 0;
    overflow: auto;
    padding: 18px 20px 6px;
    scrollbar-gutter: stable;
}
.dialog-columns > section,
.dialog-columns > aside,
.form-grid > *,
.connection-row > * { min-width: 0; }
.connection-row select { min-width: 0; }
.context-menu-separator { height: 1px; margin: 5px 4px; background: var(--border); }

.map-panel { cursor: grab; overscroll-behavior: contain; scrollbar-gutter: stable; }
.map-panel.is-panning { cursor: grabbing; user-select: none; }
.map-panel.is-panning .map-canvas { cursor: grabbing; }
.map-canvas { cursor: grab; }
.map-canvas .checkpoint-node { cursor: grab; }
.map-canvas .checkpoint-node.is-dragging { cursor: grabbing; }

.preflight-table-wrap {
    max-height: calc(100vh - 255px);
    overflow: auto;
    scrollbar-gutter: stable both-edges;
}
.preflight-table-detailed {
    min-width: 1540px;
    table-layout: fixed;
}
.preflight-table-detailed col.col-number { width: 58px; }
.preflight-table-detailed col.col-type { width: 130px; }
.preflight-table-detailed col.col-rounds { width: 610px; }
.preflight-table-detailed col.col-time { width: 92px; }
.preflight-table-detailed col.col-reward { width: 220px; }
.preflight-table-detailed col.col-confidence { width: 105px; }
.preflight-table-detailed col.col-status { width: 110px; }
.preflight-table-detailed col.col-actions { width: 105px; }
.preflight-table-detailed thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #121c27;
}
.preflight-table-detailed th,
.preflight-table-detailed td {
    min-width: 0;
    padding: 10px;
    overflow-wrap: anywhere;
}
.preflight-table-detailed td:first-child,
.preflight-table-detailed th:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    background: #121c27;
}
.preflight-table-detailed thead th:first-child { z-index: 7; }
.preflight-table-detailed input,
.preflight-table-detailed select { min-width: 0; }
.board-stack-all { display: grid; gap: 9px; }
.preflight-board-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.028);
}
.preflight-board-card > header {
    grid-column: 1 / -1;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.preflight-board-card > header strong { min-width: 0; font-size: .88rem; }
.preflight-board-card > header span { flex: 0 0 auto; color: var(--muted); font-size: .7rem; }
.preflight-board-card .letters { grid-column: 1; margin: 0; }
.board-metrics {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.board-metrics span {
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.065);
    color: #cbd5df;
    font-size: .68rem;
}
.preflight-board-card .full-words,
.preflight-board-card .distribution,
.preflight-board-card .board-objective-summary,
.preflight-board-card .candidate-suggestions { grid-column: 1 / -1; }
.board-objective-summary { display: flex; flex-wrap: wrap; gap: 5px; }
.objective-summary-chip {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(189,67,220,.13);
    color: #edd2f5;
    font-size: .72rem;
    font-weight: 750;
}
.candidate-suggestions summary { cursor: pointer; color: var(--muted); font-size: .72rem; }
.candidate-suggestions > div { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.candidate-suggestions span { font-size: .68rem; color: #b9c5d2; }
.edit-objectives-button { grid-column: 2; grid-row: 2; align-self: start; white-space: nowrap; }
.preflight-reward { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
.row-actions { min-width: 0; }

.objective-modal { width: min(860px, calc(100vw - 24px)); }
.objective-modal-card { width: 100%; }
.objective-board-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.018);
}
.objective-board-summary > * {
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    font-size: .76rem;
}
.objective-wizard {
    min-height: 0;
    overflow: auto;
    padding: 18px 20px;
    scrollbar-gutter: stable;
}
.objective-wizard-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.objective-wizard-heading p { margin: 4px 0 0; }
.objective-wizard-rows { display: grid; gap: 10px; }
.objective-wizard-row {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr) 30px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.028);
}
.wizard-objective-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
}
.wizard-objective-inputs > small { align-self: center; color: var(--muted); }
.objective-suggestions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.objective-suggestions > div { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.suggestion-button {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
    color: #dbe3ec;
    background: rgba(255,255,255,.04);
    cursor: pointer;
}
.suggestion-button:hover { background: rgba(189,67,220,.12); border-color: rgba(189,67,220,.35); }

@media (max-width: 900px) {
    .modal.modal-wide { width: calc(100vw - 12px); }
    .checkpoint-modal-card .dialog-columns { grid-template-columns: 1fr; }
    .objective-wizard-row { grid-template-columns: 1fr 1fr 30px; }
}
@media (max-width: 620px) {
    .checkpoint-modal-card > header,
    .checkpoint-modal-card > footer,
    .objective-modal-card > header,
    .objective-modal-card > footer,
    .checkpoint-modal-card .dialog-columns,
    .objective-wizard,
    .objective-board-summary { padding-left: 12px; padding-right: 12px; }
    .objective-wizard-heading { flex-direction: column; }
    .objective-wizard-row { grid-template-columns: 1fr 30px; }
    .wizard-type-field, .wizard-objective-inputs { grid-column: 1; }
    .remove-objective-button { grid-column: 2; grid-row: 1; }
    .wizard-objective-inputs { grid-template-columns: 1fr; }
}

/* Phase 8: simpler graph semantics */
.field-help {
    margin: -4px 0 10px 30px;
    color: var(--muted);
    font-size: .83rem;
    line-height: 1.35;
}
#connectionStatus.has-warning {
    color: #ffd37a;
    font-weight: 700;
}
.connection-row {
    grid-template-columns: minmax(74px, .72fr) minmax(128px, 1.35fr) auto;
}
.connection-row.direction-in {
    grid-template-columns: minmax(74px, .72fr) minmax(128px, 1.35fr) minmax(95px, auto);
}
.connection-endpoint { font-weight: 800; white-space: nowrap; }
.connection-readonly { color: var(--muted); font-size: .78rem; text-align: right; }
