/* Lacewing — warm drafting-paper canvas, ink controls, one colour per peer. */

:root {
  --ground: #F3F0E8;
  --dots: #D3CCBC;
  --surface: #FFFFFF;
  --surface-2: #FAF8F3;
  --line: #E2DDD1;
  --line-2: #EFEBE2;
  --line-3: #CFC8B8;
  --ink: #1B1A17;
  --on-ink: #F3F0E8;
  --body: #3F3C36;
  --muted: #5E5A52;
  --accent: #C4411E;
  --on-accent: #FFFFFF;
  --danger: #B42318;
  --danger-text: #8A2A12;
  --danger-soft: #FBE9E5;
  --ok: #155C43;
  --ok-soft: #E3F1EA;
  --gold: #B7791F;
  --night: #1B1A17;
  --night-2: #34312B;
  --night-text: #F3F0E8;
  --night-muted: #CFC8BA;
  --shadow: 0 8px 24px rgba(27, 26, 23, 0.08);
  --shadow-lg: 0 20px 48px rgba(27, 26, 23, 0.16);

  --peer-vermilion: #C4411E;
  --peer-blue: #2A5BD7;
  --peer-green: #1F7A5A;
  --peer-violet: #7A3FC0;
  --peer-amber: #9A6212;
  --peer-teal: #0F6E7A;
  --peer-rose: #B0306A;
  --peer-slate: #4B5563;
  --on-peer: #FFFFFF;

  --ink-ink: var(--ink);
  --ink-vermilion: #C4411E;
  --ink-blue: #2A5BD7;
  --ink-green: #1F7A5A;
  --ink-amber: #E0A32E;
  --ink-violet: #7A3FC0;

  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', var(--font-sans);
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 12px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #171613;
    --dots: #34312B;
    --surface: #23211D;
    --surface-2: #1C1A17;
    --line: #36332D;
    --line-2: #2E2B26;
    --line-3: #4A463E;
    --ink: #EDE8DD;
    --on-ink: #171613;
    --body: #CFC8BA;
    --muted: #A59E90;
    --accent: #F08A67;
    --on-accent: #171613;
    --danger: #B42318;
    --danger-text: #F29B84;
    --danger-soft: #3A1F1A;
    --ok: #7FD3AE;
    --ok-soft: #1E3B30;
    --gold: #E0A32E;
    --night: #2C2A25;
    --night-2: #3A3731;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);

    --peer-vermilion: #F08A67;
    --peer-blue: #7EA2F2;
    --peer-green: #5FC49A;
    --peer-violet: #B592EC;
    --peer-amber: #E0A94A;
    --peer-teal: #5CC3CF;
    --peer-rose: #EE8AB6;
    --peer-slate: #A7B0BE;
    --on-peer: #171613;

    --ink-vermilion: #F08A67;
    --ink-blue: #7EA2F2;
    --ink-green: #5FC49A;
    --ink-amber: #E0A94A;
    --ink-violet: #B592EC;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--ground);
  background-image: radial-gradient(var(--dots) 1.2px, transparent 1.5px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--peer-blue); }
h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--peer-blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; }

/* ---------- type & utilities ---------- */
.display { font-family: var(--font-display); font-weight: 700; font-size: clamp(40px, 6vw, 68px); line-height: 0.98; letter-spacing: -0.03em; }
.display-sm { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.05; letter-spacing: -0.02em; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.h3 { font-size: 17px; font-weight: 600; }
.lead { font-size: clamp(16px, 1.4vw, 18px); line-height: 1.55; color: var(--body); }
.lead-sm { font-size: 15px; line-height: 1.55; color: var(--body); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.mono { font-family: var(--font-mono); font-weight: 500; }
.ink { color: var(--ink); }
.grow { flex: 1 1 auto; }
.min0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.max-260 { max-width: 260px; line-height: 1.45; }
.max-420 { max-width: 420px; line-height: 1.5; }
.stack-2, .stack-6, .stack-8, .stack-10, .stack-12, .stack-16, .stack-20, .stack-24 { display: flex; flex-direction: column; }
.stack-2 { gap: 2px; } .stack-6 { gap: 6px; } .stack-8 { gap: 8px; } .stack-10 { gap: 10px; } .stack-12 { gap: 12px; }
.stack-16 { gap: 16px; } .stack-20 { gap: 20px; } .stack-24 { gap: 24px; }
.row-8, .row-10, .row-16, .row-between { display: flex; align-items: center; }
.row-8 { gap: 8px; } .row-10 { gap: 10px; } .row-16 { gap: 16px; }
.row-between { justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--line-2); }
.peer-text { color: var(--pc); }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.eyebrow-gold { color: #E0A32E; }
.eyebrow-danger { color: var(--danger-text); }
.badge { align-self: flex-start; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.chip { height: 36px; padding: 0 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: inline-flex; align-items: center; font-size: 14px; font-weight: 600; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.tagline { font-size: 15px; color: var(--muted); margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--line-3); }
.logo-mark { flex-shrink: 0; }

/* ---------- buttons ---------- */
.btn {
  height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none; flex-shrink: 0;
  transition: background-color 120ms, border-color 120ms, transform 60ms;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: var(--surface); border-color: var(--line-3); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn-dark { background: var(--ink); color: var(--on-ink); }
.btn-dark:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 88%, var(--ground)); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 54px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--line-2); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.icon-btn-outline { border: 1px solid var(--line); }
.icon-btn-surface { background: var(--surface); border: 1px solid var(--line); }
.icon-btn-accent { background: var(--accent); color: var(--on-accent); }
.icon-btn-accent:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

/* ---------- inputs ---------- */
.input { height: 44px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--surface-2); font-size: 15px; }
.input:focus { outline: none; border-color: var(--ink); }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.link-field { display: flex; flex-direction: column; gap: 6px; }
.link-row { display: flex; gap: 8px; }
.link-input {
  flex: 1 1 auto; min-width: 0; height: 56px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--ink); background: var(--surface); font-family: var(--font-mono); font-size: 15px; text-overflow: ellipsis;
}
.link-row .btn { height: 56px; }
.link-field-compact .link-input, .link-field-compact .btn { height: 46px; font-size: 13px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; position: relative; }
.switch-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch-text strong { font-size: 14px; }
.switch-text span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.switch-input { position: absolute; opacity: 0; width: 44px; height: 26px; right: 0; margin: 0; cursor: pointer; }
.switch-track { width: 44px; height: 26px; border-radius: 13px; background: var(--line-3); position: relative; flex-shrink: 0; transition: background 150ms; }
.switch-thumb { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 150ms; }
.switch-input:checked + .switch-track { background: var(--ok); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--peer-blue); outline-offset: 2px; }

/* ---------- cards & notes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.card-flat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--muted); }
.note svg { flex-shrink: 0; margin-top: 1px; }
.note-boxed { padding: 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; color: var(--body); }
.dark-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--night); color: var(--night-text); border-radius: 12px; font-size: 13px; line-height: 1.5; }
.dark-note svg { flex-shrink: 0; margin-top: 1px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.callout-warn { background: var(--danger-soft); color: var(--danger-text); }

.avatar {
  width: var(--size, 32px); height: var(--size, 32px); border-radius: 50%; background: var(--pc); color: var(--on-peer);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: calc(var(--size, 32px) * 0.34); font-weight: 600; letter-spacing: 0.02em;
}
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

.identity-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.identity-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.identity-slot { min-height: 40px; display: flex; align-items: center; }
.identity-name { font-size: 19px; font-weight: 600; }
.name-button { border: 0; background: none; padding: 2px 0; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; text-align: left; border-radius: 6px; }
.name-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-button svg { color: var(--muted); flex-shrink: 0; }
.name-button:hover span { text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 4px; }
.name-button:hover svg { color: var(--ink); }
.name-input { width: 100%; height: 40px; font-size: 17px; font-weight: 600; background: var(--surface); }
.input-lg { flex: 1; height: 50px; font-size: 17px; }
.field-error { font-size: 13px; color: var(--danger-text); min-height: 1em; }

.promise { background: var(--night); color: var(--night-text); border-radius: 22px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.promise-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 3vw, 40px); line-height: 1.05; letter-spacing: -0.02em; }
.promise-list { display: flex; flex-direction: column; gap: 18px; }
.promise-list li { display: flex; gap: 14px; align-items: flex-start; }
.promise-list strong { display: block; font-size: 17px; }
.promise-list span { font-size: 14px; line-height: 1.45; color: var(--night-muted); }
.promise-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--night-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.promise-compact { padding: 18px; gap: 12px; border-radius: 18px; }
.promise-compact .promise-icon { width: 36px; height: 36px; }

.pillars { display: flex; flex-direction: column; gap: 12px; }
.pillars li { display: flex; gap: 12px; align-items: flex-start; }
.pillars strong { display: block; font-size: 14px; }
.pillars span { font-size: 13px; line-height: 1.45; color: var(--muted); }
.pillar-icon { width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: var(--on-ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.qr-card { display: flex; gap: 20px; align-items: center; padding: 18px; }
.qr-frame { padding: 8px; background: #FFFFFF; border: 1px solid var(--line-2); border-radius: 12px; flex-shrink: 0; line-height: 0; }

.status-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.status-dot.is-ok { background: var(--ok-soft); color: var(--ok); }
.status-dot.is-bad { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .status-dot.is-bad { color: var(--danger-text); } }

/* ---------- pages ---------- */
.page { min-height: 100vh; min-height: 100dvh; padding: 32px clamp(16px, 7vw, 112px) 48px; display: flex; flex-direction: column; gap: 48px; }
.page-header { display: flex; align-items: center; }
.home-grid { display: grid; grid-template-columns: minmax(0, 580px) minmax(0, 516px); gap: clamp(32px, 8vw, 120px); align-items: start; }
.page-center { align-items: center; }
.page-center .page-header { align-self: flex-start; }
.join-card { width: min(560px, 100%); padding: 32px 36px; border-radius: 24px; box-shadow: var(--shadow-lg); }
.room-code { font-family: var(--font-mono); font-weight: 500; font-size: clamp(28px, 4vw, 36px); letter-spacing: -0.01em; }
.who-inside { min-height: 64px; display: flex; align-items: center; }
.who-row { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; width: 100%; }
.who-empty { width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed var(--line-3); display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.page-narrow section { max-width: 580px; }
.page-narrow { padding-top: 32px; }
.split { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 536px); gap: clamp(32px, 8vw, 120px); align-items: start; }
.warn-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--danger-soft); color: var(--danger); display: flex; align-items: center; justify-content: center; }
.check-list { display: flex; flex-direction: column; }
.check-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.check-state { font-size: 12px; font-weight: 600; }
.check-state.is-ok { color: var(--ok); }
.check-state.is-bad { color: var(--danger-text); }
.howto-row { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.howto-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--ground); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tips { display: flex; flex-direction: column; gap: 14px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; }
.tip-num { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rings { color: var(--line-3); line-height: 0; }
.done-list, .erase-list { display: flex; flex-direction: column; gap: 10px; }
.done-list li, .erase-list li { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.erase-list { padding: 14px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; }
.show-on-mobile { display: none; }

@media (max-width: 820px) {
  .page { padding: 20px 20px 28px; gap: 28px; }
  .home-grid, .split { grid-template-columns: minmax(0, 1fr); }
  .tagline { display: none; }
  .show-on-mobile { display: inline-flex; }
  .link-input, .link-row .btn { height: 50px; }
  .link-row { flex-wrap: wrap; }
  .link-row .link-input { flex-basis: 100%; }
  .link-row .btn { flex: 1; }
  .promise { padding: 20px; border-radius: 18px; }
  .join-card { padding: 22px 20px; }
  .qr-card { padding: 14px; }
}

/* ---------- toasts & dialogs ---------- */
.toasts { position: fixed; z-index: 60; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: toast-in 180ms ease-out;
}
.toast-warn { border-left: 4px solid var(--danger); }
.toast-body { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.toast-body strong { font-size: 14px; }
.toast-body span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: 180ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(27, 26, 23, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 32px; }
.dialog-actions { justify-content: flex-end; border-top: 1px solid var(--line-2); padding-top: 18px; }
.dark-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--night); color: var(--night-text); display: flex; align-items: center; justify-content: center; }
@media (max-width: 820px) {
  .backdrop { align-items: flex-end; padding: 0; }
  .dialog { border-radius: 22px 22px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); }
  /* Dialogs you type into sit at the top, so the on-screen keyboard can't cover them. */
  .backdrop:has(.dialog-rename) { align-items: flex-start; }
  .dialog-rename { border-radius: 0 0 22px 22px; padding: calc(20px + env(safe-area-inset-top)) 20px 20px; }
  .dialog-rename .lead-sm { display: none; }
  .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
}

/* ================================================================ room */

.room { position: fixed; inset: 0; overflow: hidden; --panel-w: max(352px, 33vw); --panel-space: calc(var(--panel-w) + 16px); }
.room.panel-collapsed { --panel-space: 0px; }
.room.panel-collapsed .panel, .room.panel-collapsed .panel-resize { display: none; }
.room.is-resizing, .room.is-resizing * { user-select: none; cursor: col-resize !important; }
.board { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.board-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.board.tool-select .board-canvas { cursor: grab; }
.board.is-panning .board-canvas { cursor: grabbing; }
.board.tool-text .board-canvas { cursor: text; }
.board.tool-eraser .board-canvas { cursor: cell; }
.board-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.board-cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.cnote { position: absolute; left: 0; top: 0; width: max-content; max-width: 360px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.board.tool-select .cnote, .board.tool-text .cnote { pointer-events: auto; }
.board.tool-select .cnote { cursor: grab; }
.cnote-tag { align-self: flex-start; font-size: 12px; font-weight: 600; color: var(--on-peer); background: var(--pc); padding: 2px 8px; border-radius: 6px; }
/* Who wrote a note only shows while you hover it or move it around. */
.cnote .cnote-tag { opacity: 0; transition: opacity 120ms; }
.cnote:hover .cnote-tag, .cnote.is-hover .cnote-tag, .cnote.is-dragging .cnote-tag { opacity: 1; }
.cnote.has-width { max-width: none; min-width: min-content; } /* never narrower than the longest word */
.cnote-tag { white-space: nowrap; }
.cnote-resize {
  display: none; position: absolute; top: 24px; bottom: 0; right: calc(-8px / var(--zoom, 1)); width: calc(16px / var(--zoom, 1));
  cursor: ew-resize; pointer-events: auto; touch-action: none; align-items: center; justify-content: center;
}
.cnote-resize::after { content: ''; width: calc(4px / var(--zoom, 1)); height: min(48px, 70%); border-radius: 2px; background: var(--pc); opacity: 0.7; }
.board.tool-select .cnote:hover .cnote-resize, .board.tool-text .cnote:hover .cnote-resize,
.cnote.is-local-edit .cnote-resize, .cnote.is-resizing .cnote-resize { display: flex; }
.cnote-text { font-size: var(--fs, 18px); line-height: 1.45; white-space: pre-wrap; overflow-wrap: break-word; min-width: 24px; min-height: 26px; padding: 6px 8px; border-radius: 8px; border: 1.5px solid transparent; outline: none; }
.cnote.is-editing .cnote-text { border: 1.5px dashed var(--pc); background: color-mix(in srgb, var(--surface) 70%, transparent); }
.cnote-text[contenteditable='true'], .cnote-text[contenteditable='plaintext-only'] { cursor: text; pointer-events: auto; }
.cnote.is-dragging, .file-card.is-dragging { opacity: 0.85; cursor: grabbing; }

.file-card { cursor: grab; }
.file-card button { cursor: pointer; }
.file-card.is-dragging, .image-pending.is-dragging { cursor: grabbing; }
.image-pending { cursor: grab; }
.image-pending button { cursor: pointer; }
.image-pending-hide { position: absolute; top: 6px; right: 6px; }
.nowrap { white-space: nowrap; }
.file-row.is-hidden-on-canvas { border-style: dashed; }
.file-card { position: absolute; left: 0; top: 0; width: 272px; pointer-events: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.board.tool-select .file-card { cursor: grab; }
.file-body { display: flex; flex-direction: column; gap: 10px; }
.file-head { display: flex; gap: 10px; align-items: center; }
.file-icon { width: 40px; height: 48px; border-radius: 8px; background: color-mix(in srgb, var(--pc) 14%, var(--surface)); color: var(--pc); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-offer-line { font-size: 13px; }
.file-warning { font-size: 12px; line-height: 1.45; color: var(--muted); }
.file-status { font-size: 12px; color: var(--muted); }
.progress { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--peer-violet); transition: width 120ms; }
.tone-ok { color: var(--ok); }
.tone-wait { color: var(--muted); }
.tone-warn { color: var(--gold); }
.tone-bad { color: var(--danger-text); }

/* Images: the picture sits under the ink; its controls live in the layer above. */
.board-images { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.board-image { position: absolute; left: 0; top: 0; display: block; user-select: none; border-radius: 4px; box-shadow: var(--shadow); background: var(--surface-2); }
.image-chrome { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 4px; }
.board.tool-select .image-chrome.is-active { z-index: 2; } /* its toolbar above overlapping notes */
.image-pending {
  position: absolute; inset: 0; pointer-events: auto; overflow: hidden; padding: 12px; border-radius: 8px;
  background: var(--surface-2); border: 1.5px dashed var(--line-3); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.image-pending > .truncate { max-width: 100%; }
.image-pending svg { color: var(--muted); }
.image-toolbar {
  position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 6px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  transform: scale(calc(1 / var(--zoom, 1))); transform-origin: top right;
  opacity: 0; pointer-events: none; transition: opacity 120ms;
}
.board.tool-select .image-chrome.is-active .image-toolbar, .image-chrome:focus-within .image-toolbar { opacity: 1; pointer-events: auto; }
.image-tag { font-size: 12px; font-weight: 600; color: var(--on-peer); background: var(--pc); padding: 3px 8px; border-radius: 7px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.image-tool { width: 36px; height: 36px; border-radius: 9px; }
/* Selection (Select tool): outline, delete/hide button top-right, resize handle bottom-right. */
.selection { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; border-radius: 6px; outline: calc(1.5px / var(--zoom, 1)) dashed var(--peer-blue); }
.selection-delete {
  position: absolute; top: 0; right: 0; width: 30px; height: 30px; border-radius: 50%; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line-3); box-shadow: var(--shadow); transform: translate(50%, -50%) scale(calc(1 / var(--zoom, 1)));
}
.selection-delete[data-kind='delete']:hover { background: var(--danger); border-color: var(--danger); color: #FFFFFF; }
.selection-delete[data-kind='hide']:hover { border-color: var(--ink); }
.selection-resize {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: var(--surface); border: 2px solid var(--peer-blue); cursor: nwse-resize; transform: translate(50%, 50%) scale(calc(1 / var(--zoom, 1)));
}

.cursor { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 2px; transition: transform 60ms linear; }
.cursor-arrow path { fill: var(--pc); stroke: var(--ground); stroke-width: 1.5; stroke-linejoin: round; }
.cursor-label { margin-top: 14px; font-size: 12px; font-weight: 600; color: var(--on-peer); background: var(--pc); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }

/* top chrome */
.room-top-left { position: absolute; left: var(--gutter); top: var(--gutter); display: flex; align-items: center; gap: 10px; z-index: 5; }
.brand-chip { height: 44px; padding: 0 14px; background: var(--ink); color: var(--on-ink); border-radius: 12px; display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.room-pill { height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; gap: 12px; font-size: 15px; }
.pill-sep { width: 1px; height: 20px; background: var(--line); }
.pill-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lock-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--danger-text); background: var(--danger-soft); padding: 2px 8px; border-radius: 6px; }
.p2p-chip { height: 32px; padding: 0 10px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.room-top-right { position: absolute; right: calc(var(--gutter) + var(--panel-space)); top: var(--gutter); display: flex; gap: 8px; align-items: center; z-index: 5; }
.me-chip { height: 44px; padding: 0 12px 0 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; gap: 10px; text-align: left; }
.me-chip > svg { color: var(--muted); }
.me-chip:hover { border-color: var(--ink); }
.me-chip:hover > svg { color: var(--ink); }
.me-chip-text { display: flex; flex-direction: column; line-height: 1.15; max-width: 200px; }
.me-chip-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip-text strong { font-size: 14px; }

/* tool dock */
.dock {
  position: absolute; left: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 5;
  width: 60px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.dock-tools { display: contents; }
.dock-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dock-btn:hover { background: var(--line-2); }
.dock-btn.is-active { background: var(--ink); color: var(--on-ink); }
.dock-sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; flex-shrink: 0; }
.dock-inks { display: flex; flex-direction: column; gap: 2px; }
.swatch { width: 44px; height: 34px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.swatch span { width: 22px; height: 22px; border-radius: 50%; background: var(--swatch); }
.swatch.is-active span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.ink-toggle { display: none; }
.ink-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--swatch, var(--ink)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.flyout { position: absolute; left: calc(100% + 10px); top: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 160px; }
.flyout-item { height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 14px; text-align: left; }
.flyout-item:hover { background: var(--line-2); }
.flyout-item.is-active { background: var(--ink); color: var(--on-ink); }
.ink-menu { flex-direction: row; min-width: 0; }

.zoom { position: absolute; left: var(--gutter); bottom: var(--gutter); z-index: 5; height: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; }
.zoom .icon-btn { height: 42px; }
.zoom-label { min-width: 56px; height: 42px; border: 0; background: transparent; font-size: 13px; font-weight: 500; }

/* side panel */
.panel {
  position: absolute; right: var(--gutter); top: var(--gutter); bottom: var(--gutter); width: var(--panel-w); z-index: 6;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head { padding: 12px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 8px; }
.panel-grabber, .panel-close { display: none; }
/* The tab on the panel's left edge: hide while open; Chat / People / Files on the screen edge while hidden. */
.panel-rail {
  position: absolute; z-index: 8; top: 50%; transform: translateY(-50%);
  right: calc(var(--gutter) + var(--panel-space) - 16px);
  padding: 4px; border: 1px solid var(--line); border-right: 0; border-radius: 14px 0 0 14px;
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.room.panel-collapsed .panel-rail { right: 0; padding: 6px; gap: 6px; }
.rail-btn {
  position: relative; width: 36px; height: 64px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.room.panel-collapsed .rail-btn { width: 48px; height: 48px; color: var(--ink); }
.rail-btn:hover { background: var(--line-2); color: var(--ink); }
.rail-btn .badge-count { top: -4px; left: -6px; right: auto; }
.panel-resize {
  position: absolute; z-index: 7; top: calc(var(--gutter) + 24px); bottom: calc(var(--gutter) + 24px);
  /* Sits just inside the panel's left edge, so it never covers anything on the canvas. */
  right: calc(var(--gutter) + var(--panel-w) - 12px); width: 12px; cursor: col-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center; outline: none;
}
.panel-resize::after { content: ''; width: 4px; height: 44px; border-radius: 2px; background: var(--line-3); opacity: 0; transition: opacity 120ms; }
.panel-resize:hover::after, .panel-resize:focus-visible::after, .room.is-resizing .panel-resize::after { opacity: 1; background: var(--ink); }
.panel-resize:focus-visible { outline: 2px solid var(--peer-blue); outline-offset: -2px; border-radius: 6px; }
.tabs { flex: 1; display: flex; gap: 4px; padding: 4px; background: var(--ground); border-radius: 12px; }
.tab { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 600; white-space: nowrap; }
.tab.is-active { background: var(--surface); box-shadow: 0 1px 3px rgba(27, 26, 23, 0.12); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.chat-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px dashed var(--line-3); border-radius: 12px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.chat-note svg { flex-shrink: 0; margin-top: 1px; }
.chat-list { display: flex; flex-direction: column; gap: 14px; }
.chat-sys { text-align: center; font-size: 12px; color: var(--muted); }
.chat-msg { display: flex; gap: 10px; }
.chat-meta { font-size: 13px; display: flex; gap: 6px; }
.chat-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.chat-mine { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.bubble { max-width: 80%; background: var(--ink); color: var(--on-ink); font-size: 14px; line-height: 1.45; padding: 10px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; word-break: break-word; }
.chat-time { font-size: 11px; color: var(--muted); }
.composer { padding: 12px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; align-items: center; }
.composer .input { flex: 1; }
.pane-intro { line-height: 1.5; }
.people-list { display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.person strong { font-size: 14px; }
.person-status { font-size: 12px; }
.files-list { display: flex; flex-direction: column; gap: 10px; }
.drop-hint { border: 1.5px dashed var(--line-3); border-radius: 12px; padding: 18px; text-align: center; font-size: 13px; color: var(--muted); line-height: 1.5; }

.chat-fab {
  display: none; position: absolute; right: 16px; bottom: 100px; z-index: 5; width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--ink); color: var(--on-ink); align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(27, 26, 23, 0.22);
}
.badge-count { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ground); }

/* invite popover */
.invite {
  position: absolute; left: 290px; top: 80px; width: 420px; z-index: 20; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.invite-qr { display: flex; gap: 16px; align-items: center; }
.invite-backdrop { position: absolute; inset: 0; z-index: 19; background: rgba(27, 26, 23, 0.38); }

/* empty room */
.empty-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(calc(-50% - (var(--panel-space) + 8px) / 2), -50%); width: min(520px, calc(100vw - 32px)); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; pointer-events: none;
}
.empty-hint .btn { pointer-events: auto; }
.rings-small { width: 96px; height: 96px; border-radius: 50%; border: 1.5px dashed var(--line-3); display: flex; align-items: center; justify-content: center; }
.rings-small::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 20px var(--ground), 0 0 0 21.5px var(--line-3); }

.drop-overlay { position: absolute; inset: 0; z-index: 30; background: color-mix(in srgb, var(--ground) 70%, transparent); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 40px; border: 2px dashed var(--ink); border-radius: 20px; background: var(--surface); }

/* joining overlay */
.connecting { position: absolute; inset: 0; z-index: 40; background: color-mix(in srgb, var(--ground) 82%, transparent); display: flex; align-items: flex-start; justify-content: center; padding: 88px 16px 16px; overflow: auto; }
.connecting-card { width: min(500px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.connecting-card > .btn { align-self: flex-start; }
.steps { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-done .step-icon { background: var(--ok-soft); color: var(--ok); }
.step-now .step-icon { background: var(--ink); color: var(--on-ink); }
.step-now .step-icon svg { animation: spin 1s linear infinite; }
.step-todo .step-icon { border: 1.5px dashed var(--line-3); }
.step-todo strong { color: var(--muted); }
.connect-peers { border-top: 1px solid var(--line-2); padding-top: 6px; display: flex; flex-direction: column; }
.connect-peer { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- room: mid-size screens ---------- */
/* The panel takes a third of the width, so the "You are" chip only fits on wide screens (it's also in People). */
@media (max-width: 1480px) and (min-width: 821px) {
  .me-chip { padding: 0 10px 0 6px; gap: 6px; }
  .me-chip-text { display: none; }
}
@media (max-width: 1180px) and (min-width: 821px) {
  .p2p-chip span { display: none; }
  .brand-chip span { display: none; }
}

/* ---------- room: short desktop screens ---------- */
@media (max-height: 860px) and (min-width: 821px) {
  .dock { gap: 2px; padding: 6px 8px; }
  .dock-btn { height: 38px; }
  .swatch { height: 28px; }
  .dock-sep { margin: 3px 0; }
}
@media (max-height: 700px) and (min-width: 821px) {
  .dock-inks { display: none; }
  .ink-toggle { display: flex; }
  .flyout { top: auto; bottom: 0; }
}

/* ---------- room: phones ---------- */
@media (max-width: 820px) {
  .room { --gutter: 12px; }
  .brand-chip, .zoom, .dock-inks { display: none; }
  .input { font-size: 16px; } /* smaller text makes iOS zoom the page when the field is focused */
  .me-chip { width: 44px; padding: 0; justify-content: center; }
  .me-chip-text, .me-chip > svg { display: none; }
  .room-top-left { left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); gap: 8px; }
  .room-pill { padding: 0 12px; gap: 8px; font-size: 14px; min-width: 0; }
  .invite-btn { margin-left: auto; width: 44px; padding: 0; }
  .invite-btn span { display: none; }
  .p2p-chip { position: absolute; top: 52px; left: 0; }
  .room-top-right { right: 12px; top: calc(12px + env(safe-area-inset-top)); }
  .room-top-left { right: calc(12px + (44px + 8px) * 2); }

  .dock {
    left: 12px; right: 12px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); transform: none; width: auto;
    flex-direction: row; gap: 0; padding: 6px 8px; border-radius: 20px; overflow-x: auto; scrollbar-width: none; justify-content: space-between;
  }
  .dock::-webkit-scrollbar { display: none; }
  .dock-sep { display: none; }
  .dock-btn { width: 38px; }
  .ink-toggle { display: flex; }
  .flyout { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(84px + env(safe-area-inset-bottom)); flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .shape-menu .flyout-item span { display: none; }

  .chat-fab { display: flex; bottom: calc(90px + env(safe-area-inset-bottom)); }
  .panel {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; height: min(78dvh, 640px); border-radius: 22px 22px 0 0;
    transform: translateY(105%); transition: transform 220ms ease; padding-bottom: env(safe-area-inset-bottom); z-index: 25;
  }
  .room.panel-open .panel { transform: none; box-shadow: 0 -8px 30px rgba(27, 26, 23, 0.2); }
  .room.panel-open::after { content: ''; position: absolute; inset: 0; z-index: 24; background: rgba(27, 26, 23, 0.38); }
  .panel-head { position: relative; padding-top: 22px; }
  .panel-grabber { display: block; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 5px; border-radius: 3px; background: var(--line-3); }
  .panel-close { display: inline-flex; }
  .panel-rail, .panel-resize { display: none; }
  .room.panel-collapsed .panel { display: flex; }
  .tab { font-size: 13px; }

  .invite { left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow: auto; }
  .invite-qr { flex-direction: column; text-align: center; }
  .empty-hint { transform: translate(-50%, -60%); }
  .empty-hint .lead { font-size: 15px; }
  .connecting { padding-top: 24px; }
  .toasts { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
