/* ArchBoard — architecture canvas: palettes, board, SVG parts, floating toolbars. */
.view--canvas { display: flex; }

/* ---------- Devicon palettes ---------- */
.palette {
  flex: none; width: var(--palette-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  transition: width .24s var(--ease);
  overflow: hidden;
}
.palette { border-right: 1px solid var(--line); }
.palette__head { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 6px 0 14px; flex: none; }
.palette__title { font-weight: 600; white-space: nowrap; }
.palette__body { flex: 1; min-height: 0; display: flex; flex-direction: column; width: var(--palette-w); }
.palette__field { display: flex; align-items: center; gap: 6px; margin: 0 12px 10px; padding: 0 10px; height: 40px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-2); color: var(--ink-3); }
.palette__field:focus-within { border-color: var(--accent); }
.palette__field span { display: grid; }
.palette__search { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); }
.palette__search::placeholder { color: var(--ink-3); }
.palette__list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.pcat + .pcat { border-top: 1px solid var(--line); }
.pcat__head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 6px; width: 100%;
  min-height: 40px; padding: 0 6px 0 2px;
  background: var(--surface); border: 0; border-radius: 0;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-align: left;
}
.pcat__head:hover { color: var(--ink); }
.pcat__chev { display: grid; transition: transform .16s var(--ease); }
.pcat.is-open .pcat__chev { transform: rotate(90deg); }
.pcat__label { flex: 1; }
.pcat__count { color: var(--ink-3); font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.palette__list.is-searching .pcat__head { cursor: default; }
.palette__grid {
  display: none;
  grid-template-columns: repeat(4, 1fr); grid-auto-rows: 58px; gap: 4px;
  padding: 2px 0 10px;
}
.pcat.is-open .palette__grid { display: grid; }
.tile {
  display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--r-2); padding: 0;
  cursor: grab; position: relative;
}
.tile:hover { background: var(--hover); }
.tile:active { cursor: grabbing; background: var(--press); }
.tile img { width: 38px; height: 38px; object-fit: contain; pointer-events: none; }
.tile img:not([src]) { visibility: hidden; }
.tile__fallback { display: none; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.tile.is-missing img { display: none; }
.tile.is-missing .tile__fallback { display: block; }

.palette__note { padding: 18px 14px; color: var(--ink-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; line-height: 1.5; }
.palette__note-title { font-weight: 600; color: var(--ink); }
.palette__foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 40px; padding: 5px 8px 5px 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.palette__foot:empty { display: none; }

.palette.is-collapsed { width: 52px; }
.palette.is-collapsed .palette__body, .palette.is-collapsed .palette__title { display: none; }
.palette.is-collapsed .palette__head { padding: 0 6px; }

/* ---------- board ---------- */
.board { flex: 1; min-width: 0; position: relative; background: var(--canvas); overflow: hidden; }
.board__svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.board[data-tool="shape"] .board__svg, .board[data-tool="text"] .board__svg { cursor: crosshair; }
.board[data-tool="arrow"] .board__svg, .board[data-tool="arrow-curve"] .board__svg { cursor: crosshair; }
.board.is-panning .board__svg, .board.is-panning .board__svg * { cursor: grab !important; }
.board.is-grabbing .board__svg, .board.is-grabbing .board__svg * { cursor: grabbing !important; }

.grid-minor, .grid-major { fill: none; stroke-width: 1; }
.grid-minor { stroke: var(--grid-minor); }
.grid-major { stroke: var(--grid-major); }

/* nodes */
.node { cursor: move; }
.board[data-tool="arrow"] .node, .board[data-tool="arrow-curve"] .node { cursor: crosshair; }
.node__shape { fill: var(--canvas);   /* default: the board colour, so a shape reads as unfilled but still hides what is behind it */ stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; pointer-events: all; }
.node__detail { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.node__detail:is(circle) { fill: var(--ink); }
.node__plate { fill: transparent; pointer-events: all; }
.node__ink { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.node__inkhit { fill: none; stroke: transparent; stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke; }
.board[data-tool="pen"] .board__svg, .board[data-tool="eraser"] .board__svg,
.board[data-tool="pen"] .node, .board[data-tool="eraser"] .node { cursor: crosshair; }
.eraser-cursor { fill: color-mix(in srgb, var(--ink) 10%, transparent); stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.node__text { fill: var(--ink); font-family: var(--font-ui); pointer-events: none; }
.node__text--caption { fill: var(--ink-2); }
.node__missing { display: none; fill: var(--ink-3); font: 11px var(--font-ui); pointer-events: none; }
.node.is-missing .node__missing { display: block; }
.node.is-missing .node__plate { stroke: var(--line-2); stroke-dasharray: 4 3; }
.node.is-target .node__shape, .node.is-target .node__plate { stroke: var(--accent); stroke-width: 2.5; }

/* edges */
.edge { cursor: pointer; }
.edge__hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; }
.edge__line { fill: none; stroke: var(--ink); stroke-width: 1.5; pointer-events: none; }
.edge.is-selected .edge__line { stroke: var(--accent); stroke-width: 2; }
.edge__labelbg { fill: var(--canvas); }
.edge__label { fill: var(--ink); font: 12px var(--font-ui); }
.arrowhead { fill: var(--ink); }
.arrowhead--sel { fill: var(--accent); }

/* selection overlay */
.sel-box { fill: none; stroke: var(--accent); stroke-width: 1.25; vector-effect: non-scaling-stroke; pointer-events: none; }
.sel-stem { stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.handle { fill: var(--raised); stroke: var(--accent); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.handle[data-dir="nw"], .handle[data-dir="se"] { cursor: nwse-resize; }
.handle[data-dir="ne"], .handle[data-dir="sw"] { cursor: nesw-resize; }
.handle[data-dir="n"], .handle[data-dir="s"] { cursor: ns-resize; }
.handle[data-dir="e"], .handle[data-dir="w"] { cursor: ew-resize; }
.handle--rot { cursor: grab; }
.handle--bend { cursor: move; fill: var(--accent); }
.handle--link { cursor: crosshair; }
.handle--link circle { fill: var(--accent); }
.handle--link path { fill: none; stroke: var(--accent-ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.marquee { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.link-preview { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }

/* inline text editor, positioned over the node being edited */
.inline-editor {
  position: absolute; z-index: 3;
  margin: 0; padding: 4px 6px;
  text-align: center; line-height: 1.3; resize: none; overflow: hidden;
  background: var(--raised); color: var(--ink);
  border: 1.5px solid var(--accent); border-radius: var(--r-1); outline: none;
  min-width: 80px; min-height: 30px;
}

/* empty state */
.canvas-empty {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: min(400px, 70%); text-align: center; pointer-events: none;
  color: var(--ink-3); display: flex; flex-direction: column; gap: 6px; line-height: 1.5;
}
.canvas-empty__title { color: var(--ink-2); font-size: 18px; font-weight: 600; }

/* ---------- floating toolbars ---------- */
.rail, .dock, .selbar {
  position: absolute; z-index: 2;
  display: flex; align-items: center; gap: 4px; padding: 5px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--pop-shadow);
}
.rail { left: 14px; top: 14px; flex-direction: column; max-height: calc(100% - 100px); overflow-y: auto; scrollbar-width: none; }
.rail__sep { width: 26px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
.dock { bottom: 14px; }
.dock--left { left: 14px; }
.dock--right { right: 14px; }
.dock__sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.dock__zoom { min-width: 62px; height: 40px; padding: 0 6px; background: none; border: 0; border-radius: var(--r-2); font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 500; }
.dock__zoom:hover { background: var(--hover); color: var(--ink); }

.selbar { top: 14px; left: 50%; transform: translateX(-50%); gap: 0; padding: 5px 6px; max-width: calc(100% - 160px); overflow-x: auto; scrollbar-width: none; animation: bar-in .16s var(--ease); }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, -4px); } }
.bar__group { display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 42px; }
.bar__group + .bar__group { border-left: 1px solid var(--line); }
.bar__group:last-child { gap: 2px; padding-right: 3px; }
.penbar .bar__group:last-child { gap: 10px; padding-right: 12px; }
.bar__label { color: var(--ink-3); font-size: 14.5px; margin-right: 2px; }
.chip { height: 36px; padding: 0 13px; background: none; border: 0; border-radius: var(--r-2); color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.chip:hover { background: var(--hover); color: var(--ink); }
.chip.is-active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .chip.is-active, [data-theme="dark"] .iconbtn[aria-pressed="true"] { color: var(--accent); }

/* ---------- colour popover (opened from the top bar, js/chrome.js) ---------- */
.colorpop {
  position: absolute; z-index: 4; left: 82px; bottom: 72px;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--pop-shadow); animation: pop-in .14s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } }
.colorpop__title { font-weight: 600; color: var(--ink-2); font-size: 14.5px; }
.colorpop__grid { display: grid; grid-template-columns: repeat(5, 30px); gap: 10px; }
.colorpop__grid .swatch { width: 30px; height: 30px; }
.colorpop__default { --sw: #12352a; }
.colorpop__default::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1.5px solid var(--ink-2); }
.colorpop__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-2); font-size: 14.5px; }
.colorpop__custom { width: 52px; height: 32px; padding: 2px; background: var(--canvas); border: 1px solid var(--line-2); border-radius: var(--r-2); cursor: pointer; }

/* ---------- pen / eraser options bar ---------- */
.sizedot { display: inline-grid; place-items: center; min-width: 38px; padding: 0 8px; }
.sizedot span { width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.bar__hint { color: var(--ink-3); font-size: 14px; white-space: nowrap; }
.chip:disabled { opacity: .4; cursor: default; background: none; }
.penbar { flex-wrap: wrap; justify-content: center; overflow: visible; row-gap: 2px; }
.penbar .bar__group { border-left: 0; }
.penbar .bar__group + .bar__group { box-shadow: inset 1px 0 0 var(--line); }
