/* Hallmark · shape: app screen · genre: playful · theme: Werkstatt (deal 2/3, seed realtime-collaborative-flowchart-editor-f7c3·8f72bf11·2026-11-23·r0)
 * nav: top bar, files sidebar, style and activity side panel · signature: the ruled board with live cursors · states: loading, empty, error, full · werkstatt: putty
 * axes: mid/geometric-sans/cool · posture: full-palette · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E4 S4 R3 V4 · weakest: R, user-chosen element colours exceed the three primaries by request; chrome keeps the theme's palette */
@import url("./tokens.css");
@import url("./base.css");

:root {
  --bar-h: 56px; --files-w: 232px; --side-w: 272px; --ctl: 36px;
  --color-board: var(--color-paper-3); --color-grid: var(--color-rule);
}

html, body { height: 100%; }
body { display: grid; grid-template-rows: var(--bar-h) minmax(0, 1fr); overflow: clip; }
h2 { font-size: var(--text-section); text-transform: uppercase; }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: var(--ctl); padding: 0 var(--space-md);
  border: var(--rule-bar) solid var(--color-ink); border-radius: 0; background: transparent; color: var(--color-ink);
  font: 600 var(--text-sm)/1 var(--font-body); text-transform: uppercase; cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur-micro), color var(--dur-micro);
}
.btn:hover { background: var(--color-paper-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--color-ink); color: var(--color-paper); }
.btn--primary:hover { background: var(--color-ink-2); }
.btn[aria-expanded="true"] { background: var(--color-paper-2); }
input { color: inherit; }

/* top bar */
.bar {
  display: flex; align-items: center; gap: var(--space-md); padding-inline: var(--space-md);
  border-bottom: var(--rule-box) solid var(--color-ink); background: var(--color-paper); min-width: 0;
}
.wordmark { font: 700 var(--text-lg)/1 var(--font-display); text-transform: uppercase; letter-spacing: var(--tracking-display); }
.file-name {
  min-width: 0; width: 26ch; min-height: var(--ctl); padding: 0 var(--space-xs);
  border: var(--rule-bar) solid transparent; background: transparent; font-weight: 600;
  transition: border-color var(--dur-micro), background-color var(--dur-micro);
}
.file-name:hover { border-color: var(--color-rule); }
.file-name:focus-visible { border-color: var(--color-ink); background: var(--color-paper-3); outline-offset: 0; }
.file-name:disabled { color: var(--color-muted); background: var(--color-paper-2); cursor: not-allowed; border-color: transparent; }
.here { display: flex; gap: var(--space-2xs); margin-left: auto; }
.person {
  display: grid; place-items: center; width: 30px; height: 30px; border: var(--rule-bar) solid var(--color-ink);
  background: var(--who); color: var(--color-accent-ink); font: 600 var(--text-xs)/1 var(--font-body);
}
.person.is-me { outline: var(--rule-bar) solid var(--who); outline-offset: 2px; }
.status { font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; }
.status[data-state="bad"] { color: var(--color-accent-2-deep); font-weight: 600; }
.export { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + var(--space-2xs)); z-index: 20; min-width: 160px;
  display: grid; border: var(--rule-bar) solid var(--color-ink); background: var(--color-paper-3);
}
.menu button {
  min-height: 40px; padding: 0 var(--space-md); border: 0; border-bottom: var(--rule-hair) solid var(--color-rule);
  background: transparent; text-align: left; cursor: pointer; color: var(--color-ink);
}
.menu button:last-child { border-bottom: 0; }
.menu button:hover, .menu button:focus-visible { background: var(--color-paper-2); }
.you { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--color-muted); font-weight: 600; }
.you input {
  width: 14ch; min-height: var(--ctl); padding: 0 var(--space-xs); border: var(--rule-bar) solid var(--color-ink);
  background: var(--color-paper-3); color: var(--color-ink); font-weight: 600;
}
.you input:focus-visible { outline-offset: 0; }

/* layout */
.layout { display: grid; grid-template-columns: var(--files-w) minmax(0, 1fr) var(--side-w); min-height: 0; }
.files, .side { background: var(--color-paper); min-height: 0; overflow: auto; }
.files { border-right: var(--rule-box) solid var(--color-ink); }
.side { border-left: var(--rule-box) solid var(--color-ink); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); padding: var(--space-md); border-bottom: var(--rule-bar) solid var(--color-ink); }

/* files */
.file-list { list-style: none; margin: 0; padding: 0; }
.file { position: relative; display: flex; align-items: stretch; border-bottom: var(--rule-hair) solid var(--color-rule); }
.file-open {
  flex: 1; min-width: 0; display: grid; gap: var(--space-3xs); padding: var(--space-sm) var(--space-md);
  border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer;
  transition: background-color var(--dur-micro);
}
.file-open:hover { background: var(--color-paper-2); }
.file-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: var(--text-xs); color: var(--color-muted); display: flex; gap: var(--space-2xs); align-items: center; }
.file-meta .person { width: 20px; height: 20px; border-width: 1px; font-size: 0.625rem; }
.file.is-current .file-open { background: var(--color-accent); color: var(--color-accent-ink); }
.file.is-current .file-meta { color: var(--color-accent-ink); }
.file-del {
  border: 0; border-left: var(--rule-hair) solid var(--color-rule); background: transparent; color: var(--color-muted);
  padding: 0 var(--space-sm); font-size: var(--text-xs); font-weight: 600; cursor: pointer; opacity: 0;
  transition: opacity var(--dur-micro), background-color var(--dur-micro);
}
.file:hover .file-del, .file-del:focus-visible { opacity: 1; }
.file-del:hover { background: var(--color-accent-2-deep); color: var(--color-accent-ink); }
.empty { padding: var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }

/* stage */
.stage { position: relative; min-width: 0; min-height: 0; overflow: clip; background: var(--color-board); }
#board { width: 100%; height: 100%; touch-action: none; user-select: none; cursor: default; }
#board:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
#board.is-panning { cursor: grabbing; }
.grid-dot { fill: var(--color-grid); }
.node { cursor: move; }
.node text { font-family: var(--font-body); pointer-events: none; }
.edge { cursor: pointer; }
.edge text { font-family: var(--font-body); }
.port { fill: var(--color-paper-3); stroke: var(--color-accent); cursor: crosshair; }
.port:hover { fill: var(--color-accent); }
.handle { fill: var(--color-paper-3); stroke: var(--color-accent); }
.handle[data-handle="nw"], .handle[data-handle="se"] { cursor: nwse-resize; }
.handle[data-handle="ne"], .handle[data-handle="sw"] { cursor: nesw-resize; }
.sel-box { fill: none; stroke: var(--color-accent); pointer-events: none; }
.guide { stroke: var(--color-accent-2-deep); pointer-events: none; }
.marquee { fill: var(--color-accent); fill-opacity: .08; stroke: var(--color-accent); pointer-events: none; }
.temp-edge { stroke: var(--color-accent); fill: none; pointer-events: none; }
#cursors { pointer-events: none; }
#cursors text { font-family: var(--font-body); }

.tools, .zoom {
  position: absolute; display: flex; border: var(--rule-bar) solid var(--color-ink); background: var(--color-paper);
}
.tools { left: var(--space-md); top: var(--space-md); flex-direction: column; }
.zoom { left: var(--space-md); bottom: var(--space-md); }
.tools button, .zoom button {
  display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 var(--space-xs);
  border: 0; background: transparent; color: var(--color-ink); cursor: pointer; font-weight: 600;
  transition: background-color var(--dur-micro), color var(--dur-micro);
}
.tools button + button { border-top: var(--rule-hair) solid var(--color-rule); }
.zoom button + button { border-left: var(--rule-hair) solid var(--color-rule); }
.tools button:hover, .zoom button:hover { background: var(--color-paper-2); }
.tools button:active, .zoom button:active { background: var(--color-ink); color: var(--color-paper); }
.tools button[draggable="true"] { cursor: grab; }
.tools button:disabled { opacity: .35; cursor: not-allowed; background: transparent; color: var(--color-ink); }
.tools svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.tools-rule { height: var(--rule-bar); background: var(--color-ink); }
.zoom-level { min-width: 64px; font-size: var(--text-sm); }

.state {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 36ch; margin: 0;
  padding: var(--space-md) var(--space-lg); border: var(--rule-bar) solid var(--color-ink); background: var(--color-paper);
  text-align: center; pointer-events: none;
}
.state[data-kind="error"] { border-color: var(--color-accent-2-deep); }
.state[data-kind="loading"] { color: var(--color-muted); }
.editor {
  position: absolute; z-index: 5; margin: 0; padding: var(--space-2xs); resize: none; overflow: hidden;
  border: var(--rule-bar) solid var(--color-accent); border-radius: 0; background: transparent;
  font-family: var(--font-body); font-weight: 600; line-height: 1.3; text-align: center;
}
.editor:focus-visible { outline: 0; }

/* side panel */
.panel { padding: var(--space-md); border-bottom: var(--rule-bar) solid var(--color-ink); display: grid; gap: var(--space-sm); align-content: start; }
.panel--grow { flex: 1; min-height: 160px; overflow: auto; }
.field { display: grid; gap: var(--space-2xs); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--color-muted); }
.swatches { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.swatch {
  position: relative; width: 32px; height: 32px; padding: 0; border: var(--rule-bar) solid var(--color-ink); border-radius: 0;
  background: var(--sw); cursor: pointer; transition: transform var(--dur-micro);
}
.swatch:hover { transform: translateY(-1px); }
.swatch[aria-pressed="true"] { outline: var(--rule-box) solid var(--color-accent); outline-offset: 1px; }
.swatch--none { background: linear-gradient(135deg, transparent 45%, var(--color-accent-2-deep) 45% 55%, transparent 55%), var(--color-paper-3); }
.swatch--custom { display: grid; place-items: center; overflow: hidden; background: var(--color-paper-3); font-weight: 600; }
.swatch--custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.swatch--custom:focus-within { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.seg { display: flex; }
.seg button {
  min-width: 44px; min-height: var(--ctl); border: var(--rule-bar) solid var(--color-ink); background: transparent; color: var(--color-ink);
  font-weight: 600; cursor: pointer; transition: background-color var(--dur-micro);
}
.seg button + button { border-left: 0; }
.seg button:hover { background: var(--color-paper-2); }
.seg button[aria-pressed="true"] { background: var(--color-accent); color: var(--color-accent-ink); }
.activity { list-style: none; margin: 0; padding: 0; font-size: var(--text-sm); }
.activity li { padding: var(--space-xs) 0; border-bottom: var(--rule-hair) solid var(--color-rule); }
.activity .who { font-weight: 600; }
.activity .who::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--space-2xs); background: var(--who); }
.activity time { display: block; font-size: var(--text-xs); color: var(--color-muted); }
.activity .empty { padding: 0; border: 0; }
.keys p { font-size: var(--text-sm); color: var(--color-muted); }
.noscript { padding: var(--space-lg); }

.only-narrow { display: none; }
@media (max-width: 60rem) {
  .only-narrow { display: inline-flex; }
  .wordmark, .status, .you span { display: none; }
  .file-name { width: auto; flex: 1; }
  .here { margin-left: 0; }
  .you input { width: 10ch; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .files, .side { position: fixed; top: var(--bar-h); bottom: 0; z-index: 30; width: min(85vw, 300px); visibility: hidden; }
  .files { left: 0; } .side { right: 0; }
  body[data-panel="files"] .files, body[data-panel="side"] .side { visibility: visible; }
}
@media (max-width: 40rem) { .export .btn { padding: 0 var(--space-xs); } .here { display: none; } }
