/* Canvas 2.0. Colors follow the LogiShell kit (tokens.css), so the board looks like the main canvas everywhere,
   also on a tablet or a phone where the app's lsh://kit is not around. */
:root {
  --bg: oklch(0.975 0.006 95);
  --grid: oklch(0.9 0.008 95);
  --grid-major: oklch(0.86 0.01 95);
  --surface: oklch(1 0 0 / 0.9);
  --surface-strong: oklch(1 0 0 / 0.98);
  --text: oklch(0.22 0.01 260);
  --muted: oklch(0.52 0.01 260);
  --line: oklch(0.88 0.006 95);
  --accent: oklch(0.78 0.14 80);
  --accent-ink: oklch(0.32 0.08 70);
  --accent-glow: color-mix(in oklch, var(--accent), transparent 80%);
  --frame: oklch(0.93 0.004 260 / 0.55);
  --frame-line: oklch(0.8 0.006 260);
  --note-pink: oklch(0.96 0.03 10);
  --note-yellow: oklch(0.96 0.07 95);
  --note-blue: oklch(0.95 0.03 240);
  --note-green: oklch(0.95 0.05 150);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.06), 0 6px 20px oklch(0 0 0 / 0.07);
  --ink: #1d1f24;
  --cell: 104px;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.18 0.01 260);
    --grid: oklch(0.235 0.012 260);
    --grid-major: oklch(0.27 0.014 260);
    --surface: oklch(0.26 0.014 260 / 0.9);
    --surface-strong: oklch(0.28 0.016 260 / 0.98);
    --text: oklch(0.95 0.005 260);
    --muted: oklch(0.7 0.01 260);
    --line: oklch(0.34 0.014 260);
    --accent: oklch(0.83 0.16 85);
    --accent-ink: oklch(0.28 0.06 72);
    --frame: oklch(0.3 0.014 260 / 0.45);
    --frame-line: oklch(0.42 0.016 260);
    --note-pink: oklch(0.33 0.05 10);
    --note-yellow: oklch(0.36 0.06 90);
    --note-blue: oklch(0.32 0.05 240);
    --note-green: oklch(0.33 0.05 150);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 8px 24px oklch(0 0 0 / 0.35);
    --ink: #eceff4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.4 Geist, ui-sans-serif, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- stage ---------- */
#stage { position: fixed; inset: 0; touch-action: none; overflow: hidden; cursor: default;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--gs, var(--cell)) var(--gs, var(--cell)); background-position: var(--gx, 0) var(--gy, 0); }
#stage.pen { cursor: crosshair; }
#stage.panning { cursor: grabbing; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.layer { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }

/* frames */
.frame { position: absolute; border: 1px solid var(--frame-line); background: var(--frame); border-radius: 10px; }
.frame .title { position: absolute; left: 0; top: -26px; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; background: var(--surface-strong); border: 1px solid var(--line); font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.frame .title::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--muted); opacity: .7; }

/* notes and text */
.note { position: absolute; border-radius: 12px; padding: 26px 14px 12px; box-shadow: var(--shadow); background: var(--note-pink);
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden; font-size: 15px; line-height: 1.35; }
.note::before { content: "Note"; position: absolute; left: 12px; top: 7px; font: 500 10.5px/1 "Geist Mono", ui-monospace, monospace; color: var(--muted); letter-spacing: .02em; }
.note.yellow { background: var(--note-yellow); } .note.blue { background: var(--note-blue); } .note.green { background: var(--note-green); }
.text { position: absolute; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; line-height: 1.2; }
.item.selected { outline: 2px solid var(--accent); outline-offset: 3px; }
.editing { pointer-events: auto; -webkit-user-select: text; user-select: text; cursor: text; outline: 2px solid var(--accent) !important; }
.editing:focus { outline-offset: 3px; }

/* overlay: selection, marquee, magic */
#over .marquee { position: absolute; border: 1px dashed var(--accent); background: var(--accent-glow); border-radius: 4px; }
#over .selbox { position: absolute; border: 1.5px solid var(--accent); border-radius: 6px; }
#over .spell { position: absolute; border-radius: 14px; overflow: hidden; border: 1.5px solid var(--accent);
  background: linear-gradient(110deg, transparent 20%, var(--accent-glow) 45%, transparent 70%) 0 0 / 250% 100%;
  animation: spell 1.1s linear infinite; }
@keyframes spell { to { background-position: -250% 0; } }
.cursor { position: absolute; width: 0; height: 0; pointer-events: none; transition: transform 80ms linear; }
.cursor i { position: absolute; left: 8px; top: 8px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font: 500 11px/18px Geist, sans-serif; font-style: normal; white-space: nowrap; }
.cursor::before { content: ""; position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }

/* ---------- chrome ---------- */
.glass { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); }

#top { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 74px; right: 12px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.crumbs { pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 8px; border-radius: 999px; font-weight: 500; }
.crumbs { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.crumbs .mark { width: 24px; height: 24px; border-radius: 7px; }
.crumbs .sep { color: var(--muted); }
.crumbs .tag { font: 500 10.5px/1 "Geist Mono", monospace; padding: 4px 6px; border-radius: 6px; background: var(--accent-glow); color: var(--text); }
#people { pointer-events: auto; display: flex; gap: 6px; }
.person { height: 30px; padding: 0 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.person::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: oklch(0.72 0.17 150); }

#tools { position: fixed; left: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 18px; }
#tools { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
#tools button { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
#tools button:hover { background: var(--bg); color: var(--text); }
#tools button.on { background: var(--accent); color: var(--accent-ink); }
#tools .gap { height: 1px; margin: 3px 6px; background: var(--line); }
.magic { color: var(--accent-ink) !important; background: linear-gradient(135deg, oklch(0.88 0.13 90), oklch(0.8 0.15 70)) !important; }
.magic.busy svg { animation: wiggle .6s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }

#pen-bar { position: fixed; left: 70px; top: 50%; transform: translateY(-50%); display: none; flex-direction: column; gap: 10px; padding: 10px 8px; border-radius: 16px; }
#pen-bar { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
body.tool-pen #pen-bar { display: flex; }
#colors, .widths { display: flex; flex-direction: column; gap: 8px; align-items: center; }
#colors button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line); }
#colors button.on, .widths button.on { box-shadow: 0 0 0 2px var(--accent); }
.widths button { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.widths button::after { content: ""; border-radius: 50%; background: var(--text); }
.w2::after { width: 4px; height: 4px; } .w4::after { width: 7px; height: 7px; } .w8::after { width: 11px; height: 11px; }

#bottom { position: fixed; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
#zoom, #history { display: flex; align-items: center; height: 40px; padding: 0 4px; border-radius: 12px; }
#zoom, #history { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
#zoom button, #history button { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; color: var(--muted); }
#zoom button:hover, #history button:hover { background: var(--bg); color: var(--text); }
#zval { min-width: 52px; text-align: center; font: 500 12px/1 "Geist Mono", monospace; color: var(--muted); }

#sel-bar { position: fixed; display: flex; gap: 4px; padding: 4px; border-radius: 12px; transform: translate(-50%, -100%); }
#sel-bar { background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); }
#sel-bar button { height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 500; font-size: 13px; }
#sel-bar button:hover { background: var(--bg); }
#sel-bar[hidden] { display: none; }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 12px; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13.5px; }
#toast[hidden] { display: none; }
#dot { position: fixed; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); width: 9px; height: 9px; border-radius: 50%; background: oklch(0.65 0.2 25); }
#dot.on { background: oklch(0.72 0.17 150); }

/* inside the LogiShell app the window already has a title bar */
body.in-app #top { left: 74px; }

/* phones: tools go to the bottom edge */
@media (max-width: 640px) {
  #top { left: 12px; }
  .crumbs .sep, #space-name { display: none; }
  #tools { top: auto; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); flex-direction: row; padding: 5px; }
  #tools button { width: 40px; height: 40px; }
  #tools .gap { width: 1px; height: auto; margin: 6px 2px; }
  #pen-bar { left: 50%; top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px); transform: translateX(-50%); flex-direction: row; }
  #colors, .widths { flex-direction: row; }
  #bottom { left: auto; right: 12px; bottom: auto; top: calc(max(12px, env(safe-area-inset-top)) + 52px); }
  #people { display: none; }
  #zoom #zval { display: none; }
  #toast { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 120px); }
}

/* cards: an app or a doc LOG made; select one to use it, otherwise the board takes the pen */
.card { position: absolute; border-radius: 14px; overflow: hidden; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card-bar { height: 30px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 500; }
.card-status { color: var(--muted); font: 500 10.5px/1 "Geist Mono", monospace; }
.card iframe { flex: 1; width: 100%; border: 0; background: #fff; pointer-events: none; }
.card.live iframe { pointer-events: auto; }
