/* Hind Siliguri, SIL Open Font License 1.1 (see fonts/OFL.txt) */
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/hind-siliguri-bengali-400-normal.woff2) format("woff2");unicode-range:U+0951-0952,U+0964-0965,U+0980-09FE,U+1CD0,U+1CD2,U+1CD5-1CD6,U+1CD8,U+1CE1,U+1CEA,U+1CED,U+1CF2,U+1CF5-1CF7,U+200C-200D,U+20B9,U+25CC,U+A8F1}
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/hind-siliguri-latin-ext-400-normal.woff2) format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/hind-siliguri-latin-400-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/hind-siliguri-bengali-600-normal.woff2) format("woff2");unicode-range:U+0951-0952,U+0964-0965,U+0980-09FE,U+1CD0,U+1CD2,U+1CD5-1CD6,U+1CD8,U+1CE1,U+1CEA,U+1CED,U+1CF2,U+1CF5-1CF7,U+200C-200D,U+20B9,U+25CC,U+A8F1}
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/hind-siliguri-latin-ext-600-normal.woff2) format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Hind Siliguri";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/hind-siliguri-latin-600-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
/* Fredoka, SIL Open Font License 1.1 (see fonts/OFL-Fredoka.txt) */
@font-face{font-family:"Fredoka";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/fredoka-latin-600-normal.woff2) format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
/* ictoons Whiteboard
   Layout: the board fills the screen under a slim top bar; tools float in a dock (bottom, left or right);
   options open in a popup next to the dock. Brand: ictoons navy with a chalk blue accent. */
:root {
  --chrome: #eef1f8;      /* app background */
  --panel: #ffffff;       /* bars, dock, popups */
  --panel-2: #f2f5fb;     /* hover */
  --press: #e3e8f4;
  --ink: #17203b;
  --ink-2: #56607c;
  --line: #d6dcea;
  --accent: #3a5fd9;      /* active tool */
  --accent-ink: #ffffff;
  --accent-soft: #e4eafc;
  --brand: #202f5b;       /* ictoons navy */
  --brand-line: #6e8ce4;
  --brand-ink: #eaf1ff;
  --danger: #c0362c;
  --ok: #1e8b4d;
  --warn: #b06a00;
  --notice-bg: #fff5dc;
  --notice-line: #edd396;
  --notice-ink: #4d3500;
  --scrim: rgba(15, 20, 40, 0.45);
  --toast-bg: #17203b;
  --toast-ink: #ffffff;
  --overlay-bg: rgba(18, 24, 44, 0.62);
  --overlay-fg: #ffffff;
  --focus: #3a5fd9;
  --swatch-ring: rgba(23, 32, 59, 0.25);
  --shadow: 0 10px 30px rgba(23, 32, 59, 0.16), 0 2px 6px rgba(23, 32, 59, 0.08);
  --shadow-sm: 0 2px 8px rgba(23, 32, 59, 0.10);
  --logo-chalk: #ffffff;
  --logo-ink: #202f5b; --logo-accent: #3a5fd9; --logo-glow: none; /* full screen ICToons Board logo */
  --font-ui: "Hind Siliguri", "Noto Sans Bengali", "Nirmala UI", system-ui, "Segoe UI", sans-serif;
  --tool: 52px;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chrome: #0d1222; --panel: #161d33; --panel-2: #1f2844; --press: #28324f;
    --ink: #e6ebf8; --ink-2: #9ea9c6; --line: #2a3555;
    --accent: #7d9bf2; --accent-ink: #0d1222; --accent-soft: #24305a;
    --brand: #202f5b; --brand-line: #6e8ce4; --brand-ink: #eaf1ff;
    --danger: #ff7a70; --ok: #4cd08a; --warn: #f2b14a;
    --notice-bg: #2a2412; --notice-line: #5a4a1c; --notice-ink: #f4e2b0;
    --scrim: rgba(0, 0, 0, 0.6); --toast-bg: #e6ebf8; --toast-ink: #0d1222;
    --focus: #9db4ff; --swatch-ring: rgba(230, 235, 248, 0.4);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --logo-ink: #ffffff; --logo-accent: #8aa6ff; --logo-glow: 0 0 11px rgba(120, 160, 255, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --chrome: #0d1222; --panel: #161d33; --panel-2: #1f2844; --press: #28324f;
  --ink: #e6ebf8; --ink-2: #9ea9c6; --line: #2a3555;
  --accent: #7d9bf2; --accent-ink: #0d1222; --accent-soft: #24305a;
  --brand: #202f5b; --brand-line: #6e8ce4; --brand-ink: #eaf1ff;
  --danger: #ff7a70; --ok: #4cd08a; --warn: #f2b14a;
  --notice-bg: #2a2412; --notice-line: #5a4a1c; --notice-ink: #f4e2b0;
  --scrim: rgba(0, 0, 0, 0.6); --toast-bg: #e6ebf8; --toast-ink: #0d1222;
  --focus: #9db4ff; --swatch-ring: rgba(230, 235, 248, 0.4);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --logo-ink: #ffffff; --logo-accent: #8aa6ff; --logo-glow: 0 0 11px rgba(120, 160, 255, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--chrome);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
svg { flex: none; }

.app { position: relative; height: 100%; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------- buttons ---------- */
.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  cursor: pointer; touch-action: manipulation;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn:active { background: var(--press); }
.icon-btn:disabled { opacity: 0.32; cursor: default; background: transparent; }
.icon-btn.big { width: 52px; height: 48px; }
.icon-btn.big svg { width: 27px; height: 27px; }
.icon-btn.small { width: 40px; height: 40px; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: 1rem; cursor: pointer; touch-action: manipulation;
}
.btn svg { width: 22px; height: 22px; }
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.big { min-height: 56px; padding: 0 26px; font-size: 1.06rem; border-radius: 14px; }
.btn.small { min-height: 44px; padding: 0 16px; }
/* ictoons button style: navy fill, blue border, soft glow on hover */
.btn.primary { background: var(--brand); border-color: var(--brand-line); color: var(--brand-ink); border-radius: 11px; }
.btn.primary:hover { background: var(--brand); box-shadow: 0 0 0 3px rgba(110, 140, 228, 0.35), 0 6px 18px rgba(32, 47, 91, 0.35); transform: translateY(-1px); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }

/* ---------- home ---------- */
.home-bar {
  display: flex; align-items: center; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, 3vw) 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.logo { width: 44px; height: 44px; }
.logo-bg { fill: var(--brand); }
.logo-chalk { fill: none; stroke: var(--logo-chalk); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.logo-dot { fill: var(--brand-line); }
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 1.32rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; }
.brand-text p { margin: 2px 0 0; color: var(--ink-2); font-size: 0.92rem; line-height: 1.1; }
.home-top-actions { display: flex; align-items: center; gap: 6px; }

.status-chip, .save-status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; color: var(--ink-2); white-space: nowrap; }
.status-chip { min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; margin-right: 6px; background: transparent; cursor: pointer; font: inherit; font-size: 0.86rem; }
.status-chip:hover { background: var(--panel-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
[data-state="saving"] .dot, [data-state="unsaved"] .dot { background: var(--accent); }
[data-state="offline"] .dot, [data-state="memory"] .dot { background: var(--warn); }
[data-state="error"] .dot { background: var(--danger); }
[data-state="error"] .label { color: var(--danger); }

.home-main { flex: 1; overflow: auto; padding-block: 24px 48px; padding-inline: max(16px, 3vw); }
.home-inner { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.section-title { margin: 8px 0 -4px; font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }

.notice {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--notice-bg); border: 1px solid var(--notice-line); color: var(--notice-ink);
}
.notice-icon svg { width: 24px; height: 24px; }
.notice-text { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.notice .btn { background: transparent; border-color: var(--notice-line); color: var(--notice-ink); }
.notice.moved { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.notice.moved .btn { border-color: var(--accent); color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 18px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card:active { transform: scale(0.99); }
.card-thumb { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #ffffff; border-bottom: 1px solid var(--line); }
.card-body { display: flex; align-items: center; gap: 4px; padding: 10px 6px 10px 14px; }
.card-text { flex: 1; min-width: 0; }
.card-name { font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.empty { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding: 28px; border: 2px dashed var(--line); border-radius: 18px; }
.empty-art { width: 160px; max-width: 100%; }
.ea-board { fill: var(--panel); stroke: var(--line); stroke-width: 3; }
.ea-ink { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.ea-shape { fill: none; stroke: var(--brand-line); stroke-width: 3; }
.ea-leg { stroke: var(--line); stroke-width: 4; stroke-linecap: round; }
.empty-title { margin: 0; font-size: 1.15rem; font-weight: 600; }
.empty-sub { margin: 4px 0 0; color: var(--ink-2); }

.drop-hint { position: absolute; inset: 12px; border: 3px dashed var(--accent); border-radius: 20px; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.2rem; font-weight: 600; color: var(--accent); pointer-events: none; z-index: 20; }

/* ---------- board: top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 2px;
  min-height: 60px; padding: env(safe-area-inset-top, 0px) 8px 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: relative; z-index: 6;
}
/* left and right halves share the width equally, so the full screen logo sits in the true middle
   when there is room, and moves aside (never overlaps) when the buttons need the space */
.tb-side { flex: 1 1 0; display: flex; align-items: center; gap: 2px; }
.tb-left { min-width: 0; }
.tb-right { justify-content: flex-end; }
/* Full screen only: the ictoons logo from the ictoons simulators (animated ICToons wordmark) with "Board"
   beside it on the same baseline and cap height, straight on the bar (no box). Every 30 s it fades to
   "ictoons.com" and back: the outgoing layer fades out first, the incoming one follows 1.1 s later. */
.tb-logo { flex: none; display: inline-grid; align-items: center; justify-items: center; margin: 0 4px; transition: transform 0.2s ease; user-select: none; -webkit-user-select: none; }
.tb-logo:hover { transform: scale(1.05); }
.tb-logo > .tb-emu-layer { grid-area: 1 / 1; transition: opacity 1.3s cubic-bezier(0.45, 0, 0.55, 1); will-change: opacity; }
.tb-emu-logo { opacity: 1; transition-delay: 1.1s; }
.tb-emu-text {
  opacity: 0; transition-delay: 0s; line-height: 1;
  font-family: "Fredoka", "Poppins", "Segoe UI", system-ui, sans-serif; font-weight: 600; font-size: 19px; letter-spacing: 0.2px;
  color: var(--logo-ink); white-space: nowrap; text-shadow: var(--logo-glow);
}
.tb-emu-dot { color: var(--logo-accent); }
.tb-logo.show-text .tb-emu-logo { opacity: 0; transition-delay: 0s; }
.tb-logo.show-text .tb-emu-text { opacity: 1; transition-delay: 1.1s; }
/* 24 px tall as on the simulators; lifted 3 px so the letters, not the eyebrows, sit on the bar's middle line */
.tb-emu-svg { display: block; height: 24px; width: auto; margin-top: -3px; }
.tb-emu-word { fill: var(--logo-ink); }
.tb-emu-board { fill: var(--logo-accent); font-family: "Fredoka", "Poppins", "Segoe UI", system-ui, sans-serif; font-weight: 600; }
.title-block { display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 2px; }
.board-name {
  min-height: 44px; min-width: 0; border: 0; background: transparent; padding: 0 10px; border-radius: 10px;
  font-weight: 600; font-size: 1.06rem; text-align: left; cursor: pointer;
  max-width: 30vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-name:hover { background: var(--panel-2); }
.save-status { font-size: 0.84rem; gap: 6px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-family: inherit; }
.save-status:hover { background: var(--panel-2); }
.save-status .dot { width: 8px; height: 8px; }
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 4px; border-left: 1px solid var(--line); }
.tb-actions { padding-right: 0; }
.page-num { min-width: 58px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- board: workspace ---------- */
/* clip, not hidden: a hidden box can still be scrolled by the browser, which shifts the whole board */
.workspace { flex: 1; display: flex; min-height: 0; position: relative; overflow: hidden; overflow: clip; }
.stage-wrap { flex: 1; position: relative; overflow: hidden; overflow: clip; min-width: 0; }
.stage {
  position: absolute; inset: 0; background: #ffffff;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: crosshair; overscroll-behavior: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage[data-tool="hand"], .stage.space-pan { cursor: grab; }
.stage.panning { cursor: grabbing; }
.stage[data-tool="text"] { cursor: text; }
.stage[data-tool="select"] { cursor: default; }
.stage[data-tool="laser"] { cursor: none; } /* the laser dot replaces the mouse arrow */

/* drag handle shown while typing in a text box */
.text-grip {
  position: absolute; z-index: 4; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 12px;
  border: 2px solid var(--accent); background: var(--panel); color: var(--accent);
  box-shadow: var(--shadow-sm); cursor: grab; touch-action: none;
}
.text-grip svg { width: 22px; height: 22px; }
.text-grip.dragging { cursor: grabbing; background: var(--accent); color: var(--accent-ink); }

/* actions for selected objects */
.selbar {
  position: absolute; z-index: 5; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.selbar .danger { color: var(--danger); }
.sel-count { padding: 0 10px 0 8px; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* import progress */
.progress {
  position: fixed; z-index: 65; left: 50%; top: 76px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 32px); padding: 10px 10px 10px 18px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.prog-text { font-weight: 600; min-width: 0; }
.prog-bar { width: 160px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.prog-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.text-editor {
  position: absolute; z-index: 3; margin: 0; padding: 0; border: 0;
  background: transparent; resize: none; overflow: hidden; white-space: pre;
  font-family: "Hind Siliguri", "Noto Sans Bengali", "Nirmala UI", "Vrinda", sans-serif; font-weight: 400;
  outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 2px;
  min-width: 1em; caret-color: var(--accent);
}

/* ---------- dock ---------- */
.dock {
  position: absolute; z-index: 5;
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  /* --dsx/--dsy: set while the page list is kept open, so the toolbar glides out of its way */
  transform: translate(calc(-50% + var(--dsx, 0px)), var(--dsy, 0px)); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock[data-side="left"], .dock[data-side="right"] {
  flex-direction: column; top: 50%; bottom: auto; transform: translate(var(--dsx, 0px), calc(-50% + var(--dsy, 0px)));
  max-width: none; max-height: calc(100% - 24px - var(--dcut, 0px)); overflow-x: visible; overflow-y: auto;
}
.dock[data-side="left"] { left: 12px; }
.dock[data-side="right"] { left: auto; right: 12px; }
.tool {
  position: relative; width: var(--tool); height: var(--tool); flex: none;
  display: grid; place-items: center; border: 0; border-radius: 14px;
  background: transparent; color: var(--ink); cursor: pointer; touch-action: manipulation;
}
.tool svg { width: 26px; height: 26px; }
.tool:hover { background: var(--panel-2); }
.tool:active { background: var(--press); }
.tool.active { background: var(--accent); color: var(--accent-ink); }
.tdot { position: absolute; right: 8px; bottom: 8px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--swatch-ring); }
.tool.active .tdot { border-color: var(--accent); }
.dock-sep { width: 1px; height: 32px; background: var(--line); margin: 0 4px; flex: none; }
.dock[data-side="left"] .dock-sep, .dock[data-side="right"] .dock-sep { width: 32px; height: 1px; margin: 4px 0; }
.color-btn .swatch { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--swatch-ring); }

/* ---------- zoom ---------- */
.zoombox {
  position: absolute; z-index: 4; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; padding: 4px; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm);
  transform: translate(var(--zsx, 0px), var(--zsy, 0px)); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.no-anim { transition: none !important; }
.dock[data-side="right"] ~ .zoombox { right: auto; left: 14px; } /* out of the way of a right toolbar */
.zoom-val { min-width: 64px; height: 40px; border: 0; background: transparent; border-radius: 10px; font-weight: 600; font-size: 0.92rem; font-variant-numeric: tabular-nums; cursor: pointer; }
.zoom-val:hover { background: var(--panel-2); }

/* ---------- page strip ----------
   Lies over the board (the board never changes size, so nothing jumps) and slides in from its edge:
   right (default), left or bottom. It opens when the mouse rests at that edge of the board and closes
   when the mouse leaves it, or stays open with the Pages button; the toolbar and zoom glide aside then. */
.workspace { --ps-w: 236px; --ps-h: 156px; }
.pagestrip {
  position: absolute; z-index: 6; display: flex; flex-direction: column;
  background: var(--panel); box-shadow: var(--shadow); visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.4, 0, 1, 1), visibility 0s linear 0.22s; /* slide out */
}
.pagestrip[data-side="right"] { top: 0; bottom: 0; right: 0; width: var(--ps-w); border-left: 1px solid var(--line); transform: translateX(calc(100% + 32px)); }
.pagestrip[data-side="left"] { top: 0; bottom: 0; left: 0; width: var(--ps-w); border-right: 1px solid var(--line); transform: translateX(calc(-100% - 32px)); }
.pagestrip[data-side="bottom"] { left: 0; right: 0; bottom: 0; height: var(--ps-h); flex-direction: row; border-top: 1px solid var(--line); transform: translateY(calc(100% + 32px)); }
.pagestrip.open { transform: none; visibility: visible; transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s; } /* slide in */
.ps-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.ps-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.pthumb { position: relative; display: block; width: 100%; padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: #ffffff; cursor: pointer; }
.pthumb canvas { display: block; width: 100%; aspect-ratio: 16 / 10; }
.pthumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pthumb .pnum { position: absolute; left: 6px; bottom: 6px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px; background: var(--overlay-bg); color: var(--overlay-fg); font-size: 0.85rem; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.pthumb-wrap { position: relative; }
.pthumb-del { position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--overlay-bg); color: var(--overlay-fg); display: grid; place-items: center; cursor: pointer; opacity: 0.85; }
.pthumb-del svg { width: 18px; height: 18px; }
.ps-add { margin: 0 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
/* bottom: a row of pages */
.pagestrip[data-side="bottom"] .ps-head { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 10px; border-bottom: 0; border-right: 1px solid var(--line); }
.pagestrip[data-side="bottom"] .ps-list { flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 10px 14px; }
.pagestrip[data-side="bottom"] .pthumb-wrap { flex: none; width: 176px; }
.pagestrip[data-side="bottom"] .ps-add { flex: none; align-self: center; margin: 0 14px 0 0; }

/* ---------- presentation ---------- */
.exit-present {
  position: absolute; z-index: 7; top: 12px; right: 12px;
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px 0 12px;
  border-radius: 22px; border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--overlay-bg); color: var(--overlay-fg); font-weight: 600; cursor: pointer;
  opacity: 0.55; transition: opacity 0.2s;
}
.exit-present svg { width: 18px; height: 18px; }
.exit-present:hover, .exit-present:focus-visible { opacity: 1; }
.presenting .topbar, .presenting .dock, .presenting .zoombox, .presenting .pagestrip, .presenting .selbar { display: none !important; }

/* ---------- layer: popups, menus, dialogs ---------- */
.layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.layer > * { pointer-events: auto; }
.pop {
  position: fixed; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow: auto;
}

.popup { padding: 14px 16px 16px; width: 440px; display: flex; flex-direction: column; gap: 14px; }
.popup-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.popup-title { font-weight: 600; font-size: 1.06rem; }
.popup-val { color: var(--ink-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.colors { display: grid; grid-template-columns: repeat(8, 44px); gap: 8px; justify-content: space-between; }
.cswatch {
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--swatch-ring); display: grid; place-items: center; touch-action: manipulation;
}
.cswatch svg { width: 22px; height: 22px; }
.cswatch.selected { outline: 3px solid var(--accent); outline-offset: 3px; }
.kinds { display: flex; gap: 8px; }
.kind { width: 56px; height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); display: grid; place-items: center; cursor: pointer; }
.kind svg { width: 26px; height: 26px; }
.kind.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.size-row { display: flex; align-items: center; gap: 14px; }
.size-preview { width: 52px; height: 52px; flex: none; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; background: #ffffff; overflow: hidden; }
.size-dot { border-radius: 50%; }
.size-preview.text-prev { font-weight: 400; line-height: 1; color: #17203b; }

input[type="range"] { flex: 1; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: manipulation; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--accent); }

.menu { padding: 6px; min-width: 250px; display: flex; flex-direction: column; }
.menu-item {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; font-size: 1rem; white-space: nowrap;
}
.menu-item svg { width: 21px; height: 21px; color: var(--ink-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.menu-item:disabled { opacity: 0.4; cursor: default; }
.menu-item .hint { margin-left: auto; padding-left: 16px; color: var(--ink-2); font-size: 0.82rem; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { padding: 8px 14px 4px; font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); }
.bg-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 8px 8px; }
.bg-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: transparent; padding: 4px; border-radius: 12px; cursor: pointer; font-size: 0.82rem; color: var(--ink-2); }
.bg-opt .bg-sw { width: 48px; height: 48px; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--swatch-ring); }
.bg-opt.selected .bg-sw { outline: 3px solid var(--accent); outline-offset: 2px; }
.bg-opt:hover { background: var(--panel-2); }
/* toolbar position: Left / Bottom / Right */
.seg-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px 8px 8px; }
.seg-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 64px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: transparent; color: var(--ink-2); font-size: 0.88rem; cursor: pointer; touch-action: manipulation;
}
.seg-opt svg { width: 24px; height: 24px; color: var(--ink); }
.seg-opt:hover { background: var(--panel-2); }
.seg-opt[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.seg-opt[aria-checked="true"] svg { color: var(--accent); }

.backdrop { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 16px; z-index: 60; }
.dialog { width: min(500px, 100%); background: var(--panel); color: var(--ink); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 32px); overflow: auto; }
.dialog h2 { margin: 0; font-size: 1.22rem; text-wrap: balance; }
.dialog p { margin: 0; color: var(--ink-2); line-height: 1.5; }
.dialog .field { display: flex; flex-direction: column; gap: 6px; }
.dialog label { font-size: 0.88rem; font-weight: 600; color: var(--ink-2); }
.dialog input[type="text"] { height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--chrome); color: var(--ink); font: inherit; font-size: 1.06rem; }
.dialog input[type="text"]:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 0.95rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
kbd { display: inline-block; min-width: 28px; padding: 2px 8px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--chrome); font: inherit; font-size: 0.88rem; font-weight: 600; text-align: center; }

.toasts { position: fixed; z-index: 70; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-ink); box-shadow: var(--shadow); font-size: 0.97rem; animation: toast-in 0.18s ease-out; }
.toast svg { width: 20px; height: 20px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.boot-error { position: fixed; left: 16px; right: 16px; top: 40%; z-index: 100; padding: 16px; border-radius: 14px; background: var(--panel); color: var(--danger); border: 1px solid var(--line); font-weight: 600; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .tb-optional { display: none; }
  .board-name { max-width: 28vw; }
}
@media (max-width: 860px) {
  /* keep the zoom box clear of the centered dock */
  .zoombox { top: 12px; bottom: auto; }
}
@media (max-width: 640px) {
  :root { --tool: 46px; }
  .status-chip .label, .save-status .label { display: none; }
  .board-name { max-width: 34vw; }
  .status-chip { padding: 8px; }
  .zoombox { display: none; }
  #btn-prev, #btn-next { display: none; }
  .page-num { min-width: 44px; }
  .tb-group { padding: 0 2px; }
  .icon-btn.big { width: 46px; }
  .colors { grid-template-columns: repeat(4, 44px); justify-content: start; }
  .tb-logo { margin: 0 2px; }
  .brand-text h1 { font-size: 1.15rem; }
}
@media (max-width: 430px) {
  /* phones: color is reached by tapping the active tool, so the color button and divider go */
  :root { --tool: 44px; }
  .dock { gap: 2px; padding: 4px; }
  .dock-sep, #btn-color, #dock .tool[data-tool="hand"] { display: none; } /* phones: two fingers move the board */
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
