:root {
  --bg:#14171c; --panel:#1d222a; --panel2:#262c35; --text:#e6e8eb; --muted:#9aa3ad;
  --accent:#e0b84a; --line:#2c333d; --warn-bg:#3a2e12; --warn:#f3cf6b;
  --cellBg:#ffffff; --cellText:#1a1d21; --cellBorder:#9ea5ad;
  --trap:#f6b900; --mark:#111; --ok:#3fb950; --bad:#f85149;
  --stOk:#bfeccb; --stNo:#ffc9c4; --stNone:#dde1e6;
  --cols:8;
  /* Mobile first: every column must fit the screen width (the board
     scrolls sideways only when cells would get too small). */
  --cell: clamp(30px, calc((100vw - 20px) / var(--cols)), 72px);
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; background:var(--bg); color:var(--text);
  font:15px/1.4 system-ui,-apple-system,sans-serif; }
body { padding-bottom:calc(24px + env(safe-area-inset-bottom)); }
/* While editing, room below the board so even the last row can scroll up
   under the editor, clear of the keyboard. */
body.editing { padding-bottom:65vh; }

header.top { position:sticky; top:0; z-index:5; background:var(--bg);
  padding:10px 10px 8px; border-bottom:1px solid var(--line); }
header.top h1 { margin:0; font-size:17px; color:var(--accent); }
header.top .count { color:var(--muted); font-size:13px; }
.count .dup { color:#ff9b93; font-weight:600; }
.titlerow { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }

.syncrow { padding-top:4px; }
.sync { font-size:12px; font-weight:600; padding:2px 8px; border-radius:999px; }
.sync.local { color:var(--muted); background:var(--panel2); }
.sync.wait { color:#ffd27a; background:#3a2e12; }
.sync.live { color:#7be3a0; background:#123222; }
.tagrow { display:flex; align-items:center; gap:8px; padding-top:8px; }
.tagrow label { color:var(--muted); font-size:13px; white-space:nowrap; }
.tagrow input[type=text] { width:96px; flex:none; text-transform:uppercase; font-weight:700; padding:6px 8px; }
.tagpreview { color:var(--muted); font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.toolbar { display:flex; gap:6px; overflow-x:auto; padding-top:8px; scrollbar-width:none; }
.toolbar::-webkit-scrollbar { display:none; }
.toolbar .sep { flex:none; width:1px; background:var(--line); margin:4px 2px; }
button { font:inherit; font-size:14px; color:var(--text); background:var(--panel2);
  border:1px solid var(--line); border-radius:8px; padding:8px 12px; cursor:pointer;
  white-space:nowrap; min-height:38px; }
button:disabled { opacity:.4; cursor:default; }
button.primary { background:var(--accent); color:#1a1a1a; border-color:var(--accent); font-weight:600; }
button.on { background:var(--accent); color:#1a1a1a; border-color:var(--accent); }
button.danger { color:#ffb4ad; border-color:#6b2a26; }
button.icon { min-width:40px; padding:8px 10px; }

/* Layout editing bar, shown only in layout mode. */
.layoutbar { display:none; gap:6px; align-items:center; overflow-x:auto; padding-top:8px; scrollbar-width:none; }
.layoutbar::-webkit-scrollbar { display:none; }
body.layoutmode .layoutbar { display:flex; }
.layoutbar .lbl { color:var(--muted); font-size:12px; white-space:nowrap; }
.brush { display:flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; flex:none; }
.brush button { border:0; border-radius:0; min-height:36px; padding:6px 10px; }
.brush button + button { border-left:1px solid var(--line); }

.warn { margin:10px; padding:10px 12px; border-radius:8px; background:var(--warn-bg);
  color:var(--warn); border:1px solid #6b5520; font-size:13px; }
.warn b { color:#ffe08a; }
.warn[hidden] { display:none; }

/* Board */
#board { padding:0 10px; overflow-x:auto; }
table.grid { border-collapse:collapse; table-layout:fixed; margin:0 auto;
  width:calc(var(--cell) * var(--cols)); }
table.grid td { width:var(--cell); height:var(--cell); border:1px solid var(--cellBorder);
  padding:1px; text-align:center; vertical-align:middle; color:var(--cellText);
  background:var(--cellBg); font-weight:700; font-size:clamp(10px, calc(var(--cell) * 0.24), 16px);
  overflow:hidden; cursor:pointer; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; }
table.grid td.named { font-weight:600; font-size:clamp(8px, calc(var(--cell) * 0.17), 13px);
  line-height:1.1; word-break:break-word; }
table.grid td .nm { overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
table.grid td .num { display:block; font-size:clamp(7px, calc(var(--cell) * 0.14), 10px);
  color:#6b7076; font-weight:600; }
table.grid td.sel { outline:3px solid var(--accent); outline-offset:-3px; }
table.grid td.hit { background:#fff4cc; }
table.grid td.dup { box-shadow:inset 0 0 0 3px var(--bad); }
/* Move status of named slots: green placed, red not yet, grey no reply. */
table.grid td { position:relative; }
table.grid td.st-none { background:var(--stNone); }
table.grid td.st-ok { background:var(--stOk); }
table.grid td.st-no { background:var(--stNo); }
table.grid td .stb { position:absolute; top:1px; right:2px; font-size:clamp(8px, calc(var(--cell) * 0.16), 12px);
  font-weight:800; line-height:1; }
table.grid td.st-ok .stb { color:#137a2c; }
table.grid td.st-no .stb { color:#c0271d; }
body.nostatus table.grid td.st-none, body.nostatus table.grid td.st-ok, body.nostatus table.grid td.st-no { background:var(--cellBg); }
body.nostatus table.grid td .stb { display:none; }
/* Locked slot (confirmed member): small padlock in the top-left corner. */
table.grid td .lk { position:absolute; top:1px; left:1px; font-size:clamp(9px, calc(var(--cell) * 0.2), 13px);
  line-height:1; pointer-events:none; }
table.grid td.locked { border-color:#5b6470; }
body.markmode table.grid td[data-id] { cursor:copy; }
/* Blocked: the spot exists but nobody goes there. */
table.grid td.blocked { background:repeating-linear-gradient(45deg, #b9bfc6 0 5px, #dfe2e6 5px 10px);
  color:#5d636a; font-size:clamp(10px, calc(var(--cell) * 0.3), 20px); }
/* Empty: no city at all, so no border either. */
table.grid td.void { border:none; background:transparent; cursor:default; }
body.layoutmode table.grid td.void { cursor:pointer; outline:1px dashed #56606c; outline-offset:-4px; }
body.layoutmode table.grid td.trapblock { cursor:grab; }

/* Drag and drop */
table.grid td.dragsrc { opacity:.35; }
table.grid td.drop-ok { outline:3px solid var(--ok); outline-offset:-3px; }
table.grid td.drop-bad { outline:3px solid var(--bad); outline-offset:-3px; }
.ghost { position:fixed; left:0; top:0; z-index:50; pointer-events:none; display:flex;
  align-items:center; justify-content:center; text-align:center; padding:2px;
  background:#fff; color:#1a1d21; font-weight:700; font-size:12px; border-radius:6px;
  box-shadow:0 10px 28px rgba(0,0,0,.6); outline:3px solid var(--accent); opacity:.92;
  overflow:hidden; overflow-wrap:anywhere; }
.ghost.trap { background:var(--trap); }
.ghost.blocked { background:repeating-linear-gradient(45deg, #b9bfc6 0 5px, #dfe2e6 5px 10px); }
body.dragging, body.dragging * { cursor:grabbing !important; }

/* Bear trap block: 2x2 cities = 4x4 tiles; trap is 3x3 tiles, the 1-tile L
   strip stays empty with black markers at its corners (as in the pattern). */
table.grid td.trapblock { padding:0; position:relative; cursor:default; }
.tiles { position:absolute; inset:0; display:grid;
  grid-template-columns:repeat(4,1fr); grid-template-rows:repeat(4,1fr); }
.tiles .k { background:var(--mark); }
.tiles .t { background:var(--trap); }
.trapnote { position:absolute; transform:translate(-50%,-50%); width:68%; text-align:center;
  color:#1a1a1a; font-weight:700; font-size:clamp(9px, calc(var(--cell) * 0.17), 13px); line-height:1.15;
  overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
  overflow-wrap:anywhere; pointer-events:none; }
body:not(.layoutmode) table.grid td.trapblock { cursor:pointer; }
#cellmenu.traponly .cmlayout { display:none; }
.cmgroup[hidden] { display:none; }
#cmtrap input { flex:1; min-width:150px; font:inherit; padding:8px 10px; border-radius:8px;
  border:1px solid var(--line); background:var(--bg); color:var(--text); }
.traplabel { position:absolute; transform:translate(-50%,-50%); font-weight:800;
  color:#1a1a1a; font-size:clamp(12px, calc(var(--cell) * 0.3), 22px); pointer-events:none; }

/* Status panel, next to the board on desktop, under it on phones. */
#statuswrap { margin:14px 10px 0; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; }
#statuswrap h2 { margin:0 0 8px; font-size:15px; display:flex; justify-content:space-between; align-items:baseline; }
#statuswrap h2 small { color:var(--muted); font-weight:500; font-size:12px; }
.bar { display:flex; height:8px; border-radius:4px; overflow:hidden; background:var(--panel2); margin-bottom:10px; }
.bar i { display:block; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip { display:flex; align-items:center; gap:6px; font-size:13px; padding:6px 10px; min-height:34px; }
.chip .sw { width:14px; height:14px; border-radius:3px; border:1px solid #0004; flex:none; }
.chip.on { outline:2px solid var(--accent); }
.sw.ok { background:var(--stOk); } .sw.no { background:var(--stNo); } .sw.none { background:var(--stNone); }
.stlist { margin-top:10px; font-size:13px; max-height:220px; overflow:auto; }
.stlist h3 { margin:8px 0 4px; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.stlist .who { display:flex; flex-wrap:wrap; gap:4px; }
.stlist .who button { min-height:28px; padding:2px 8px; font-size:12px; border-radius:6px; }
.stlist .who button b { color:var(--muted); font-weight:600; margin-right:4px; }
.stactions { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
.stactions button { min-height:34px; padding:6px 10px; font-size:13px; }
#editor .strow { display:flex; gap:6px; margin-top:8px; }
#editor .strow button { flex:1; min-height:40px; font-size:14px; }
#editor .strow button.on { color:#fff; font-weight:700; }
#editor .strow button.on.ok { background:#1d5c2e; border-color:var(--ok); }
#editor .strow button.on.no { background:#6b2420; border-color:var(--bad); }
#editor .strow button.on.none { background:#3a414b; border-color:var(--muted); }
.opts { display:flex; gap:14px; flex-wrap:wrap; font-size:13px; color:var(--muted); margin-top:8px; }
.opts label { display:flex; gap:6px; align-items:center; }

/* List */
#listwrap { margin:14px 10px 0; background:var(--panel); border:1px solid var(--line); border-radius:10px; }
#listwrap summary { padding:12px 14px; cursor:pointer; font-weight:600; list-style:none;
  display:flex; justify-content:space-between; }
#listwrap summary::-webkit-details-marker { display:none; }
#listwrap summary::after { content:"▾"; color:var(--muted); }
#listwrap[open] summary::after { content:"▴"; }
.find { padding:0 12px 8px; }
input[type=search], input[type=text], input[type=password], textarea { font:inherit; font-size:16px; /* no iOS zoom */
  color:var(--text); background:var(--panel2); border:1px solid var(--line);
  border-radius:8px; padding:9px 10px; width:100%; }
input:focus, textarea:focus { outline:none; border-color:var(--accent); }
#list { padding:0 8px 10px; }
.slot { display:flex; align-items:center; gap:8px; padding:4px; }
.slot .n { width:30px; flex:none; text-align:right; color:var(--muted); font-weight:600;
  font-variant-numeric:tabular-nums; }
.slot.dup input { border-color:var(--bad); }
.slot.locked input { color:#9cc7ff; border-style:dashed; }
.slot.locked .n { width:auto; min-width:30px; font-size:12px; }

/* Panels (name editor, cell options) open just under the sticky header, so
   the toolbar stays visible; near the top because phone keyboards cover the
   bottom of the page. JS sets `top` (see placePanels). */
.toppanel { position:fixed; left:0; right:0; top:0; z-index:4;
  padding:10px 10px 12px;
  background:var(--panel); border-bottom:3px solid var(--accent);
  box-shadow:0 8px 24px rgba(0,0,0,.55);
  opacity:0; transform:translateY(-8px); transition:opacity .15s, transform .15s; visibility:hidden; }
.toppanel.open { opacity:1; transform:none; visibility:visible; }
.toppanel .close { min-width:40px; min-height:40px; padding:4px 10px; font-size:18px; }
.toppanel .edhead { display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-bottom:8px; }
.toppanel .edtitle { font-size:13px; color:var(--muted); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.toppanel .edtitle b { color:var(--accent); font-size:20px; margin-right:6px; }
#editor .edrow { display:flex; gap:8px; align-items:center; }
#editor .edrow input { flex:1; min-width:0; font-size:18px; padding:11px 12px;
  border:2px solid var(--accent); background:#10141a; }
#editor .edrow .prefix { color:var(--muted); font-weight:700; }
#editor button { min-width:44px; min-height:44px; font-size:18px; padding:6px 10px; }
.toppanel .done { font-size:15px; font-weight:700; min-height:40px; }
#editor .edhint { color:var(--muted); font-size:12px; margin-top:6px; }
#editor .lockrow { display:flex; align-items:center; gap:8px; margin-top:8px; padding:6px 6px 6px 10px; border-radius:8px;
  background:var(--panel2); font-size:13px; color:var(--muted); }
#editor .lockrow[hidden] { display:none; }
#editor .lockrow span { flex:1; min-width:0; }
#editor .lockrow.on { background:#16283d; color:#9cc7ff; border:1px solid #284a70; }
#editor .lockrow.on b { color:#fff; }
#editor .lockrow button { min-height:36px; min-width:0; font-size:13px; padding:4px 12px; flex:none; }
#editor input[readonly] { border-color:#284a70; color:#9cc7ff; }
.toppanel .remote { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-top:8px; padding:6px 8px;
  border-radius:8px; background:var(--warn-bg); color:var(--warn); font-size:13px; }
.toppanel .remote[hidden] { display:none; }
.toppanel .remote .msg { flex:1 1 180px; }
#editor .remote button, #cellmenu .remote button { min-height:34px; min-width:0; font-size:13px; padding:4px 10px; }
.cmgroup { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding:4px 0; }
@keyframes flash { from { box-shadow: inset 0 0 0 3px #f5b400; } to { box-shadow: inset 0 0 0 3px transparent; } }
#board td.flash { animation: flash 1.2s ease-out; }
.cmgroup > span { width:64px; color:var(--muted); font-size:13px; }
.cmnote { color:var(--muted); font-size:12px; margin:6px 0 0; }
@media (min-width:900px) {
  .toppanel { left:50%; right:auto; width:560px; margin-left:-280px; border:1px solid var(--line);
    border-top:0; border-radius:0 0 12px 12px; border-bottom:3px solid var(--accent); z-index:6; }
}

#hint { text-align:center; color:var(--muted); font-size:12px; margin:8px 10px 0; }

/* Dialogs */
dialog { background:var(--panel); color:var(--text); border:1px solid var(--line); border-radius:12px;
  width:min(560px, calc(100vw - 24px)); padding:16px; }
dialog::backdrop { background:rgba(0,0,0,.6); }
dialog h2 { margin:0 0 10px; font-size:17px; color:var(--accent); }
dialog p { margin:0 0 10px; color:var(--muted); font-size:13px; }
.dlgbtns { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.dlgbtns .grow { flex:1; }
#imgpreview { display:block; max-width:100%; max-height:52vh; margin:0 auto; border-radius:6px; background:#fff; }
#imgstatus { min-height:1.4em; margin-top:8px; font-size:13px; color:#7be3a0; }
dialog p.embednote { margin:6px 0 0; font-size:12px; }
dialog p.embednote[hidden] { display:none; }
.choice { display:block; width:100%; text-align:left; white-space:normal; margin-bottom:8px; padding:10px 12px; }
.choice b { display:block; color:var(--text); }
.choice span { color:var(--muted); font-size:13px; }
#pastetext { min-height:180px; resize:vertical; font-family:ui-monospace,monospace; font-size:14px; }
code { background:var(--panel2); padding:1px 4px; border-radius:4px; }

/* Toast with optional Undo */
#toast { position:fixed; left:50%; bottom:calc(16px + env(safe-area-inset-bottom)); transform:translateX(-50%);
  z-index:40; display:none; align-items:center; gap:10px; max-width:calc(100vw - 24px);
  background:#2b313a; border:1px solid var(--line); border-radius:10px; padding:6px 6px 6px 14px;
  box-shadow:0 8px 24px rgba(0,0,0,.5); font-size:14px; }
#toast.show { display:flex; }
#toast button { min-height:34px; padding:4px 12px; }

/* Presence: who is on the board (like Excalidraw's collaborators). */
.syncrow { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.peers { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.avs { display:flex; }
.av { width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:800; color:#fff; border:2px solid var(--bg); margin-left:-6px; cursor:pointer;
  padding:0; min-height:0; text-transform:uppercase; }
.av:first-child { margin-left:0; }
.av.me { box-shadow:0 0 0 2px var(--accent); }
.watching { font-size:12px; color:var(--muted); white-space:nowrap; }
.meline { font-size:12px; color:var(--muted); white-space:nowrap; }
.meline b { font-weight:700; }
/* A cell someone else has open: their colour + name tag. */
table.grid td.peer { outline:3px solid var(--peer); outline-offset:-3px; }
.peertag { position:absolute; left:0; top:0; z-index:2; max-width:100%; padding:0 4px; border-radius:0 0 5px 0;
  background:var(--peer); color:#fff; font-size:9px; font-weight:700; line-height:1.45;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; pointer-events:none; }
@keyframes peerflash { from { box-shadow: inset 0 0 0 4px var(--peer); } to { box-shadow: inset 0 0 0 4px transparent; } }
#board td.pflash { animation: peerflash 1.4s ease-out; }

/* Viewer: read-only, laid out like the exported image. Editors get the same
   view with 👁 Preview. */
#sheethead { display:none; }
#previewbar { display:none; margin:10px 10px 0; padding:8px 8px 8px 12px; border-radius:8px; align-items:center;
  gap:8px; justify-content:space-between; background:#16283d; color:#9cc7ff; border:1px solid #284a70; font-size:13px; }
body.preview #previewbar { display:flex; }
body.viewer .toolbar > :not(.vw), body.viewer .tagrow, body.viewer .layoutbar,
body.viewer #listwrap, body.viewer #streset, body.viewer #warn { display:none !important; }
body.viewer main.layout { background:#fff; color:#1a1d21; border-radius:12px; margin:10px; padding:14px 10px; }
/* The white card takes 40px more of the width than the editor page. */
body.viewer { --cell: clamp(28px, calc((100vw - 44px) / var(--cols)), 72px); }
body.viewer #sheethead { display:flex; justify-content:space-between; align-items:baseline; gap:4px 12px;
  flex-wrap:wrap; padding:0 0 12px; }
#sheethead h2 { margin:0; font-size:20px; font-weight:800; color:#1a1d21; }
#sheethead span { color:#6b7076; font-size:13px; font-weight:600; }
body.viewer #board { padding:0; }
body.viewer table.grid td { cursor:default; }
body.viewer table.grid td[data-id].named, body.viewer table.grid td.trapblock { cursor:pointer; }
body.viewer #statuswrap { background:#f4f5f7; border-color:#e3e6ea; color:#1a1d21; margin:14px 0 0; }
body.viewer #statuswrap h2 small, body.viewer .stlist h3 { color:#5d636a; }
body.viewer .bar { background:#e3e6ea; }
body.viewer #statuswrap button { background:#fff; color:#1a1d21; border-color:#d5d9de; }
body.viewer #statuswrap button.primary { background:var(--accent); border-color:var(--accent); }
body.viewer #hint { color:#6b7076; }

/* Login + history */
.field { display:block; margin:0 0 10px; font-size:13px; color:var(--muted); }
.field input { margin-top:4px; }
.err { min-height:1.4em; color:#ff9b93; font-size:13px; }
#histlist { max-height:60vh; overflow:auto; margin:0 -4px; }
.he { display:grid; grid-template-columns:auto 1fr; gap:0 10px; padding:7px 4px; border-bottom:1px solid var(--line); font-size:13px; }
.he time { color:var(--muted); font-variant-numeric:tabular-nums; font-size:12px; padding-top:1px; white-space:nowrap; }
.he .what b { font-weight:700; }
.he .where { grid-column:2; color:var(--muted); font-size:11px; }
.he.login .what, .he.fail .what { color:var(--muted); }
.he.new { animation:hnew 1.5s ease-out; }
@keyframes hnew { from { background:#3a2e12; } to { background:transparent; } }
#histempty { color:var(--muted); font-size:13px; padding:10px 4px; }
/* Templates */
#tpllist { max-height:46vh; overflow:auto; margin:0 -4px 10px; border-top:1px solid var(--line); }
.tpl { display:flex; align-items:center; gap:8px; padding:8px 4px; border-bottom:1px solid var(--line); }
.tpl .tthumb { flex:none; width:44px; height:44px; border-radius:6px; background:#fff; display:block; }
.tpl .tinfo { flex:1; min-width:0; }
.tpl .tinfo b { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.tpl .tinfo small { display:block; color:var(--muted); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tpl button { min-height:36px; padding:4px 12px; font-size:13px; flex:none; }
.tpl button.icon { min-width:36px; padding:4px 8px; }
.tplnote { color:var(--muted); font-size:13px; padding:10px 4px; }
.tplsave { display:flex; gap:8px; }
.tplsave input { flex:1; min-width:0; }
.tplsave button { flex:none; }

/* Desktop: list as a sidebar next to the board. */
@media (min-width:900px) {
  :root { --cell: clamp(40px, calc((100vw - 400px) / var(--cols)), 72px); }
  body, body.editing { padding-bottom:0; }
  main.layout { display:grid; grid-template-columns:340px minmax(0, 1fr); gap:16px; align-items:start; padding:10px; }
  /* --hdr = live header height (set by placePanels). */
  #side { position:sticky; top:calc(var(--hdr, 160px) + 8px); display:flex; flex-direction:column; gap:10px;
    max-height:calc(100vh - var(--hdr, 160px) - 18px); }
  #statuswrap { margin:0; flex:none; }
  #listwrap { margin:0; min-height:0; overflow:auto; }
  .warn { margin:10px 10px 0; }
  #board { padding:0; }
  #side { order:0; } #center { order:1; }
  body.viewer main.layout { grid-template-columns:minmax(0, 1fr) 320px; padding:16px; }
  body.viewer { --cell: clamp(40px, calc((100vw - 420px) / var(--cols)), 72px); }
  body.viewer #side { order:1; } body.viewer #center { order:0; }
  body.viewer #statuswrap { margin:0; }
}

/* --- collaboration: idle / away, people, follow, ping, links, find --- */
.toppanel .edacts { display:flex; gap:6px; align-items:center; flex:none; }
#editor .edacts .mini, #cellmenu .edacts .mini { min-width:0; min-height:40px; font-size:13px; padding:4px 9px; }
.mini[hidden] { display:none; }
/* Phone viewer: the four toolbar buttons fit without sideways scrolling. */
@media (max-width:480px) {
  body.viewer .toolbar button { padding:8px 9px; }
  body.viewer #findbtn .lbl { display:none; }
}
.av.idle { opacity:.55; }
.av.away { opacity:.3; filter:grayscale(1); }
.peers { cursor:pointer; }

/* Small panels under the header (people, find). JS sets `top`. */
.pop { position:fixed; z-index:7; top:0; background:var(--panel); border:1px solid var(--line);
  box-shadow:0 8px 24px rgba(0,0,0,.55); }
.pop[hidden] { display:none; }
#peoplepop { left:10px; right:10px; max-width:360px; border-radius:0 0 12px 12px; border-top:0;
  max-height:min(60vh, 420px); overflow:auto; padding:4px 0; }
.prow { display:flex; align-items:center; gap:8px; padding:6px 12px; min-height:48px; }
.prow + .prow { border-top:1px solid var(--line); }
.prow .dot { width:12px; height:12px; border-radius:50%; flex:none; }
.prow .who { flex:1; min-width:0; }
.prow .who b { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.prow .who small { display:block; color:var(--muted); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.prow .st { font-size:11px; padding:1px 6px; border-radius:999px; background:var(--panel2); color:var(--muted); margin-left:4px; font-weight:600; }
.prow .st.active { color:#7be3a0; background:#123222; }
.prow button { min-height:36px; padding:4px 12px; font-size:13px; flex:none; }
.pfoot { padding:8px 12px 6px; color:var(--muted); font-size:12px; border-top:1px solid var(--line); }
.pempty { padding:10px 12px; color:var(--muted); font-size:13px; }

#findbar { left:0; right:0; display:flex; align-items:center; gap:6px; padding:8px 10px;
  border-width:0 0 3px; border-bottom-color:var(--accent); }
#findbar[hidden] { display:none; }
#findbar input { flex:1; min-width:0; padding:8px 10px; }
#findcount { color:var(--muted); font-size:13px; font-variant-numeric:tabular-nums; min-width:34px; text-align:center; white-space:nowrap; }
#findbar .mini { min-width:40px; min-height:40px; padding:4px 8px; font-size:16px; }
@media (min-width:900px) {
  #findbar { left:50%; right:auto; width:480px; margin-left:-240px; border:1px solid var(--line); border-top:0;
    border-radius:0 0 12px 12px; border-bottom:3px solid var(--accent); }
  #peoplepop { left:auto; right:16px; width:340px; }
}
table.grid td.findhit { box-shadow:inset 0 0 0 3px #5aa9ff; }
table.grid td.findcur { outline:3px solid #1c7ed6; outline-offset:-3px; box-shadow:inset 0 0 0 6px #a5d0ff; }

/* Following another editor: coloured frame + bar at the bottom. */
#followframe { display:none; position:fixed; inset:0; z-index:30; pointer-events:none;
  border:3px solid var(--follow, var(--accent)); }
body.following #followframe { display:block; }
#followbar { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(12px + env(safe-area-inset-bottom)); z-index:41;
  display:flex; align-items:center; gap:8px; max-width:calc(100vw - 24px); padding:4px 4px 4px 12px;
  background:var(--panel); color:var(--text); border:2px solid var(--follow, var(--accent)); border-radius:999px;
  box-shadow:0 8px 24px rgba(0,0,0,.5); font-size:14px; }
#followbar[hidden] { display:none; }
#followbar .fdot { width:10px; height:10px; border-radius:50%; background:var(--follow, var(--accent)); flex:none; }
#followtext { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#followbar button { min-height:34px; min-width:34px; padding:2px 8px; border-radius:999px; flex:none; }
body.following #toast { bottom:calc(64px + env(safe-area-inset-bottom)); }

/* Ping: three rings in the pinger's colour + a name tag. */
.pingfx { position:absolute; inset:0; pointer-events:none; z-index:3; }
.pingfx i { position:absolute; left:50%; top:50%; width:100%; height:100%; margin:-50% 0 0 -50%; border-radius:50%;
  border:3px solid var(--ping); opacity:0; animation:ring 1.5s ease-out forwards; }
.pingfx i:nth-child(2) { animation-delay:.25s; }
.pingfx i:nth-child(3) { animation-delay:.5s; }
@keyframes ring { from { transform:scale(.15); opacity:1; } to { transform:scale(1.15); opacity:0; } }
table.grid td.ping { outline:3px solid var(--ping); outline-offset:-3px; }
.pingtag { position:absolute; right:0; bottom:0; z-index:4; max-width:100%; padding:0 4px; border-radius:5px 0 0 0;
  background:var(--ping); color:#fff; font-size:9px; font-weight:700; line-height:1.45;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; pointer-events:none; }
/* Opened from a link to this slot: stays until the next tap. */
@keyframes linked { 0%,100% { box-shadow:inset 0 0 0 3px var(--accent); } 50% { box-shadow:inset 0 0 0 6px var(--accent); } }
table.grid td.linked { outline:3px solid var(--accent); outline-offset:-3px; animation:linked 1.6s ease-in-out infinite; }
/* Drop a file anywhere to import it. */
#dropzone { position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; padding:16px;
  background:rgba(10,12,16,.78); pointer-events:none; }
#dropzone[hidden] { display:none; }
#dropzone .dzbox { width:min(460px, 100%); padding:28px 20px; border:3px dashed var(--accent); border-radius:16px;
  background:var(--panel); text-align:center; display:flex; flex-direction:column; gap:8px; box-shadow:0 12px 40px rgba(0,0,0,.6); }
#dropzone b { font-size:20px; color:var(--accent); }
#dropzone span { color:var(--muted); font-size:13px; }
#dropzone span[hidden] { display:none; }
#dropzone.no .dzbox { border-color:var(--muted); }
#dropzone.no b { color:var(--text); }
@media (prefers-reduced-motion: reduce) {
  .pingfx { display:none; }
  table.grid td.linked { animation:none; box-shadow:inset 0 0 0 5px var(--accent); }
  #board td.pflash, #board td.flash { animation:none; }
}
