/* Constellation board builder — interface styles (the board itself is drawn in SVG). */
:root {
  --ui: #0b0c10; --panel: #13151b; --panel-2: #1a1d25; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
  --text: #eceef3; --text-2: #b4b9c4; --muted: #8a909b; --accent: #bd3f0b; --accent-2: #bde2f0; --danger: #ff6b5b;
  --r: 12px; --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bar-h: 60px; --panel-w: 340px;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; margin: 0; }
body { background: var(--ui); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 500 11px/1 ui-monospace, Menlo, Consolas, monospace; padding: 3px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--panel-2); color: var(--text-2); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb4aa; }
.btn.danger.solid { background: #c0392b; border-color: #c0392b; color: #fff; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); font-size: 16px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }

/* ── top bar ── */
.bar { position: fixed; inset: 0 0 auto 0; height: var(--bar-h); z-index: 30; display: flex; align-items: center; gap: 10px; padding: 0 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); background: color-mix(in srgb, var(--ui) 92%, transparent); border-bottom: 1px solid var(--line); }
.brand { font: 700 20px/1 var(--font); color: var(--text); text-decoration: none; letter-spacing: -.04em; padding: 6px 4px; }
.brand span { color: var(--accent); }
.titlewrap { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 80px; }
.title { flex: 0 1 280px; min-width: 60px; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; font-weight: 600; font-size: 15px; color: var(--text); text-overflow: ellipsis; }
.title:hover { border-color: var(--line-2); }
.title:focus { border-color: var(--accent); outline: none; background: var(--panel); }
.saved { font-size: 12px; color: var(--muted); white-space: nowrap; }
.saved::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #4caf7d; vertical-align: 1px; }
.saved[data-s="saving"]::before { background: #f2b84b; }
.saved[data-s="err"]::before { background: var(--danger); }
.modes { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); }
.modes button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); min-height: 30px; }
.modes button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.tools { display: flex; align-items: center; gap: 6px; }
.tools.right { margin-left: auto; }
body[data-mode="view"] .edit-only { display: none !important; }
body[data-mode="edit"] .view-only { display: none !important; }

/* ── stage ── */
.stage { position: fixed; inset: var(--bar-h) 0 0 0; overflow: hidden; touch-action: none; cursor: grab; background-color: #0e0f13; transition: right .25s ease; user-select: none; -webkit-user-select: none; }
body.panel-open .stage { right: var(--panel-w); }
.stage.panning { cursor: grabbing; }
.stage-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.node { cursor: pointer; }
body[data-mode="edit"] .node { cursor: grab; }
.stage.dragging-node, .stage.dragging-node .node { cursor: grabbing; }
.node .body { transition: filter .15s; }
.node:hover .body { filter: brightness(1.12); }
.stage[data-dark="0"] .node:hover .body { filter: brightness(.97); }
.node .badge { cursor: pointer; }
.node .badge:hover rect { stroke-width: 2; }
.selring { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 5 4; pointer-events: none; animation: ring-spin 18s linear infinite; }
.stage[data-dark="0"] .selring { stroke: #1a5fb4; }
.node.drop-target .body { filter: drop-shadow(0 0 10px var(--accent)) brightness(1.2); }
.edge, .link { pointer-events: none; }
.edge .hit, .link .hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.link.is-sel path:first-child, .edge.is-sel path:first-child { filter: drop-shadow(0 0 4px var(--accent-2)); }
.flow path:not(.hit) { animation: dash-flow 1.1s linear infinite; }
@keyframes dash-flow { to { stroke-dashoffset: -28; } }
@keyframes ring-spin { to { stroke-dashoffset: -90; } }
body.connecting .stage, body.connecting .node { cursor: crosshair; }
.stage.file-over { box-shadow: inset 0 0 0 3px var(--accent); }
.drop-hint { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.stage.file-over .drop-hint { opacity: 1; }

.banner { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 10px 30px -10px rgba(0,0,0,.6); font-weight: 600; font-size: 13px; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }

/* floating toolbar above the selected bubble */
.mini { position: absolute; z-index: 5; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 12px 30px -12px rgba(0,0,0,.7); }
.mini button { border: 0; background: transparent; min-width: 34px; height: 32px; padding: 0 9px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.mini button:hover { background: var(--panel-2); color: var(--text); }
.mini button.danger:hover { color: var(--danger); }
.mini button:disabled { opacity: .3; cursor: default; background: none; }
.inline { position: absolute; z-index: 7; height: 40px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--accent); background: var(--panel); color: var(--text); font-weight: 650; text-align: center; box-shadow: 0 12px 30px -10px rgba(0,0,0,.7); }
.inline:focus { outline: none; }

.hud { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 4; display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 14px; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); }
.hud-left { left: 14px; padding-left: 12px; font-size: 12px; color: var(--muted); gap: 10px; }
.hud-left kbd { margin: 0 2px; }
.hud-right { right: 14px; }
.hud .sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.hud-btn { border: 0; background: transparent; padding: 0 10px; height: 34px; border-radius: 9px; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.hud-btn:hover, .hud .icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ── side panel ── */
.panel { position: fixed; top: var(--bar-h); right: 0; bottom: 0; width: var(--panel-w); z-index: 20; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: flex-end; padding: 6px 8px 0; }
.panel-grip { display: none; }
.panel-scroll { overflow-y: auto; padding: 0 18px 28px; flex: 1; overscroll-behavior: contain; }
.ph { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 14px; }
.ph-dot { flex: none; width: 12px; height: 12px; margin-top: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.ph h2 { margin: 0; font-size: 19px; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
.ph .sub { margin: 4px 0 0; color: var(--text-2); }
.eyebrow { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.quick .btn { width: 100%; }
.sec { border-top: 1px solid var(--line); }
.sec > summary { list-style: none; cursor: pointer; padding: 14px 0; font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform .2s; font-size: 18px; line-height: 1; }
.sec[open] > summary::after { transform: rotate(90deg); }
.sec > summary small { color: var(--muted); font-weight: 500; }
.sec-b { padding: 0 0 16px; display: grid; gap: 10px; }
.lbl { font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 4px; }
.lbl small { color: var(--muted); font-weight: 500; }
.fld { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.fld input, .fld textarea, .sharebox input[type="password"], .sharebox input[type="text"], #pwin { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--ui); color: var(--text); font-weight: 500; font-size: 14px; }
.fld textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.fld input:focus, .fld textarea:focus, #pwin:focus, .sharebox input:focus { outline: none; border-color: var(--accent); }
.fld .short { width: 140px; }
.fld.range span { display: flex; justify-content: space-between; }
.fld.range output { color: var(--muted); font-weight: 500; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint.lead { margin-bottom: 12px; line-height: 1.6; }
.row2 { display: flex; flex-wrap: wrap; gap: 6px; }
.stack { display: grid; gap: 6px; }
.stack .btn { justify-content: space-between; }

.seg { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--ui); border: 1px solid var(--line); }
.seg button { flex: 1 1 auto; border: 0; background: transparent; padding: 6px 8px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); min-height: 32px; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.icons { display: flex; flex-wrap: wrap; gap: 3px; }
.icons button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--ui); font-size: 14px; }
.icons button:hover { border-color: var(--accent); }
.shapes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.shapes button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px 5px; border-radius: 9px; border: 1px solid var(--line); background: var(--ui); color: var(--text-2); font-size: 10.5px; font-weight: 600; }
.shapes button:hover { border-color: var(--line-2); color: var(--text); }
.shapes button.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--ui)); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw, .sw-custom, .sw-auto { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2); background: var(--c); padding: 0; }
.sw.on, .sw-auto.on { box-shadow: 0 0 0 2px var(--accent-2); }
.sw-auto { width: auto; padding: 0 10px; border-radius: 999px; background: var(--ui); font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.sw-custom { position: relative; display: grid; place-items: center; background: conic-gradient(#ff5d5d, #ffd25d, #6dff8f, #5dd2ff, #9c6dff, #ff5dd2, #ff5d5d); cursor: pointer; }
.sw-custom span { font-weight: 700; font-size: 14px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); pointer-events: none; }
.sw-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.presets button { display: grid; justify-items: center; gap: 0; padding: 4px 2px 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--ui); color: var(--text-2); font-size: 10.5px; font-weight: 600; }
.presets button:hover { border-color: var(--accent); color: var(--text); }
.presets svg { max-width: 100%; }
.toggles { display: grid; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--line-2); flex: none; transition: background-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #cfd3da; transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch small { color: var(--muted); }
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.themes button { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 10px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font-weight: 650; font-size: 12.5px; text-align: left; }
.themes button.on { box-shadow: 0 0 0 2px var(--accent); }
.themes .dots { display: inline-flex; gap: 3px; order: 2; }
.themes .dots i { width: 9px; height: 9px; border-radius: 50%; }
.drop-zone { display: grid; place-items: center; padding: 16px; border-radius: 12px; border: 1.5px dashed var(--line-2); color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; text-align: center; }
.drop-zone:hover { border-color: var(--accent); color: var(--text); }
.file-btn { cursor: pointer; }
.pic { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: start; }
.pic img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line-2); }
.pic .seg { margin: 6px 0 8px; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.files li { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; background: var(--ui); border: 1px solid var(--line); }
.ficon { flex: none; width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: #3a1d14; color: #ff9b7a; font-size: 10px; font-weight: 800; overflow: hidden; }
.ficon img { width: 100%; height: 100%; object-fit: cover; }
.fname { flex: 1; text-align: left; background: none; border: 0; padding: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.fname small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.fname:hover { color: var(--accent-2); }

/* view-mode details */
.details { display: grid; gap: 14px; padding-top: 4px; }
.details .ph { margin: 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.crumbs button { background: none; border: 0; padding: 0; color: var(--text-2); font-weight: 600; }
.crumbs button:hover { color: var(--accent-2); }
.hero-img { width: 100%; border-radius: 14px; border: 1px solid var(--line); max-height: 260px; object-fit: cover; }
.note { font-size: 14.5px; line-height: 1.65; color: var(--text); overflow-wrap: anywhere; }
.note a { color: var(--accent-2); }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gallery button { padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--ui); aspect-ratio: 4 / 3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.gallery button:hover img { transform: scale(1.04); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line-2); background: var(--ui); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.chips button:hover { color: var(--text); border-color: var(--accent); }

/* ── dialogs ── */
.dlg { border: 1px solid var(--line-2); border-radius: 18px; padding: 0; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 40px 100px -20px rgba(0,0,0,.7); }
.dlg::backdrop { background: rgba(5,6,9,.66); }
.dlg-in { padding: 22px 24px 22px; overflow-y: auto; max-height: calc(100vh - 42px); display: grid; gap: 12px; }
.dlg h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.dlg p { margin: 0; }
.dlg.small { width: min(420px, calc(100vw - 24px)); }
.dlg.wide { width: min(1100px, calc(100vw - 24px)); height: min(860px, calc(100vh - 40px)); }
.dlg.wide .dlg-in { padding: 0; height: 100%; max-height: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.err { color: #ffb4aa; font-weight: 600; font-size: 13px; margin: 0; }
.fineprint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.sharebox { display: grid; gap: 12px; padding: 14px; border-radius: 14px; background: var(--ui); border: 1px solid var(--line); }
.pw-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.tiny { font-size: 12px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.linkrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.linkrow textarea, .prev-link textarea { width: 100%; resize: none; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--ui); color: var(--accent-2); font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.prev-link summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.exp { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.exp-card { display: grid; gap: 4px; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--ui); }
.exp-card b { font-size: 14px; }
.exp-card span { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.exp-card:hover { border-color: var(--accent); }
.exp-card:disabled { opacity: .5; }
.exp-opts { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); }
.tpls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tpl { display: grid; gap: 4px; text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--ui); }
.tpl:hover { border-color: var(--accent); }
.tpl b { font-size: 14px; }
.tpl span:last-child { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.tpl-art { height: 64px; border-radius: 10px; margin-bottom: 4px; background-color: #0e0f13; background-repeat: no-repeat; }
.tpl-blank { background-image: radial-gradient(circle at 50% 50%, #bd3f0b 0 12px, transparent 13px); }
.tpl-portfolio { background-image: radial-gradient(circle at 50% 50%, #bd3f0b 0 11px, transparent 12px), radial-gradient(circle at 22% 30%, #bde2f0 0 6px, transparent 7px), radial-gradient(circle at 78% 30%, #f2b84b 0 6px, transparent 7px), radial-gradient(circle at 30% 78%, #7bd389 0 6px, transparent 7px), radial-gradient(circle at 72% 78%, #c49bff 0 6px, transparent 7px); }
.tpl-plan { background-color: #f6f3ec; background-image: linear-gradient(#bd3f0b,#bd3f0b), linear-gradient(#2f6f8f,#2f6f8f), linear-gradient(#c48a12,#c48a12), linear-gradient(#3f8a4e,#3f8a4e); background-size: 26px 10px, 40px 8px, 40px 8px, 40px 8px; background-position: 14% 50%, 60% 22%, 60% 50%, 60% 78%; }
.tpl-mood { background-color: #2a1622; background-image: radial-gradient(ellipse at 50% 50%, #ff8a5b 0 14px, transparent 15px), radial-gradient(circle at 20% 35%, #ffb38a 0 9px, transparent 10px), radial-gradient(circle at 80% 30%, #ff5d8f 0 8px, transparent 9px), radial-gradient(circle at 74% 76%, #c78bff 0 9px, transparent 10px); }
.blist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.blist li { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--ui); }
.blist li.cur { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.bopen { flex: 1; text-align: left; background: none; border: 0; padding: 6px 8px; display: grid; gap: 2px; }
.bopen small { color: var(--muted); font-size: 11.5px; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.keys td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; }
.lock-art { font-size: 34px; }
.dlg.lock form { display: grid; gap: 10px; }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-head strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head span { color: var(--muted); font-size: 12px; }
.viewer-body { flex: 1; display: grid; place-items: center; background: #08090c; min-height: 0; padding: 0; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body .hint { padding: 8px; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translate(-50%, 12px); z-index: 60; padding: 10px 16px; border-radius: 12px; background: #f3f4f6; color: #111; font-weight: 600; font-size: 13px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.6); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #ffdad5; color: #5c120a; }
.print-holder { display: none; }
.sm-only { display: none !important; }

/* ── phones & small windows ── */
@media (max-width: 900px) { .hide-sm { display: none; } .saved { display: none; } }
@media (max-width: 760px) {
  :root { --bar-h: 56px; }
  .bar { gap: 6px; padding: 0 8px; }
  .title { font-size: 14px; }
  .modes button { padding: 6px 9px; }
  .tools .btn { padding: 0 10px; }
  .brand { display: none; }
  body.panel-open .stage { right: 0; }
  .panel { top: auto; left: 0; width: auto; height: min(62vh, 560px); border-left: 0; border-top: 1px solid var(--line-2); border-radius: 18px 18px 0 0; box-shadow: 0 -20px 50px -10px rgba(0,0,0,.6); padding-bottom: env(safe-area-inset-bottom); }
  .panel-head { justify-content: space-between; padding: 8px 8px 0 14px; }
  .panel-grip { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 0 auto; transform: translateX(18px); }
  .hud-left { display: none; }
  .hud-right { left: 8px; right: 8px; justify-content: center; }
  body.panel-open .hud { display: none; }
  .pw-fields { grid-template-columns: 1fr; }
  .exp, .tpls { grid-template-columns: 1fr; }
  .mini button { padding: 0 7px; }
}
@media (max-width: 760px) {
  .sm-only { display: inline-grid !important; }
  .hud .sep.sm-only { display: block !important; }
  .tools.edit-only .icon-btn { display: none; }
}
@media (max-width: 560px) {
  .modes { padding: 0; border: 0; background: none; }
  .modes button[aria-pressed="true"] { display: none; }
  .modes button { border: 1px solid var(--line-2); min-height: 36px; padding: 0 10px; }
  .tools { gap: 4px; }
  .tools .btn { min-height: 36px; padding: 0 9px; }
  .tools .btn.ghost[data-cmd="export"] { display: none; }
  .hud-btn { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── printing: just the board ── */
@media print {
  @page { margin: 10mm; }
  body.printing > *:not(.print-holder) { display: none !important; }
  body.printing { overflow: visible; background: #fff; }
  body.printing .print-holder { display: block !important; }
  body.printing .print-holder svg { width: 100%; height: auto; max-height: 95vh; }
}

/* ───── Story maps: reader bar, types, relationships, Who's who ───── */
.reader { position: absolute; left: 70px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 14px; background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); max-width: calc(100% - 28px); }
.reader[hidden] { display: none; }
.reader .r-ic { color: var(--muted); font-size: 15px; }
.reader.shielded .r-ic { color: var(--accent); }
.r-lbl { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.r-lbl output { color: var(--text); }
.r-lbl input { width: 150px; accent-color: var(--accent); }
body.has-reader .hud-left > span { display: none; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kinds button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--ui); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.kinds button i { font-style: normal; opacity: .85; }
.kinds button:hover { color: var(--text); border-color: var(--accent); }
.kinds button.on { color: var(--text); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rels { display: flex; flex-wrap: wrap; gap: 6px; }
.rels button { border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.rels button.on { background: var(--c); color: #fff; }
.rel-chips button { border-color: var(--c); }
.rel-chips em { font-style: normal; color: var(--c); font-weight: 700; }
.dlg.who .dlg-in { width: min(520px, 92vw); }
.who-q { width: 100%; margin: 10px 0 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--ui); color: var(--text); font: inherit; }
.who-list { max-height: min(56vh, 520px); overflow: auto; display: grid; gap: 6px; }
.who-ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.who-ul button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.who-ul button:hover { background: var(--panel-2); }
.who-ul b { display: block; font-size: 14px; }
.who-ul small { display: block; color: var(--muted); font-size: 12px; }
.who-ul em { margin-left: auto; font-style: normal; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.who-ic { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--ui); }
.tpl-story { background-color: #f1e7d2; background-image: radial-gradient(circle at 50% 50%, #8c2f1b 0 11px, transparent 12px), radial-gradient(circle at 20% 28%, #2f5d62 0 6px, transparent 7px), radial-gradient(circle at 80% 28%, #b07d2b 0 6px, transparent 7px), radial-gradient(circle at 26% 78%, #4e6b3a 0 6px, transparent 7px), radial-gradient(circle at 76% 78%, #5b3f7a 0 6px, transparent 7px), linear-gradient(115deg, transparent 47%, #a2445f 47% 49%, transparent 49%); }
@media (max-width: 760px) { .reader { left: 14px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px); } .r-lbl input { width: 110px; } }
@media print { .reader { display: none !important; } }

/* ───── accounts ───── */
.acct .av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.signin { display: grid; gap: 10px; justify-items: stretch; }
.gbtn { min-height: 44px; display: flex; justify-content: center; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.pk-new { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pk-new summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pk-new[open] { display: grid; gap: 10px; }
.pk-new[open] summary { margin-bottom: 4px; }
.meter { height: 8px; border-radius: 99px; background: var(--ui); overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--accent); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent-2); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.acct-nudge { margin-top: 2px; }
@media (max-width: 1200px) { .tools.right .hide-sm { display: none; } }

/* ───── custom links ───── */
.custom-link { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--ui); }
.slugrow { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); overflow: hidden; }
.slugrow span { padding: 0 2px 0 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.slugrow input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; padding: 10px 12px 10px 0; outline: none; }
.slugrow:focus-within { border-color: var(--accent); }
.hint.good { color: #7bd389; } .hint.bad { color: var(--danger); }
.custom-link .linkrow { display: flex; gap: 6px; } .custom-link .linkrow input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: inherit; }
.ro-tag { display: inline-flex; align-items: center; gap: 8px; margin-left: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
body[data-readonly="1"] .modes, body[data-readonly="1"] .tools.edit-only, body[data-readonly="1"] [data-cmd="share"], body[data-readonly="1"] [data-cmd="new"], body[data-readonly="1"] [data-cmd="boards"], body[data-readonly="1"] #acct, body[data-readonly="1"] .saved { display: none !important; }
body[data-readonly="1"] .title { pointer-events: none; }

/* ───── simpler sign-in ───── */
.dlg.signin-dlg { width: min(380px, calc(100vw - 24px)); }
.signin-dlg .dlg-in { padding: 30px 28px 20px; gap: 18px; position: relative; text-align: center; }
.dlg-x { position: absolute; top: 12px; right: 12px; }
.si-head h2 { font-size: 22px; }
.si-head p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.signin-dlg .signin { gap: 10px; justify-items: center; }
/* sign-in buttons: same pill for Google and passkey */
.si-btn { position: relative; overflow: hidden; width: 100%; max-width: 300px; height: 46px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 22px; font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease; }
.si-btn:active { transform: scale(.98); }
.si-btn:disabled { opacity: .6; cursor: default; }
.si-btn svg, .si-btn span { position: relative; z-index: 1; }
.si-pk { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); }
.si-pk:hover { border-color: var(--accent); }
.si-google { background: #fff; color: #1f1f1f; border: 1px solid #fff; }
.si-google:hover { box-shadow: 0 6px 22px -8px rgba(255,255,255,.35); }
.si-new { margin: 0; font-size: 13px; color: var(--muted); }
.si-foot { margin: 4px 0 0; font-size: 12px; } .si-foot a { color: var(--muted); }
.si-new .linkbtn { color: var(--accent); font-weight: 700; }

/* ───── panel side (desktop): left by default ───── */
.side-pick { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.side-pick .seg { flex: 0 0 auto; }
@media (min-width: 761px) {
  body[data-side="left"] .panel { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); }
  body[data-side="left"] .stage { transition: none; }
  body[data-side="left"].panel-open .stage { right: 0; left: var(--panel-w); }
}

/* ───── app (PWA) ───── */
.app-dlg .dlg-in { padding: 30px 28px 24px; gap: 14px; position: relative; }
.app-head { text-align: center; display: grid; justify-items: center; gap: 4px; }
.app-head img { border-radius: 16px; box-shadow: 0 10px 30px -10px rgba(189,63,11,.5); margin-bottom: 6px; }
.app-head p { color: var(--muted); font-size: 14px; }
.app-lead { font-weight: 600; font-size: 14px; }
.app-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.app-steps li { counter-increment: s; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); }
.app-steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; }
.app-steps b { color: var(--text); }
.kbd-ic { display: inline-grid; place-items: center; vertical-align: middle; width: 26px; height: 26px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line-2); color: #4fa3ff; }
body[data-readonly="1"] .app-btn { display: none !important; }
/* inside the installed app: leave room for the phone's notch/status bar */
body.is-app .bar { padding-top: env(safe-area-inset-top); height: calc(var(--bar-h) + env(safe-area-inset-top)); }
body.is-app .stage { top: calc(var(--bar-h) + env(safe-area-inset-top)); }
@media (min-width: 761px) { body.is-app .panel { top: calc(var(--bar-h) + env(safe-area-inset-top)); } }

/* phones: New board and Download live inside ☰ My boards, which frees room in the header */
@media (max-width: 560px) { .tools.right [data-cmd="new"], .tools.right [data-cmd="export"] { display: none; } }
.app-steps li span { flex: 1; line-height: 1.45; }
@media (max-width: 560px) { .bar > .titlewrap { flex: 1 1 auto; min-width: 56px; overflow: hidden; } .bar > .modes, .bar > .tools { flex: none; } .title { text-overflow: ellipsis; } }
