/* canvas.css · the "Paper canvas" Playground: a warm paper desk with a dot grid, paper tiles in directory islands,
 * one dashed frame. House style: paper + ink, Geist / Geist Mono, 1px frames, dashed dividers, no shadows.
 * Geometry (tile slots, the frame, the strip, the rail, the card) is set by canvas.js from the viewport. */

:root {
  --bg: #fbf8f7; --surface: #fbf8f7; --surface-2: #f3f1ed; --surface-3: #ebe8e2;
  --border: #e6e3de; --border-2: #cac9c4; --border-3: #8a8783;
  --text: #15120d; --text-2: #3c3b3b; --text-3: #8a8783;
  --accent: #fbe566; --accent-soft: #fff6c2; --y-bg: #fff1a2; --y-bd: #e5c93a; --y-fg: #8a6414;
  --o: #ef8547; --pu: #8173e8; --b: #2f75ff; --g: #2e9e5b; --red: #e04a4d;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --ease-house: cubic-bezier(.2, .7, .2, 1);
  --ease-snap: cubic-bezier(.34, 1.45, .64, 1);
  --tile-h: 34px; --tile-h-compact: 26px;
  --dot: var(--border-2); --dot-o: .55;
  --pgd-footprint: var(--border-2);
  --pgd-toast-bg: var(--text); --pgd-toast-fg: var(--bg);
  /* tile tints (.desk.tint), the Studio prototype's token palette */
  --pu-bg: #f1effd; --pu-bd: #d3cdf7; --pu-fg: #5646c2;
  --o-bg: #fdf1e8; --o-bd: #f5d0b5; --o-fg: #a94e17;
  --g-bg: #eaf5ee; --g-bd: #bddfca; --g-fg: #1d7342;
  --b-bg: #ebf1ff; --b-bd: #c2d5fd; --b-fg: #1d51bd;
  --card: #fffdfc; --frame2: #b3b1ab;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15120d; --surface: #15120d; --surface-2: #1e1b17; --surface-3: #2a2621;
  --border: #2a2621; --border-2: #3c3b3b; --border-3: #8a8783;
  --text: #fbf8f7; --text-2: #cac9c4; --text-3: #8a8783;
  --accent-soft: rgba(251, 229, 102, .14); --y-bg: rgba(251, 229, 102, .16); --y-bd: rgba(251, 229, 102, .55); --y-fg: #f3df80;
  --dot-o: .4;
  --pu-bg: #221e3a; --pu-bd: #463e7c; --pu-fg: #b3a9f5;
  --o-bg: #2f1e12; --o-bd: #6a3f20; --o-fg: #f3a06d;
  --g-bg: #13271b; --g-bd: #25583a; --g-fg: #6fcb95;
  --b-bg: #13203d; --b-bd: #28457f; --b-fg: #8db1ff;
  --card: #1a1712; --frame2: #56524c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------------------------------------------------------------- the desk */
.desk { position: relative; width: 100vw; height: 100vh; min-width: 960px; min-height: 640px; overflow: hidden; }
.desk-dots {
  position: absolute; inset: 0; pointer-events: none; opacity: var(--dot-o);
  background: radial-gradient(circle, var(--dot) .8px, transparent 1.1px) 0 0 / 24px 24px;
}

/* island eyebrows (drag one: that directory's overview) */
.eyebrow {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 7px; height: 22px; padding: 0 6px 0 2px;
  font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
  background: transparent; border: 1px dashed transparent; border-radius: 4px; cursor: grab; user-select: none; touch-action: manipulation;
  transition: border-color .16s var(--ease-house), color .16s var(--ease-house), opacity .3s;
  white-space: nowrap;
}
.eyebrow[hidden] { display: none; }
.eyebrow .sq { width: 9px; height: 9px; border-radius: 1px; background: var(--hue, var(--text)); flex: none; }
.eyebrow:hover { border-color: var(--border-2); color: var(--text); }
.eyebrow.static { cursor: default; }
.eyebrow.static:hover { border-color: transparent; }
.eyebrow .lock { width: 10px; height: 10px; }
.island-hull {
  position: absolute; pointer-events: none; border: 1px dashed var(--border-2); border-radius: 12px; opacity: 0;
  transition: opacity .16s var(--ease-house);
}
.island-hull.on { opacity: 1; }

/* ---------------------------------------------------------------- tiles */
.tile {
  position: absolute; left: 0; top: 0; height: var(--tile-h); display: inline-flex; align-items: center; gap: 8px;
  padding: 0 10px 0 9px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface);
  font: 500 13px/1 var(--sans); color: var(--text); white-space: nowrap; cursor: grab; user-select: none;
  touch-action: manipulation; transform: rotate(var(--rot, 0deg));
  transition: transform .16s var(--ease-house), border-color .16s var(--ease-house), opacity .24s var(--ease-house), color .16s;
}
.tile .sq { width: 8px; height: 8px; border-radius: 1px; background: var(--hue); flex: none; }
.tile .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tile .gl { font: 500 11px/1 var(--mono); color: var(--text-3); flex: none; display: inline-flex; align-items: center; }
.tile .gl svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.tile .lock { width: 10px; height: 10px; color: var(--text-3); flex: none; }
.tile:hover { border-color: var(--text); transform: rotate(0deg) translateY(-1px); }
.tile:focus-visible { transform: rotate(0deg); }
.tile.private { border-style: dashed; border-color: var(--border-3); }
.tile.textonly .nm { color: var(--text-2); }
.tile.inuse { border-style: dashed; border-color: var(--border-2); background: transparent; }
.tile.inuse .nm, .tile.inuse .gl { color: var(--text-3); }
.tile.inuse .sq { opacity: .45; }
/* the dog-ear: "try this next" (a folded corner in the house yellow) */
.tile::after {
  content: ""; position: absolute; right: -1px; top: -1px; width: 9px; height: 9px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%); transform: scaleY(0); transform-origin: top; transition: transform .18s var(--ease-house);
  border-top-right-radius: 3px;
}
.tile.dog::after { transform: scaleY(1); }
.tile.dog { border-color: var(--text-2); }
/* working mode (and the side-column landing): compact tiles in the side columns */
.desk.is-working .tile, .desk.landing-cols .tile { height: var(--tile-h-compact); font-size: 12px; gap: 7px; padding: 0 8px; }
.desk.is-working .tile .gl, .desk.landing-cols .tile .gl { margin-left: auto; }
.desk.is-working .tile.long .gl, .desk.landing-cols .tile.long .gl { display: none; }
.desk.is-working .tile .sq, .desk.landing-cols .tile .sq { width: 7px; height: 7px; }
.desk.is-working .eyebrow, .desk.landing-cols .eyebrow { height: 20px; font-size: 10.5px; }
/* the side-column landing shows the stamp card from the start (nothing found yet) */
.desk.landing-cols.is-empty .game { visibility: visible; opacity: 1; }
.desk.landing-cols.is-empty .game.wait { visibility: hidden; opacity: 0; }   /* no room beside the right column: it arrives with the first drop */
.game-actions [hidden] { display: none; }

/* tinted tiles (.desk.tint): coloured by directory, as the Studio prototype colours its tokens */
.desk.tint .tile { --hbg: var(--card); --hbd: var(--frame2); --hfg: var(--text); background: var(--hbg); border-color: var(--hbd); color: var(--hfg); }
.desk.tint .tile[data-dir="investors"] { --hbg: var(--pu-bg); --hbd: var(--pu-bd); --hfg: var(--pu-fg); }
.desk.tint .tile[data-dir="startups"] { --hbg: var(--o-bg); --hbd: var(--o-bd); --hfg: var(--o-fg); }
.desk.tint .tile[data-dir="rounds"] { --hbg: var(--g-bg); --hbd: var(--g-bd); --hfg: var(--g-fg); }
.desk.tint .tile[data-dir="news"] { --hbg: var(--b-bg); --hbd: var(--b-bd); --hfg: var(--b-fg); }
.desk.tint .tile[data-dir="mine"] { --hfg: var(--text-2); border-style: dashed; }
.desk.tint .tile.hero { --hbg: var(--bg); --hbd: var(--text); --hfg: var(--text); font-weight: 600; }
.desk.tint .tile .gl { color: var(--hfg); opacity: .6; }
.desk.tint .tile.textonly .nm { color: var(--hfg); }
.desk.tint .tile:hover { border-color: var(--text); }
.desk.tint .tile.dog { border-color: var(--text-2); }
.desk.tint .tile.inuse { background: transparent; border-style: dashed; border-color: var(--border-2); }
.desk.tint .tile.inuse .nm, .desk.tint .tile.inuse .gl { color: var(--text-3); }
.tile .map { display: grid; grid-template-columns: 4px 4px; grid-template-rows: 4px 4px; gap: 1px; flex: none; }
.tile .map i { display: block; width: 4px; height: 4px; background: var(--surface-3); }
.tile .map i.on:nth-child(1) { background: var(--pu); }
.tile .map i.on:nth-child(2) { background: var(--o); }
.tile .map i.on:nth-child(3) { background: var(--g); }
.tile .map i.on:nth-child(4) { background: var(--b); }
.tile.inuse .map { opacity: .45; }

/* the quiet link to every chart the engine can draw */
.gallery-link {
  position: absolute; left: 0; top: 0; font: 400 11px/1.45 var(--sans); color: var(--text-3); text-decoration: none;
}
.gallery-link span { display: block; white-space: nowrap; }
.gallery-link:hover { color: var(--text); text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 3px; }
/* while carrying: the rest of the desk steps back */
html.pgd-dragging .tile:not(.pgd-footprint):not(.dog) { opacity: .7; }
html.pgd-dragging .eyebrow { opacity: .6; }

/* the ghost in the hand: scale + ink edge + soft yellow, never a shadow */
.pgd-ghost.tile, .pgd-ghost.chip, .pgd-ghost.eyebrow, .pgd-ghost.sugg, .pgd-ghost.fchip {
  border: 1px solid var(--text) !important; background: var(--accent-soft) !important; color: var(--text) !important;
  opacity: 1 !important;
}
.pgd-ghost.deck::before, .pgd-ghost.deck::after {
  content: ""; position: absolute; inset: -1px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); z-index: -1;
}
.pgd-ghost.deck::before { transform: translate(4px, 4px) rotate(3deg); }
.pgd-ghost.deck::after { transform: translate(8px, 8px) rotate(-3deg); }
.pgd-ghost .deck-n { font: 600 10px/1 var(--mono); margin-left: 4px; padding: 2px 4px; border-radius: 2px; background: var(--text); color: var(--bg); }
.pgd-ghost.pgd-ghost-refused { border-color: var(--red) !important; }
/* the ghost keeps its whole name (its box is fixed by the drag core; a subpixel overflow must not cut "Number of roun…") */
.pgd-ghost .nm { overflow: visible; text-overflow: clip; }
.pgd-ghost.pgd-removing { background: var(--surface-2) !important; color: var(--text-3) !important; border-style: dashed !important; }
.pgd-ghost.pgd-removing::before { content: "Release to remove"; position: absolute; left: 0; top: -20px; font: 500 10.5px/1 var(--mono); color: var(--text-2); white-space: nowrap; }

/* ---------------------------------------------------------------- the frame */
.frame { position: absolute; left: 0; top: 0; width: 640px; height: 400px; border-radius: 12px; }
.frame-dash { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.frame-dash rect {
  width: calc(100% - 1.5px); height: calc(100% - 1.5px); fill: var(--accent-soft); fill-opacity: calc(var(--wake, 0) * .4);
  stroke: var(--border-3); stroke-width: 1.5; stroke-dasharray: 8 6;
  transition: stroke .12s linear, stroke-width .12s linear;
}
.desk.is-empty .frame:hover .frame-dash rect { animation: march 1.6s linear infinite; }
.frame.near .frame-dash rect { stroke: var(--text); animation: march .6s linear infinite; }
.frame.pgd-over .frame-dash rect { stroke-width: 2; stroke-dasharray: none; stroke: var(--text); }
.frame.pgd-over-refused .frame-dash rect { stroke: var(--red); }
@keyframes march { to { stroke-dashoffset: -28; } }
.frame-line {
  position: absolute; left: 24px; right: 24px; top: 50%; margin: 0; transform: translateY(-50%); text-align: center;
  font: 500 15px/1.35 var(--sans); letter-spacing: -.01em; color: var(--text-2); pointer-events: none; transition: opacity .12s linear;
}
.frame-line b { font-weight: 600; color: var(--text); }
.frame-line .cap { display: block; margin-top: 6px; font: 500 11.5px/1.35 var(--mono); color: var(--text-3); letter-spacing: 0; }
.preview-host { position: absolute; inset: 20px 20px 64px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-house); }
.frame.previewing .preview-host { opacity: .55; }
.frame.previewing .frame-line { top: auto; bottom: 18px; transform: none; }

/* card mode (after the first drop) */
.frame-card { position: absolute; inset: 0; display: flex; flex-direction: column; opacity: 0; visibility: hidden; border-radius: 12px; }
.desk.is-working .frame { background: var(--surface); }
.desk.is-working .frame::before { content: ""; position: absolute; inset: 0; border: 1px solid var(--border-2); border-radius: 12px; pointer-events: none; transition: border-color .16s; }
.desk.is-working .frame.clamp::before { border: 2px solid var(--text); }
.desk.is-working .frame-dash, .desk.is-working .frame-line, .desk.is-working .preview-host { display: none; }
.desk.is-working .frame-card { opacity: 1; visibility: visible; transition: opacity .24s var(--ease-house) .18s; }
.fhead { flex: none; display: flex; align-items: flex-start; gap: 16px; padding: 28px 22px 0; min-height: 84px; }
.fhead-main { flex: 1; min-width: 0; }
/* a long title or counting note takes a second line rather than losing its meaning to an ellipsis */
.ftitle {
  margin: 0; font: 600 20px/1.2 var(--sans); letter-spacing: -.02em; color: var(--text); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.fnote { margin-top: 6px; font: 400 11.5px/1.4 var(--mono); color: var(--text-3); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; min-height: 16px; }
.fnote .cnote { min-width: 0; overflow: hidden; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fnote .act { flex: none; }
.fnote .act { all: unset; cursor: pointer; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-2); }
.fnote .act:hover { color: var(--text); text-decoration-color: var(--text); }
.fnote .act:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.fnote .limit { color: var(--text-2); }
.fhead-side { flex: none; display: flex; align-items: center; gap: 8px; padding-top: 3px; }
.best-tag {
  font: 600 10px/1 var(--mono); letter-spacing: .06em; padding: 4px 6px 3px; border-radius: 2px;
  background: var(--accent); color: #15120d; border: 1px solid var(--y-bd); cursor: help; transition: opacity .2s;
}
.best-tag.faded { opacity: 0; pointer-events: none; }
.best-tag.priv { display: inline-flex; align-items: center; gap: 4px; background: transparent; color: var(--text-2); border: 1px dashed var(--border-3); }
.best-tag.priv[hidden] { display: none; }
.best-tag.priv .lock { display: inline-flex; }
.icon-btn {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-2); background: transparent; cursor: pointer;
  font: 600 10.5px/1 var(--mono); color: var(--text-2); display: inline-grid; place-items: center; padding: 0;
}
.icon-btn:hover { border-color: var(--text); color: var(--text); }
#infoBtn { font: italic 600 11px/1 Georgia, 'Times New Roman', serif; }
.plot { position: relative; flex: 1; min-height: 0; margin: 10px 22px 0; }
.plot-host { position: absolute; inset: 0; transition: opacity .2s var(--ease-house); }
.plot.previewing .plot-host { opacity: .55; }
.plot-cap {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); max-width: 90%; padding: 5px 9px; border-radius: 2px;
  background: var(--text); color: var(--bg); font: 500 11px/1.3 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transition: opacity .12s linear; z-index: 3;
}
.plot.previewing .plot-cap, .plot.dropping .plot-cap { opacity: 1; }

/* drop zones over the chart while carrying (Add = the plot, Split = the right band) */
.zone {
  position: absolute; z-index: 2; border: 1px dashed var(--border-3); border-radius: 8px; opacity: 0; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12px; transition: opacity .14s var(--ease-house), background .14s, border-color .14s;
}
.zone-add { left: 0; top: 0; bottom: 0; right: 108px; }
.zone-split { top: 0; bottom: 0; right: 0; width: 96px; align-items: center; padding: 12px 0; }
.zone-split .zone-tag { writing-mode: vertical-rl; transform: rotate(180deg); max-width: none; max-height: 100%; padding: 8px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-tag {
  font: 500 11.5px/1.35 var(--mono); color: var(--text); background: var(--surface); border: 1px solid var(--border-2);
  padding: 5px 8px; border-radius: 2px; text-align: center; max-width: 100%;
}
.zone-tag .best { display: inline-block; margin-left: 6px; padding: 1px 4px; border-radius: 2px; background: var(--accent); color: #15120d; font-size: 9.5px; letter-spacing: .05em; }
.zone-tag .why { display: block; color: var(--text-3); margin-top: 2px; }
.zone-tag b { font-weight: 600; }
.desk.carrying .zone { opacity: 1; }
.desk.carrying .plot-host { opacity: .35; }
.desk.carrying .plot.previewing .plot-host { opacity: .6; }
.zone.pgd-over { border-style: solid; border-color: var(--text); background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.zone.pgd-over-refused { border-color: var(--red); }
.zone.off { background: repeating-linear-gradient(45deg, transparent 0 5px, color-mix(in srgb, var(--border-2) 45%, transparent) 5px 6px); }
.desk.carrying-placed .zone-add { opacity: 0; }

/* suggestions under the chart (✦, dashed; from the engine) */
.suggest { flex: none; display: flex; align-items: center; gap: 8px; padding: 0 22px; height: 34px; overflow: hidden; }
.suggest:empty { height: 8px; }
.sugg {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border: 1px dashed var(--border-3); border-radius: 4px;
  background: var(--surface); font: 500 11.5px/1 var(--mono); color: var(--text-2); cursor: grab; white-space: nowrap; touch-action: manipulation;
  transition: border-color .16s, color .16s;
}
.sugg:hover { border-color: var(--text); color: var(--text); }
.suggest .lead { font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-right: 2px; }

/* the dial row (the chart's parameters; one click each, hover previews) */
.dials { flex: none; display: flex; align-items: center; gap: 16px; height: 58px; padding: 0 22px; border-top: 1px dashed var(--border-2); overflow: hidden; }
.dial { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.dial-l { font: 500 9.5px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); white-space: nowrap; flex: none; padding-left: 3px; }
.seg { display: inline-flex; align-items: center; padding: 2px; gap: 1px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.seg button {
  border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 4px 7px; font: 500 11.5px/1 var(--sans);
  color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.seg button.off { color: var(--text-3); opacity: .55; cursor: not-allowed; text-decoration: line-through; text-decoration-color: var(--border-2); }
.seg button.more { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.dials .spacer { flex: 1; }
.dials .more-dials { flex: none; white-space: nowrap; }

/* ---------------------------------------------------------------- chips on the frame's top edge */
.chiprow { position: absolute; left: 0; top: 0; height: 30px; display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.chiprow > * { pointer-events: auto; }
.desk.is-empty .chiprow { visibility: hidden; }
.chip {
  position: relative; height: 30px; display: inline-flex; align-items: center; gap: 7px; padding: 0 4px 0 9px; flex: 0 1 auto; min-width: 92px; max-width: 240px;
  border: 1px solid var(--text); border-radius: 4px; background: var(--surface); font: 500 12.5px/1 var(--sans); color: var(--text);
  cursor: grab; user-select: none; touch-action: manipulation; transition: border-color .16s, transform .16s var(--ease-house);
}
.chip .sq { width: 8px; height: 8px; border-radius: 1px; background: var(--hue); flex: none; }
.chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip .role {
  flex: none; font: 600 9.5px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; padding: 4px 5px 3px; border-radius: 2px;
  background: var(--surface-3); color: var(--text-2); border: 0; cursor: pointer;
}
.chip .role:hover { background: var(--text); color: var(--bg); }
/* the × shows on hover / focus (drag-out, Backspace and the menu also remove): four chips keep readable names */
.chip .x { flex: none; width: 18px; height: 18px; display: none; place-items: center; border-radius: 3px; color: var(--text-3); cursor: pointer; font: 400 14px/1 var(--sans); border: 0; background: transparent; padding: 0; }
.chip:hover .x, .chip:focus-within .x { display: grid; }
.chip .x:hover { color: var(--text); background: var(--surface-2); }
.chip .lock { flex: none; display: inline-flex; color: var(--text-3); }
.chip.private { border-style: dashed; }
.chip.ghost {
  border: 1px dashed var(--border-3); color: var(--text-2); font: 500 11.5px/1 var(--mono); padding: 0 9px; background: var(--surface); cursor: pointer;
  flex: 0 3 auto; min-width: 64px; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; gap: 5px;
}
/* four chips and a ghost on a narrow frame: a tighter chip so the names still read ("Capital raised", not "Capita…") */
.chiprow.crowded { gap: 6px; }
.chiprow.crowded .chip { gap: 5px; padding: 0 3px 0 7px; font-size: 12px; }
.chiprow.crowded .chip .role { font-size: 9px; padding: 3px 4px 2px; }
.chiprow.crowded .chip.ghost { font-size: 11px; padding: 0 7px; }
.chip.ghost:hover { border-color: var(--text); color: var(--text); }
.chip.pulse { animation: pulse .28s var(--ease-house) 2; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.chip.pgd-over { border-style: dashed; background: var(--accent-soft); }
.chip.swap-hint::after {
  content: attr(data-swap); position: absolute; left: 0; bottom: calc(100% + 6px); padding: 4px 7px; border-radius: 2px; white-space: nowrap;
  background: var(--text); color: var(--bg); font: 500 10.5px/1.2 var(--mono);
}
.slot {
  height: 30px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px dashed var(--border-2); border-radius: 4px;
  background: var(--surface); font: 500 11px/1 var(--mono); color: var(--text-3); white-space: nowrap; flex: none;
}
.slot.pgd-over { border-color: var(--text); color: var(--text); background: var(--accent-soft); }

/* ---------------------------------------------------------------- the filter rail */
.rail {
  position: absolute; left: 0; top: 0; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 8px;
  border: 1px dashed var(--border-3); background: var(--surface); opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity .16s var(--ease-house), transform .16s var(--ease-house), visibility 0s linear .16s; z-index: 4;
}
.desk.is-working.carrying .rail, .desk.is-working.has-filters .rail { opacity: 1; visibility: visible; transform: none; transition: opacity .16s var(--ease-house), transform .16s var(--ease-house); }
.desk.has-filters .rail { border-style: solid; border-color: var(--border-2); }
.desk.carrying-placed.has-filters .rail, .desk.carrying .rail.pgd-over { border-style: solid; border-color: var(--text); background: var(--accent-soft); }
.rail.pgd-over-refused { border-color: var(--red) !important; }
.rail-hint { display: inline-flex; align-items: center; gap: 7px; font: 500 12px/1 var(--mono); color: var(--text-2); white-space: nowrap; flex: none; }
.rail-hint svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; }
.desk.has-filters:not(.carrying) .rail-hint span { display: none; }
.rail-chips { display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 6px 8px; min-width: 0; overflow: hidden; max-height: 58px; }
.rail.two { align-items: center; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 3px 0 8px; border-radius: 2px; border: 1px solid var(--border-2);
  background: var(--surface); font: 500 11.5px/1 var(--mono); color: var(--text); cursor: pointer; white-space: nowrap; max-width: 300px; touch-action: manipulation;
}
.fchip .sq { width: 8px; height: 8px; border-radius: 1px; background: var(--hue, var(--text)); flex: none; }
.fchip .nm { overflow: hidden; text-overflow: ellipsis; }
.fchip .x { width: 18px; height: 18px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font: 400 14px/1 var(--sans); padding: 0; border-radius: 2px; }
.fchip .x:hover { color: var(--text); background: var(--surface-2); }
.fchip.pending { border-style: dashed; color: var(--text-2); }
.fchip.tip { border-style: dashed; }
.fchip.private { border-style: dashed; border-color: var(--border-3); }
.fchip .lock { flex: none; display: inline-flex; color: var(--text-3); }

/* ---------------------------------------------------------------- the view strip (the grammar's tray) */
.strip { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 10px; transition: opacity .16s; }
.desk.is-empty .strip { visibility: hidden; opacity: 0; }
.desk.is-working .strip, .desk.is-working .game, .desk.is-working .chiprow { animation: fadeUp .36s var(--ease-house) .22s backwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
.desk.carrying .strip { opacity: .3; }
.desk.carrying:not(.has-filters) .strip { opacity: 0; }   /* the rail slides in over the strip while carrying */
.strip-head {
  position: absolute; left: 0; top: -18px; font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); white-space: nowrap;
}
.cell { position: relative; flex: none; display: flex; flex-direction: column; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.cell .th {
  position: relative; border: 1px solid var(--border-2); border-radius: 6px; background: var(--surface); overflow: hidden;
  transition: border-color .16s, transform .16s var(--ease-house);
}
.cell:hover .th { border-color: var(--text-2); transform: translateY(-1px); }
.cell.on .th { border-color: var(--text); box-shadow: none; outline: 1px solid var(--text); outline-offset: -2px; }
.cell .lb {
  font: 500 11px/1.2 var(--sans); color: var(--text-2); overflow: hidden; white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: break-word; hyphens: auto;
}
.cell.on .lb { color: var(--text); }
.cell .tg { position: absolute; left: 5px; top: 5px; z-index: 1; font: 600 8.5px/1 var(--mono); letter-spacing: .05em; padding: 2px 3px; border-radius: 2px; background: var(--accent); color: #15120d; }
.cell .th .pgr { pointer-events: none; }
.cell .th .ph { position: absolute; inset: 0; display: grid; place-items: center; font: 500 10.5px/1.25 var(--mono); color: var(--text-2); text-align: center; padding: 6px 4px; }
.cell.fun .th { border-style: dashed; }
.cell.fun .card { position: absolute; left: 19%; top: 19%; width: 62%; height: 62%; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); overflow: hidden; transition: transform .2s var(--ease-snap); }
.cell.fun .card.c3 { transform: rotate(-9deg) translate(-8px, 2px); }
.cell.fun .card.c2 { transform: rotate(7deg) translate(8px, 1px); }
.cell.fun .card.c1 { border-color: var(--text-2); }
.cell.fun:hover .card.c3 { transform: rotate(-16deg) translate(-16px, 2px); }
.cell.fun:hover .card.c2 { transform: rotate(13deg) translate(16px, 0); }
.cell.fun .n { position: absolute; right: 5px; top: 5px; font: 600 9px/1 var(--mono); padding: 2px 4px; border-radius: 2px; background: var(--text); color: var(--bg); }
.cell.fun .lb { font: 500 11px/1.2 var(--sans); color: var(--text); }
.cell.more .th, .cell.table .th { border-style: dashed; }
.cell.more .ph i { display: block; font-style: normal; color: var(--text-3); font-size: 9.5px; margin-top: 3px; }
.cell.table .ph svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.2; }

/* the fun fan: three tilted paper cards */
.fan { position: absolute; z-index: 30; display: flex; gap: 14px; padding: 14px; pointer-events: auto; }
.pop.fan { max-width: none; border: 0; background: transparent; padding: 6px; }
.fan .fcard {
  position: relative; width: 168px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--text); border-radius: 6px;
  background: var(--surface); cursor: pointer; transform: rotate(var(--r)); transition: transform .2s var(--ease-snap);
}
.fan .fcard:hover, .fan .fcard:focus-visible { transform: rotate(0deg) translateY(-4px); }
.fan .fcard .th { height: 92px; position: relative; }
.fan .fcard .lb { font: 500 11px/1.25 var(--mono); color: var(--text); }
.fan .fcard .q { font: 400 11px/1.3 var(--sans); color: var(--text-3); }

/* More ways: every other valid view by family, then the ones not possible here */
.more-sheet {
  position: absolute; z-index: 20; background: var(--surface); border: 1px solid var(--text); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}
.more-sheet[hidden] { display: none; }
.ms-head { flex: none; display: flex; align-items: baseline; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px dashed var(--border-2); }
.ms-head h2 { margin: 0; font: 600 15px/1.2 var(--sans); letter-spacing: -.01em; }
.ms-head .sub { font: 400 11.5px/1.3 var(--mono); color: var(--text-3); }
.ms-head .close { margin-left: auto; }
.ms-body { flex: 1; overflow: auto; padding: 6px 20px 18px; }
.ms-fam { padding-top: 14px; }
.ms-fam h3 { margin: 0 0 8px; display: flex; gap: 10px; align-items: baseline; font: 600 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.ms-fam h3 span { font: 400 11.5px/1 var(--sans); letter-spacing: 0; text-transform: none; color: var(--text-3); }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.ms-grid .cell .th { height: 78px; }
.ms-np { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.ms-np div { font: 400 11.5px/1.35 var(--mono); color: var(--text-3); padding: 4px 0; border-bottom: 1px dashed var(--border); }
.ms-np b { color: var(--text-2); font-weight: 500; display: block; }

/* ---------------------------------------------------------------- the stamp card + deal */
.game { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; gap: 8px; }
.desk.is-empty .game { visibility: hidden; opacity: 0; }
.game-actions { display: flex; gap: 14px; justify-content: flex-end; }
.link-btn {
  all: unset; display: inline-flex; align-items: center; gap: 6px; font: 500 11.5px/1 var(--mono); color: var(--text-2); cursor: pointer;
  padding: 3px 0; border-bottom: 1px solid transparent;
}
.link-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.1; }
.link-btn svg circle { fill: currentColor; stroke: none; }
.link-btn:hover { color: var(--text); border-bottom-color: var(--text); }
.link-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.stamp-card {
  all: unset; box-sizing: border-box; display: block; width: 100%; padding: 10px 12px 12px; border: 1px solid var(--border-2); border-radius: 3px;
  background: var(--surface); cursor: pointer; transform: rotate(-1.2deg); transition: transform .2s var(--ease-house), border-color .16s;
}
.stamp-card:hover { transform: rotate(0deg); border-color: var(--text-2); }
.stamp-card:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.sc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; padding-bottom: 6px; border-bottom: 1px solid var(--text); }
.sc-head b { font: 600 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.sc-head span { font: 500 11px/1 var(--mono); color: var(--text-2); }
.sc-grid { display: flex; flex-wrap: wrap; gap: 3px 6px; align-content: flex-start; }
.sc-fam { display: flex; flex-wrap: wrap; gap: 3px 2px; align-items: center; }
.sc-tag { flex: none; width: 14px; margin-right: 2px; font: 600 7.5px/8px var(--mono); letter-spacing: .02em; color: var(--text-3); }
.sc-cap { display: block; margin-top: 7px; font: 500 9.5px/1.2 var(--mono); letter-spacing: .03em; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box { width: 8px; height: 8px; border: 1px solid var(--border-2); border-radius: 1px; flex: none; position: relative; background: var(--surface); }
.box.on { border-color: var(--text); background: var(--text); transform: rotate(-8deg); }
.stamp-card .box:hover { outline: 1px solid var(--text); outline-offset: 1px; }
.cb-item .box { width: 11px; height: 11px; }
.stamp {
  position: absolute; z-index: 40; pointer-events: none; padding: 5px 8px 4px; border: 1.5px solid var(--text); border-radius: 2px; background: var(--surface);
  font: 600 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text); transform: rotate(-4deg); white-space: nowrap;
}

/* the card turned over: recipe hints */
.card-back {
  position: absolute; z-index: 25; background: var(--surface); border: 1px solid var(--text); border-radius: 4px; overflow: hidden;
  display: flex; flex-direction: column; transform-origin: 100% 100%;
  background-image: repeating-linear-gradient(to bottom, transparent 0 21px, color-mix(in srgb, var(--border) 80%, transparent) 21px 22px);
  background-position: 0 50px;
}
.card-back[hidden] { display: none; }
.card-back.flip-in { animation: flipIn .36s var(--ease-house); }
@keyframes flipIn { from { transform: perspective(900px) rotateY(-80deg); opacity: .2; } to { transform: none; opacity: 1; } }
.cb-head { flex: none; display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--text); }
.cb-head b { font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.cb-head span { font: 400 11.5px/1 var(--mono); color: var(--text-3); }
.cb-head .close { margin-left: auto; }
.cb-body { flex: 1; overflow: auto; padding: 4px 16px 14px; }
.cb-fam { margin-top: 10px; font: 600 9.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cb-item { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; font: 400 12px/1.35 var(--sans); color: var(--text-2); }
.cb-item .box { transform: none; top: 2px; }
.cb-item b { font-weight: 600; color: var(--text); white-space: nowrap; }
.cb-item button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-2); }
.cb-item button:hover { text-decoration-color: var(--text); color: var(--text); }
.cb-item i { font-style: normal; color: var(--text-3); font-family: var(--mono); font-size: 11px; }

/* ---------------------------------------------------------------- popovers (house .sf-pop: paper, 1px frame, no shadow) */
.pop {
  position: fixed; z-index: 60; min-width: 200px; max-width: 320px; padding: 6px; background: var(--surface); border: 1px solid var(--text); border-radius: 8px;
  font: 400 12.5px/1.35 var(--sans); color: var(--text);
}
.pop h4 { margin: 4px 8px 6px; font: 600 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.pop .sep { height: 0; border-top: 1px dashed var(--border-2); margin: 6px 4px; }
.pop .it {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 4px; cursor: pointer;
}
.pop .it:hover, .pop .it:focus-visible { background: var(--surface-2); }
.pop .it[aria-checked="true"]::after { content: "✓"; margin-left: auto; font: 600 11px/1 var(--mono); }
.pop .it.off { color: var(--text-3); cursor: not-allowed; }
.pop .it.off:hover { background: transparent; }
.pop .it .rs { display: block; font: 400 10.5px/1.3 var(--mono); color: var(--text-3); }
.pop .it .v { margin-left: auto; font: 500 11px/1 var(--mono); color: var(--text-3); }
.pop .it.link { font-weight: 600; }
.pop .note { padding: 4px 8px 6px; font: 400 11px/1.4 var(--mono); color: var(--text-3); }
.pop .it-input { padding: 4px 6px 6px; }
.pop .it-input input { width: 100%; height: 30px; padding: 0 9px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); color: var(--text); font: 400 12.5px/1 var(--sans); }
.pop .it-input input:focus { outline: none; border-color: var(--text); }
.pop.wide { max-width: 360px; width: 340px; }
.pop .notes-list { margin: 0; padding: 4px 8px 6px 22px; font: 400 11.5px/1.45 var(--mono); color: var(--text-2); }
.pop .notes-list li + li { margin-top: 4px; }
/* mark popover */
.pop.mark { min-width: 220px; }
.pop.mark .hd { padding: 6px 8px 4px; font: 600 12.5px/1.3 var(--sans); }
.pop.mark .hd span { display: block; font: 400 11px/1.3 var(--mono); color: var(--text-3); }
/* filter picker */
.picker { width: 300px; max-width: 300px; padding: 10px; }
.picker .pk-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.picker .pk-h b { font: 600 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker input[type="search"], .picker input[type="text"] {
  width: 100%; height: 30px; padding: 0 9px; border: 1px solid var(--border-2); border-radius: 4px; background: var(--surface); color: var(--text);
  font: 400 12.5px/1 var(--sans); margin-bottom: 6px;
}
.picker input:focus { outline: none; border-color: var(--text); }
.pk-list { max-height: 232px; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.pk-opt { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 4px; position: relative;
  background: linear-gradient(to right, color-mix(in srgb, var(--surface-3) 75%, transparent) var(--p, 0%), transparent var(--p, 0%)) no-repeat 0 100% / 100% 3px; }
.pk-opt:hover { background-color: var(--surface-2); }
.pk-opt input { margin: 0; accent-color: var(--text); }
.pk-opt .ol { all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12.5px/1.2 var(--sans); }
.pk-opt .ol:focus-visible { outline: 2px solid var(--text); }
.pk-opt .on { font: 500 11px/1 var(--mono); color: var(--text-3); }
.pk-f { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-2); font: 400 11px/1.3 var(--mono); color: var(--text-3); }
.btn {
  all: unset; box-sizing: border-box; display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 4px; cursor: pointer;
  font: 600 12px/1 var(--sans); background: var(--accent); color: #15120d; border: 1px solid var(--y-bd);
}
.btn:hover { filter: brightness(1.03); }
.btn.ghosty { background: transparent; color: var(--text-2); border-color: var(--border-2); font-weight: 500; }
.pk-seg { flex: none; }
.pk-seg button { padding: 3px 8px; font-size: 11.5px; }

/* the contact sheet (a cluster on the empty frame) and cluster quick picks */
.frame.sheet-mode .dials, .frame.sheet-mode .suggest { display: none; }
.sheet-host { position: absolute; inset: 0 0 12px; z-index: 2; background: var(--surface); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr 1fr; gap: 12px 14px; }
.sheet-host[hidden] { display: none; }
.sheet-host .sh-h { grid-column: 1 / -1; font: 500 11px/1.3 var(--mono); color: var(--text-3); }
.sheet-host .sh-h b { color: var(--text); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-right: 8px; }
.scard { all: unset; box-sizing: border-box; position: relative; display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 12px 8px; cursor: pointer; transition: border-color .16s, transform .16s var(--ease-house); }
.scard:hover, .scard:focus-visible { border-color: var(--text); transform: translateY(-1px); }
.scard .st { font: 600 12.5px/1.25 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard .sn { font: 400 10.5px/1.3 var(--mono); color: var(--text-3); margin-bottom: 4px; }
.scard .sp { position: relative; flex: 1; min-height: 0; pointer-events: none; }

/* ---------------------------------------------------------------- tooltip (reasons, the BEST why) */
.cv-tip {
  position: fixed; z-index: 80; max-width: 280px; padding: 6px 9px; border-radius: 2px; background: var(--text); color: var(--bg);
  font: 500 11px/1.4 var(--mono); pointer-events: none;
}
.cv-tip[hidden] { display: none; }

/* ---------------------------------------------------------------- reduced motion: fades only */
@media (prefers-reduced-motion: reduce) {
  .tile, .chip, .cell .th, .stamp-card, .fan .fcard, .scard, .zone, .rail, .plot-host, .frame-card, .cell.fun .card, .tile::after { transition-duration: .12s !important; transition-delay: 0s !important; }
  .cell.fun:hover .card.c3 { transform: rotate(-9deg) translate(-8px, 2px); }
  .cell.fun:hover .card.c2 { transform: rotate(7deg) translate(8px, 1px); }
  .tile:hover, .stamp-card:hover, .cell:hover .th, .fan .fcard:hover, .scard:hover { transform: rotate(var(--rot, 0deg)); }
  .frame-dash rect { animation: none !important; }
  .chip.pulse { animation: none; }
  .desk.is-working .strip, .desk.is-working .game, .desk.is-working .chiprow { animation: fadeIn .12s linear; }
  .card-back.flip-in { animation: fadeIn .12s linear; }
}
html[data-motion="reduce"] .tile, html[data-motion="reduce"] .chip, html[data-motion="reduce"] .cell .th, html[data-motion="reduce"] .stamp-card,
html[data-motion="reduce"] .fan .fcard, html[data-motion="reduce"] .scard, html[data-motion="reduce"] .zone, html[data-motion="reduce"] .rail,
html[data-motion="reduce"] .plot-host, html[data-motion="reduce"] .frame-card, html[data-motion="reduce"] .cell.fun .card,
html[data-motion="reduce"] .tile::after { transition-duration: .12s !important; transition-delay: 0s !important; }
html[data-motion="reduce"] .cell.fun:hover .card.c3 { transform: rotate(-9deg) translate(-8px, 2px); }
html[data-motion="reduce"] .cell.fun:hover .card.c2 { transform: rotate(7deg) translate(8px, 1px); }
html[data-motion="reduce"] .frame-dash rect { animation: none !important; }
html[data-motion="reduce"] .desk.is-working .strip, html[data-motion="reduce"] .desk.is-working .game, html[data-motion="reduce"] .desk.is-working .chiprow { animation: fadeIn .12s linear; }
html[data-motion="reduce"] .chip.pulse { animation: none; }
html[data-motion="reduce"] .card-back.flip-in { animation: fadeIn .12s linear; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------------------------------------------------------------- a narrow screen */
/* Two tile columns and a frame need room: below that the page says so instead of squeezing. */
.narrow-note { display: none; }
@media (max-width: 939px) {
  .desk { display: none; }
  .narrow-note {
    display: flex; flex-direction: column; gap: 8px; justify-content: center; min-height: 100vh; padding: 32px 24px;
    max-width: 440px; margin: 0 auto; font: 400 14px/1.5 var(--sans); color: var(--text-2);
  }
  .narrow-note b { font: 600 17px/1.3 var(--sans); color: var(--text); letter-spacing: -.01em; }
}
