/* ==========================================================================
   quadrille — hand-drawn flowcharts on graph paper
   ========================================================================== */
:root {
  --paper: #fbfaf5;
  --ink: #2b2b2b;
  --ink-soft: #6b6b66;
  --grid-minor: rgba(112, 156, 214, 0.22);
  --grid-major: rgba(112, 156, 214, 0.42);
  --card: rgba(255, 253, 247, 0.96);
  --card-opaque: #fffdf7;
  --card-border: #2b2b2b;
  --accent: #2f5fb3;
  --accent-soft: #b9cff0;
  --warn: #c0392b;
  --yellow: #f2c94c;
  --shadow: 0 2px 0 rgba(43, 43, 43, 0.9), 0 8px 24px rgba(43, 43, 43, 0.12);
  --font-hand: "Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --font-title: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --gs: 20px;     /* grid size (scaled)   */
  --gx: 0px;      /* grid offset x         */
  --gy: 0px;      /* grid offset y         */
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-hand);
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- canvas & graph paper ---------- */
#canvas {
  position: fixed; inset: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--grid-major) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px),
    linear-gradient(to right, var(--grid-minor) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-minor) 1px, transparent 1px);
  background-size:
    calc(var(--gs) * 5) calc(var(--gs) * 5),
    calc(var(--gs) * 5) calc(var(--gs) * 5),
    var(--gs) var(--gs),
    var(--gs) var(--gs);
  background-position: var(--gx) var(--gy);
}
body.nogrid #canvas { background-image: none; }
/* paper styles (Settings → Appearance, or ··· → Paper): dots like a dot grid, or plain paper */
body.paper-dots #canvas { background-image: radial-gradient(var(--grid-major) 1.1px, transparent 1.6px); background-size: var(--gs) var(--gs); }
body.paper-plain #canvas { background-image: none; }
#svg { position: absolute; inset: 0; width: 100%; height: 100%; outline: none; display: block; }
#svg text { user-select: none; }
#overlay { pointer-events: none; }
#overlay .handle, #overlay .arrow-handle { pointer-events: all; }
#svg.dragging #overlay * { pointer-events: none !important; }

/* cursors per tool */
body[data-tool="select"] #svg { cursor: default; }
body[data-tool="hand"] #svg { cursor: grab; }
body.panning #svg { cursor: grabbing !important; }
body[data-tool="shape"] #svg, body[data-tool="note"] #svg, body[data-tool="arrow"] #svg,
body[data-tool="badge"] #svg, body[data-tool="sticker"] #svg, body[data-tool="comment"] #svg,
body[data-tool="image"] #svg { cursor: crosshair; }
body[data-tool="text"] #svg { cursor: text; }
body[data-tool="pen"] #svg { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M4 20l3-1 11-11-2-2L5 17z' fill='%23fff' stroke='%232b2b2b' stroke-width='1.6'/%3E%3C/svg%3E") 4 20, crosshair; }
body[data-tool="eraser"] #svg { cursor: cell; }
body[data-tool="laser"] #svg { cursor: none; }
.el { cursor: move; }
body:not([data-tool="select"]) .el { cursor: inherit; }
.handle { cursor: nwse-resize; }
.handle[data-handle="n"], .handle[data-handle="s"] { cursor: ns-resize; }
.handle[data-handle="e"], .handle[data-handle="w"] { cursor: ew-resize; }
.handle[data-handle="ne"], .handle[data-handle="sw"] { cursor: nesw-resize; }
.arrow-handle { cursor: crosshair; }

/* ---------- inline text editor ---------- */
#editor {
  position: absolute;
  margin: 0; padding: 0;
  border: 0; outline: none;
  background: transparent;
  resize: none; overflow: hidden;
  font-family: var(--font-hand);
  color: var(--ink);
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
  z-index: 5;
}

/* ---------- UI cards ---------- */
.ui { position: fixed; z-index: 10; }
.card {
  display: flex; align-items: center; gap: 4px;
  padding: 6px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  /* slightly hand-cut corners */
  border-top-left-radius: 12px 9px;
  border-bottom-right-radius: 11px 13px;
}
/* keep the cards clear of notches and home indicators on phones */
.top-left, .top-center, .left { top: calc(12px + env(safe-area-inset-top, 0px)); }
.top-left, .left, .bottom-left { left: calc(12px + env(safe-area-inset-left, 0px)); }
.top-center, .bottom-right { right: calc(12px + env(safe-area-inset-right, 0px)); }
.bottom-left, .bottom-center, .bottom-right { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.top-left { height: 46px; padding-right: 12px; }
.top-center { height: 46px; max-width: calc(100vw - 24px); z-index: 12; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex-wrap: nowrap; }
.top-center::-webkit-scrollbar { display: none; }
.top-center .icon-btn, .top-center .pill, .top-center .sep, .top-center .rough { flex: 0 0 auto; }
/* compaction levels applied by layoutTopBar() when the card would not fit beside the title card */
.top-center.compact1 .rough .lbl { display: none; } .top-center.compact1 .rough input[type=range] { width: 90px; }
.top-center.compact2 .pill span { display: none; } .top-center.compact2 .pill { padding: 0 9px; }
body.top-tight .title { width: 140px; }
.top-center.compact3 .rough { display: none !important; }
.left { top: calc(74px + env(safe-area-inset-top, 0px)); flex-direction: column; padding: 6px 5px; }
.bottom-left { }
.bottom-center {
  left: calc(236px + env(safe-area-inset-left, 0px)); right: calc(72px + env(safe-area-inset-right, 0px));
  width: fit-content; max-width: calc(100vw - 308px); margin-inline: auto;
  padding: 6px 8px; gap: 2px 0; flex-wrap: wrap; justify-content: center;
}
@media (max-width: 760px) { .bottom-center { left: 12px; right: 12px; max-width: calc(100vw - 24px); bottom: calc(62px + env(safe-area-inset-bottom, 0px)); } }
.bottom-right { }
@media (max-width: 1180px) {
  .top-center { top: calc(66px + env(safe-area-inset-top, 0px)); }
  .left { top: calc(128px + env(safe-area-inset-top, 0px)); }
  .top-left { max-width: calc(100vw - 24px); }
  .rough { display: none !important; }
}
@media (max-width: 760px) {
  .top-center { overflow-x: auto; overflow-y: hidden; }
  .pill span, .brand span { display: none; }
  .pill { padding: 0 8px; }
  .title { width: 130px; }
}

.brand {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-title); font-weight: 700; font-size: 22px;
  padding: 0 8px 0 4px; letter-spacing: 0.3px;
  border-right: 1.5px dashed rgba(43,43,43,0.3);
  margin-right: 4px; height: 100%;
}
.brand svg { color: var(--accent); }
.title {
  font-family: var(--font-title); font-size: 22px; font-weight: 500;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  min-width: 60px; width: 200px; padding: 2px 6px;
  border-bottom: 1.5px solid transparent;
}
.title:focus { border-bottom-color: var(--accent); }
.save-state { font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.save-state.dirty { color: #b26a00; }
.save-state.error { color: var(--warn); }

.icon-btn, .text-btn, .tool {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1.5px solid transparent; border-radius: 8px;
  background: transparent; cursor: pointer; padding: 0;
  color: var(--ink);
}
.text-btn { width: auto; padding: 0 8px; font-size: 14px; }
.icon-btn:hover, .text-btn:hover, .tool:hover, .pill:hover { background: rgba(43,43,43,0.07); }
.icon-btn.active, .tool.active { background: var(--yellow); border-color: var(--ink); }
.tool.locked::after {
  content: "🔒"; position: absolute; right: -2px; bottom: -3px; font-size: 9px;
}
.tool { position: relative; }
.tool kbd {
  position: absolute; right: 3px; bottom: 2px; font-size: 8px; line-height: 1; font-family: inherit;
  color: var(--ink-soft); opacity: 0.85; pointer-events: none;
  padding: 0; min-width: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.icon-btn svg, .tool svg, .pill svg { width: 20px; height: 20px; display: block; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; }
.sep { width: 1.5px; height: 24px; background: rgba(43,43,43,0.25); margin: 0 4px; border-radius: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1.5px solid var(--card-border); border-radius: 9px;
  border-top-left-radius: 10px 7px; border-bottom-right-radius: 8px 11px;
  background: #fff; cursor: pointer; font-size: 15px; white-space: nowrap;
}
.pill.primary { background: var(--yellow); }
.pill.danger { color: var(--warn); border-color: var(--warn); }
.pill.active { background: var(--accent-soft); }
.pill svg { width: 16px; height: 16px; }

.rough { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.rough .lbl { font-family: var(--font-title); font-size: 18px; font-weight: 700; }
.rough .tiny { font-size: 11px; color: var(--ink-soft); }
.rough input[type=range] { width: 120px; accent-color: var(--ink); cursor: pointer; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: 40px; right: 0; min-width: 170px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--card); border: 1.5px solid var(--card-border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 20;
}
.menu button {
  text-align: left; border: 0; background: transparent; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; font-size: 15px; white-space: nowrap;
}
.menu button:hover { background: rgba(43,43,43,0.08); }

/* ---------- style bar groups ---------- */
.group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1.5px dashed rgba(43,43,43,0.3); }
.group:last-child, .group.last { border-right: 0; }
.group.hidden { display: none; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(43,43,43,0.55);
  cursor: pointer; padding: 0; margin: 0 1px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.12);
}
.swatch.active { outline: 2.5px solid var(--ink); outline-offset: 1.5px; }
.swatch.custom { background: conic-gradient(#e74c3c, #f1c40f, #2ecc71, #3498db, #9b59b6, #e74c3c); }
.swatch.big { width: 36px; height: 36px; align-self: flex-start; }
/* ---------- colour picker ---------- */
.menu.cpick { width: 248px; padding: 10px; gap: 8px; background: var(--card-opaque, var(--card)); }
.menu.cpick .ctx-grip { display: none; }
.cp-sv { position: relative; height: 150px; border-radius: 8px; border: 1.5px solid rgba(43,43,43,0.4); cursor: crosshair; touch-action: none; --hue: #f00;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue)); }
.cp-sv:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.cp-handle { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(0,0,0,0.6), 0 1px 4px rgba(0,0,0,0.35); transform: translate(-50%, -50%); pointer-events: none; }
.menu.cpick input.cp-hue { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 0; padding: 0; border-radius: 8px; border: 1.5px solid rgba(43,43,43,0.4); cursor: pointer; color-scheme: light;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%) !important; }
.cp-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.cp-hue::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); }
.cp-hue::-moz-range-track { background: transparent; }
.cp-hue:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.menu.cpick .cp-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-preview { width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid rgba(43,43,43,0.4); flex: 0 0 auto; }
.menu.cpick .cp-hex { flex: 1; min-width: 0; height: 32px; font-family: var(--font-mono, monospace); font-size: 15px; text-transform: lowercase; padding: 0 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; color: #2b2b2b; }
.menu.cpick button.cp-done { flex: 0 0 auto; padding: 6px 12px; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--yellow); color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; }
.cp-label { font-size: 12px; color: var(--ink-soft); margin: 2px 0 -4px; }
.menu.cpick button.cp-sw { width: 22px; height: 22px; min-width: 22px; padding: 0; border-radius: 50%; border: 2px solid rgba(43,43,43,0.55); background: var(--c); box-shadow: inset 0 -3px 0 rgba(0,0,0,0.12); cursor: pointer; }
.menu.cpick button.cp-sw.active { outline: 2.5px solid var(--ink); outline-offset: 1.5px; }
body.phone .menu.cpick { position: fixed; left: 6px; right: 6px; top: auto !important; bottom: 6px; width: auto; max-height: 80vh; overflow: auto; border-radius: 16px; z-index: 45; padding: 4px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
body.phone .menu.cpick .ctx-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(43,43,43,0.3); margin: 4px auto 6px; }
body.phone .cp-sv { height: 190px; }
body.phone .menu.cpick input.cp-hue { height: 24px; border-radius: 12px; }
body.phone .cp-hue::-webkit-slider-thumb { width: 30px; height: 30px; }
body.phone .menu.cpick button.cp-sw { width: 32px; height: 32px; min-width: 32px; }
body.phone .menu.cpick .cp-hex, body.phone .menu.cpick button.cp-done { height: 40px; font-size: 16px; }
.opt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; border: 1.5px solid transparent;
  background: transparent; cursor: pointer; padding: 0; font-size: 18px;
}
.opt svg { width: 20px; height: 20px; }
.opt:hover { background: rgba(43,43,43,0.07); }
.opt.active { background: var(--yellow); border-color: var(--ink); }
.opt.emoji { font-size: 20px; }

/* ---------- panels, popovers, modals ---------- */
.panel {
  top: 70px; right: 12px; bottom: 60px; width: 300px;
  display: flex; flex-direction: column;
  background: var(--card); border: 1.5px solid var(--card-border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.panel header, .modal-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1.5px dashed rgba(43,43,43,0.3);
  font-family: var(--font-title); font-size: 22px; font-weight: 700;
}
.panel .list { flex: 1; overflow: auto; padding: 8px; }
.panel .hint { padding: 8px 12px; font-size: 13px; color: var(--ink-soft); border-top: 1.5px dashed rgba(43,43,43,0.3); }
.cmt {
  padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; cursor: pointer;
  background: #fff; border: 1.5px solid rgba(43,43,43,0.25);
}
.cmt:hover { border-color: var(--ink); }
.cmt.resolved { opacity: 0.55; text-decoration: line-through; }
.cmt .who { font-size: 12px; color: var(--ink-soft); }
.empty { color: var(--ink-soft); padding: 12px; text-align: center; }

.popover {
  z-index: 14;
  width: 280px; padding: 10px;
  background: var(--card); border: 1.5px solid var(--card-border); border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.popover .thread { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.popover .msg { background: #fff; border: 1.5px solid rgba(43,43,43,0.2); border-radius: 8px; padding: 6px 8px; font-size: 15px; white-space: pre-wrap; }
.popover .msg .who { font-size: 12px; color: var(--ink-soft); }
.popover textarea, #commentInput {
  font: inherit; font-size: 15px; padding: 6px 8px; resize: vertical;
  border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; outline: none;
}
.popover textarea:focus { border-color: var(--accent); }
.popover .row { display: flex; gap: 6px; }
.popover .row .pill { height: 28px; padding: 0 10px; font-size: 14px; }

.modal { z-index: 30; inset: 0; background: rgba(43,43,43,0.35); display: flex; align-items: center; justify-content: center; }
.modal-card {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border: 1.5px solid var(--card-border); border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal-card .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; padding: 8px 16px 16px; }
@media (max-width: 640px) { .modal-card .cols { grid-template-columns: 1fr; } }
.modal-card dt { font-family: var(--font-title); font-size: 20px; font-weight: 700; margin-top: 10px; }
.modal-card dd { margin: 4px 0; font-size: 15px; }
kbd {
  display: inline-block; padding: 0 5px; min-width: 18px; text-align: center;
  border: 1.5px solid rgba(43,43,43,0.45); border-bottom-width: 2.5px; border-radius: 5px;
  background: #fff; font-family: inherit; font-size: 13px; line-height: 18px;
}

.toast {
  left: 50%; bottom: 70px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px;
  font-size: 15px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- present mode ---------- */
.present-bar { display: none; }
body.present .ui { display: none; }
body.present .present-bar {
  display: flex; align-items: center; gap: 14px;
  top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(43,43,43,0.85); color: #fff; padding: 6px 8px 6px 14px; border-radius: 10px;
  font-size: 14px; opacity: 0.25; transition: opacity 0.2s;
}
body.present .present-bar:hover { opacity: 1; }
body.present .present-bar .pill { height: 26px; padding: 0 10px; font-size: 13px; }
body.present #svg { cursor: none; }

/* ---------- boards, history, templates, settings ---------- */
.panel.left-panel { left: calc(12px + env(safe-area-inset-left, 0px)); right: auto; }
.panel header > span:last-child { display: flex; align-items: center; gap: 4px; }
.board-row { position: relative; display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; cursor: pointer; background: #fff; border: 1.5px solid rgba(43,43,43,0.25); }
.board-thumb { width: 76px; height: 48px; border-radius: 5px; border: 1px solid rgba(127,127,127,0.35); overflow: hidden; background: rgba(127,127,127,0.08); display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 18px; }
.board-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.board-text { min-width: 0; }
.board-row:hover { border-color: var(--ink); }
.board-row.current { background: var(--yellow); border-color: var(--ink); }
.board-row .board-title { font-family: var(--font-title); font-size: 20px; font-weight: 700; padding-right: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .who { font-size: 12px; color: var(--ink-soft); }
.board-row .row-actions { position: absolute; right: 6px; top: 6px; display: none; gap: 2px; }
.board-row:hover .row-actions { display: flex; }
.board-row .row-actions button { width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 14px; }
.board-row .row-actions button:hover { background: rgba(43,43,43,0.1); }
.icon-btn.active-panel { background: var(--yellow); border-color: var(--ink); }
.tiny { font-size: 11px; color: var(--ink-soft); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 14px 16px 18px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border: 1.5px solid rgba(43,43,43,0.3); border-radius: 10px; background: #fff; cursor: pointer; text-align: left; min-height: 110px; }
.tpl:hover { border-color: var(--ink); background: var(--yellow); }
.tpl-emoji { font-size: 26px; }
.tpl-name { font-family: var(--font-title); font-size: 20px; font-weight: 700; }
.tpl-desc { font-size: 13px; color: var(--ink-soft); }
.modal-card.narrow { width: min(460px, calc(100vw - 32px)); }
.form { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.form input[type=text], .form input[type=url], .form input[type=password] { font: inherit; font-size: 15px; padding: 6px 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; outline: none; }
.form input:focus { border-color: var(--accent); }
.form h4 { margin: 8px 0 0; font-family: var(--font-title); font-size: 20px; }
.form .hint { margin: 0; font-size: 13px; color: var(--ink-soft); }
.form .row { display: flex; justify-content: flex-end; }
/* ---------- ask dialog ---------- */
#askModal { z-index: 60; }   /* above every other modal: a question can be asked from the Share or Settings dialog */
.modal-card.ask { width: min(440px, calc(100vw - 32px)); }
.modal-card.ask .form { padding: 18px 18px 14px; gap: 12px; }
.ask-msg { margin: 0; font-size: 16px; line-height: 1.4; white-space: pre-line; }
.modal-card.ask textarea { font: inherit; font-size: 14px; font-family: var(--font-mono, monospace); padding: 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; outline: none; resize: vertical; min-height: 110px; }
.modal-card.ask textarea:focus { border-color: var(--accent); }
.ask-actions { gap: 8px; }
.pill.primary { background: var(--yellow); border-color: var(--ink); font-weight: 700; }
.pill.primary.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
body.phone .modal-card.ask .pill { height: 40px; font-size: 16px; flex: 1; justify-content: center; }
/* selects look like the app's fields (the open list stays the system's) */
select { -webkit-appearance: none; appearance: none; padding-right: 24px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b2b2b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; background-size: 14px; cursor: pointer; }
.form select { font: inherit; font-size: 15px; padding: 6px 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background-color: #fff; outline: none; }
.form select:focus { border-color: var(--accent); }
html[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8e8e8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
html[data-theme="dark"] .modal-card.ask textarea { background: rgba(255,255,255,0.06); color: var(--ink); border-color: var(--card-border); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: rgba(43,43,43,0.07); padding: 1px 4px; border-radius: 4px; }

/* ---------- element features ---------- */
.el.locked { cursor: not-allowed; }
.rotate-handle { cursor: grab; }
.opacity { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; font-size: 14px; }
.opacity input[type=range] { width: 70px; accent-color: var(--ink); }
#layer foreignObject { pointer-events: auto; }
#layer foreignObject video, #layer foreignObject audio, #layer foreignObject iframe { pointer-events: auto; }
.open-link { pointer-events: all; }

/* ---------- navigation ---------- */
#minimap { position: fixed; right: calc(64px + env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--card); border: 1.5px solid var(--card-border); border-radius: 10px; box-shadow: var(--shadow); cursor: crosshair; z-index: 9; }
.search-box { padding: 10px 12px 4px; }
.search-box input { width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; outline: none; }
.search-box input:focus { border-color: var(--accent); }
.cmt.scene { position: relative; padding-right: 100px; }
.cmt.scene.current { background: var(--yellow); border-color: var(--ink); }
.cmt.scene .row-actions { position: absolute; right: 6px; top: 6px; display: flex; gap: 2px; }
.cmt.scene .row-actions button { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 13px; }
.cmt.scene .row-actions button:hover { background: rgba(43,43,43,0.1); }
.menu-label { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 14px; color: var(--ink-soft); border-bottom: 1.5px dashed rgba(43,43,43,0.3); margin-bottom: 4px; }
.menu-label select { font: inherit; font-size: 14px; border: 1.5px solid rgba(43,43,43,0.3); border-radius: 6px; background-color: #fff; padding: 2px 6px; }
.present-bar #presentScene { font-size: 13px; }

/* ---------- collaboration ---------- */
.peers { display: inline-flex; align-items: center; }
.peers .avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; margin-left: -6px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; box-shadow: 0 0 0 1.5px var(--ink); }
.peers .avatar:first-child { margin-left: 0; }
.peers .cloud { font-size: 13px; color: var(--ink-soft); margin-right: 4px; white-space: nowrap; }
.peers .cloud.err { color: var(--warn); }
.members { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow: auto; }
/* Share: a board shared with a link and a password */
.form .link-row { justify-content: flex-start; gap: 6px; }
.form .link-row input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 6px 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; color: #2b2b2b; }
.peers-list { display: flex; flex-wrap: wrap; gap: 6px; }
.peers-list .peer { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1.5px solid rgba(43,43,43,0.2); border-radius: 999px; background: #fff; font-size: 14px; }
.peers-list .dot { width: 12px; height: 12px; border-radius: 50%; }
.share-details { border: 1.5px solid var(--card-border); border-radius: 10px; padding: 6px 10px; }
.share-details > summary { cursor: pointer; font-family: var(--font-title); font-size: 18px; font-weight: 700; list-style: none; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.share-details > summary::-webkit-details-marker { display: none; }
.share-details > summary::before { content: '▸'; font-size: 14px; }
.share-details[open] > summary::before { content: '▾'; }
.share-details > summary .hint { font-family: var(--font-body, inherit); font-weight: 400; }
.share-details > :not(summary) { margin-top: 8px; }
html[data-theme="dark"] .form .link-row input, html[data-theme="dark"] .peers-list .peer { background: rgba(255,255,255,0.06); color: var(--ink); border-color: var(--card-border); }
.member { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1.5px solid rgba(43,43,43,0.2); border-radius: 8px; background: #fff; font-size: 14px; }
.member .dot { width: 12px; height: 12px; border-radius: 50%; }
.member select { margin-left: auto; font: inherit; font-size: 13px; }
.member.board { cursor: pointer; }
.member.board:hover { border-color: var(--ink); }
body.readonly .left, body.readonly #stylebar { opacity: 0.45; pointer-events: none; }
body.readonly #editor { display: none !important; }
.peer-cursor text { paint-order: stroke; stroke: #fff; stroke-width: 3px; font-family: var(--font-hand); }

/* ---------- account ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px dashed rgba(43,43,43,0.3); }
.tab { border: 0; background: transparent; padding: 6px 10px; cursor: pointer; font-family: var(--font-title); font-size: 18px; font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1.5px; }
.tab.active { border-bottom-color: var(--ink); }
.linkish { border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--accent); text-decoration: underline; font: inherit; font-size: 14px; }
.form input[type=email] { font: inherit; font-size: 15px; padding: 6px 8px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 8px; background: #fff; outline: none; }

/* ---------- about / settings extras ---------- */
.about-brand { display: flex; align-items: center; gap: 12px; color: var(--accent); }
.about-name { font-family: var(--font-title); font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1; }
.about p { margin: 0; font-size: 15px; }
.check { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-size: 14px; }
.check input { margin-top: 3px; }

/* ==========================================================================
   Touch & phone layout
   ========================================================================== */
@media (pointer: coarse) {
  .tool kbd { display: none; }                       /* keyboard hints mean nothing on a touch screen */
  .icon-btn, .tool, .text-btn { width: 40px; height: 40px; }
  .pill { height: 38px; }
  .opt { width: 36px; height: 36px; }
  .swatch { width: 26px; height: 26px; }
  .board-row .row-actions { display: flex; }
  .menu button { padding: 10px 12px; font-size: 16px; }
  .cmt { padding: 10px 12px; }
}
body.phone .tool kbd { display: none; }             /* nor in the phone dock, where the buttons are tight */
@media (max-width: 760px) {
  .top-left { height: 44px; padding-right: 8px; max-width: calc(100vw - 24px); }
  .top-left .brand { padding: 0 4px; }
  .title { width: auto; flex: 1; min-width: 0; font-size: 20px; }
  .save-state { font-size: 12px; }
  .top-center { top: calc(64px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px; max-width: none; height: 44px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex-wrap: nowrap; }
  .top-center::-webkit-scrollbar { display: none; }
  .top-center .icon-btn, .top-center .pill { flex: 0 0 auto; }
  /* tools become a horizontal dock at the bottom */
  .left { top: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: 12px; right: 12px; flex-direction: row; padding: 5px; gap: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .left::-webkit-scrollbar { display: none; }
  .tool { flex: 0 0 auto; }
  .bottom-center { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); left: 12px; right: 12px; max-width: none; margin: 0; width: auto; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .bottom-center::-webkit-scrollbar { display: none; }
  .bottom-center .group { flex: 0 0 auto; }
  .bottom-left, .bottom-right { display: none; }
  #minimap { right: 12px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); width: 140px; height: 92px; }
  .panel, .panel.left-panel { left: 12px; right: 12px; width: auto; top: calc(116px + env(safe-area-inset-top, 0px)); bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  .popover { width: calc(100vw - 24px); }
  .present-bar { max-width: calc(100vw - 24px); font-size: 12px; }
  .toast { max-width: calc(100vw - 24px); }
  .modal-card header { font-size: 20px; }
}

/* ---------- context menu, locks, formatting ---------- */
.menu.floating { position: fixed; right: auto; z-index: 40; overflow: auto; }
/* dropdown entries: icon, label, shortcut */
#moreMenu button, #exportMenu button { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
#moreMenu button .mi { width: 18px; height: 18px; flex: 0 0 18px; display: inline-flex; color: var(--ink-soft); }
#moreMenu button .mi svg { width: 18px; height: 18px; }
#moreMenu button .ml { flex: 1; }
#moreMenu button .k { font-size: 12px; color: var(--ink-soft); margin-left: 16px; }
#moreMenu .menu-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 0; padding-bottom: 2px; margin-bottom: 0; }
#moreMenu .mg + .mg { margin-top: 4px; }
#moreMenu button:focus-visible, #exportMenu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* a tall menu on a wide screen lays its groups out in two columns instead of scrolling */
.menu.cols2 { display: block; column-count: 2; column-gap: 10px; width: max-content; max-width: calc(100vw - 16px); }
.menu.cols2 .mg { break-inside: avoid; display: flex; flex-direction: column; }
.menu.cols2 .mg + .mg { margin-top: 0; padding-top: 4px; }
.menu.ctx { position: fixed; top: 0; left: 0; right: auto; width: max-content; min-width: 210px; max-width: calc(100vw - 16px); z-index: 40; max-height: calc(100vh - 16px); overflow: auto; }
.menu.ctx button { display: flex; justify-content: space-between; gap: 16px; }
.menu.ctx button .k { font-size: 12px; color: var(--ink-soft); }
.menu.ctx button.danger { color: var(--warn); }
.menu.ctx .ctx-title { padding: 6px 10px 2px; font-family: var(--font-title); font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.menu.ctx .ctx-quick { display: flex; gap: 2px; padding: 4px 6px 6px; border-bottom: 1.5px dashed rgba(43,43,43,0.3); margin-bottom: 4px; }
.menu.ctx .ctx-quick button { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 8px; }
.menu.ctx .ctx-quick button.active { background: var(--yellow); }
.menu.ctx .ctx-quick button.danger { margin-left: auto; }
.menu.ctx button .mi { width: 18px; height: 18px; flex: 0 0 18px; display: inline-flex; color: var(--ink-soft); }
.menu.ctx button .mi svg { width: 18px; height: 18px; }
.menu.ctx button.danger .mi, .menu.ctx .ctx-quick button.danger .mi { color: var(--warn); }
.menu.ctx button { justify-content: flex-start; gap: 10px; }
.menu.ctx button .ml { flex: 1; text-align: left; }
.menu.ctx button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu.ctx .menu-label { margin-top: 2px; padding-top: 4px; padding-bottom: 2px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 0; }
.menu.ctx .menu-label + button { margin-top: 0; }
.menu.ctx button:disabled { opacity: 0.4; cursor: default; }
.menu-sep { height: 1.5px; margin: 4px 6px; background: rgba(43,43,43,0.15); }
#boardLockBtn.active { background: var(--yellow); border-color: var(--ink); }
body.readonly #title { pointer-events: none; }
.mini-select { font: inherit; font-size: 13px; height: 28px; border: 1.5px solid rgba(43,43,43,0.3); border-radius: 6px; background-color: #fff; margin: 0 2px; padding-left: 6px; }
@media (pointer: coarse) { .menu.ctx button { padding: 12px 14px; font-size: 16px; } .menu.ctx .ctx-quick button { width: 42px; height: 42px; padding: 0; } .menu.ctx button .mi svg { width: 20px; height: 20px; } }

/* ---------- settings page ---------- */
.modal-card.settings { width: min(860px, calc(100vw - 32px)); height: min(640px, calc(100vh - 32px)); display: flex; flex-direction: column; }
.settings-body { display: flex; flex: 1; min-height: 0; }
.settings-nav { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border-right: 1.5px dashed rgba(43,43,43,0.3); min-width: 170px; }
.settings-nav button { text-align: left; border: 1.5px solid transparent; background: transparent; border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 15px; }
.settings-nav button:hover { background: rgba(43,43,43,0.07); }
.settings-nav button.active { background: var(--yellow); border-color: var(--ink); }
.settings-sections { flex: 1; overflow: auto; }
.settings-sections section { display: flex; flex-direction: column; gap: 10px; }
.settings-sections section.hidden { display: none; }
@media (max-width: 760px) {
  .modal-card.settings { height: calc(100vh - 24px); width: calc(100vw - 24px); }
  .settings-body { flex-direction: column; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1.5px dashed rgba(43,43,43,0.3); min-width: 0; scrollbar-width: none; }
  .settings-nav button { flex: 0 0 auto; }
}
/* ---------- scroll hints on horizontal bars ---------- */
.scrollx::before, .scrollx::after { content: ""; position: absolute; top: 0; bottom: 0; width: 34px; pointer-events: none; opacity: 0; transition: opacity 0.2s; z-index: 2; }
.scrollx::after { right: 0; background: linear-gradient(to right, rgba(255,253,247,0), rgba(255,253,247,0.95) 55%); border-radius: 0 10px 10px 0; }
.scrollx::before { left: 0; background: linear-gradient(to left, rgba(255,253,247,0), rgba(255,253,247,0.95) 55%); border-radius: 10px 0 0 10px; }
.scrollx.more-right::after, .scrollx.more-left::before { opacity: 1; }
.scroll-chev { position: absolute; top: 50%; transform: translateY(-50%); font-size: 18px; color: var(--ink); pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.2s; animation: chev-nudge 1.4s ease-in-out infinite; }
.scroll-chev.r { right: 6px; } .scroll-chev.l { left: 6px; }
.scrollx.more-right .scroll-chev.r, .scrollx.more-left .scroll-chev.l { opacity: 0.9; }
@keyframes chev-nudge { 0%, 100% { transform: translateY(-50%) translateX(0); } 50% { transform: translateY(-50%) translateX(3px); } }
/* ---------- accessibility ---------- */
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ==========================================================================
   Themes (Settings → Appearance). data-theme on <html>: sketch (default), elegant, dark
   ========================================================================== */
html[data-theme="elegant"], html[data-theme="dark"] {
  --font-hand: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: #2f5fb3;
}
html[data-theme="elegant"] {
  --paper: #f6f7f9;
  --ink: #1f2328;
  --ink-soft: #5c6470;
  --grid-minor: rgba(31, 35, 40, 0.045);
  --grid-major: rgba(31, 35, 40, 0.09);
  --card: rgba(255, 255, 255, 0.95);
  --card-opaque: #ffffff;
  --card-border: rgba(31, 35, 40, 0.16);
  --accent-soft: #dbe6fa;
  --yellow: #dbe6fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.10);
}
html[data-theme="dark"] {
  --paper: #14171c;
  --ink: #e6e8eb;
  --ink-soft: #9aa3ad;
  --grid-minor: rgba(255, 255, 255, 0.05);
  --grid-major: rgba(255, 255, 255, 0.09);
  --card: rgba(30, 34, 40, 0.96);
  --card-opaque: #1e2228;
  --card-border: rgba(255, 255, 255, 0.14);
  --accent: #7aa2f7;
  --accent-soft: #22304d;
  --yellow: #22304d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
html[data-theme="elegant"] body, html[data-theme="dark"] body { font-size: 14px; }
html[data-theme="elegant"] .brand, html[data-theme="dark"] .brand { font-size: 17px; font-weight: 600; letter-spacing: 0; }
html[data-theme="elegant"] .title, html[data-theme="dark"] .title { font-size: 16px; font-weight: 600; }
html[data-theme="elegant"] .panel header, html[data-theme="elegant"] .modal-card header,
html[data-theme="dark"] .panel header, html[data-theme="dark"] .modal-card header { font-size: 16px; font-weight: 600; }
html[data-theme="elegant"] .modal-card dt, html[data-theme="dark"] .modal-card dt { font-size: 15px; font-weight: 600; }
html[data-theme="elegant"] .rough .lbl, html[data-theme="dark"] .rough .lbl { font-size: 14px; font-weight: 600; }
html[data-theme="elegant"] .brand, html[data-theme="elegant"] .panel header, html[data-theme="elegant"] .modal-card header, html[data-theme="elegant"] .panel .hint, html[data-theme="elegant"] .settings-nav,
html[data-theme="dark"] .brand, html[data-theme="dark"] .panel header, html[data-theme="dark"] .modal-card header, html[data-theme="dark"] .panel .hint, html[data-theme="dark"] .settings-nav { border-style: solid; border-color: var(--card-border); }
html[data-theme="elegant"] .card, html[data-theme="elegant"] .menu, html[data-theme="elegant"] .panel, html[data-theme="elegant"] .popover, html[data-theme="elegant"] .modal-card, html[data-theme="elegant"] #minimap,
html[data-theme="dark"] .card, html[data-theme="dark"] .menu, html[data-theme="dark"] .panel, html[data-theme="dark"] .popover, html[data-theme="dark"] .modal-card, html[data-theme="dark"] #minimap { border-width: 1px; }
html[data-theme="elegant"] .icon-btn.active, html[data-theme="elegant"] .tool.active, html[data-theme="elegant"] .opt.active, html[data-theme="elegant"] .board-row.current, html[data-theme="elegant"] .settings-nav button.active,
html[data-theme="dark"] .icon-btn.active, html[data-theme="dark"] .tool.active, html[data-theme="dark"] .opt.active, html[data-theme="dark"] .board-row.current, html[data-theme="dark"] .settings-nav button.active { border-color: var(--accent); color: var(--accent); }
html[data-theme="elegant"] .swatch.active, html[data-theme="dark"] .swatch.active { outline-color: var(--accent); }
html[data-theme="elegant"] .toast, html[data-theme="dark"] .toast { border-radius: 6px; }
html[data-theme="elegant"] .toast { background: #1f2328; }
html[data-theme="dark"] .toast { background: #e6e8eb; color: #14171c; }
html[data-theme="elegant"] kbd, html[data-theme="dark"] kbd { font-family: inherit; }

/* dark: the drawing is inverted with its hues kept (the classic whiteboard trick); photos, media and stickers are inverted back */
html[data-theme="dark"] #svg, html[data-theme="dark"] #minimap { filter: invert(0.92) hue-rotate(180deg); }
html[data-theme="dark"] #svg image, html[data-theme="dark"] #svg .el.sticker, html[data-theme="dark"] #svg .el.video, html[data-theme="dark"] #svg .el.audio, html[data-theme="dark"] #svg foreignObject { filter: invert(1) hue-rotate(180deg); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea, html[data-theme="dark"] .tpl, html[data-theme="dark"] .cmt, html[data-theme="dark"] .board-row, html[data-theme="dark"] .mini-select { background: rgba(255, 255, 255, 0.06); color: var(--ink); border-color: var(--card-border); }
html[data-theme="dark"] #editor, html[data-theme="dark"] .title { background: transparent; }
html[data-theme="dark"] .pill, html[data-theme="dark"] .cmt, html[data-theme="dark"] .popover .msg, html[data-theme="dark"] .member, html[data-theme="dark"] .search-box input, html[data-theme="dark"] .menu-label select, html[data-theme="dark"] .form input { background: rgba(255, 255, 255, 0.06); color: var(--ink); border-color: var(--card-border); }
html[data-theme="dark"] .pill.primary, html[data-theme="dark"] .pill.active { background: var(--accent-soft); }
html[data-theme="dark"] .icon-btn:hover, html[data-theme="dark"] .text-btn:hover, html[data-theme="dark"] .tool:hover, html[data-theme="dark"] .pill:hover { background: rgba(255, 255, 255, 0.10); }
html[data-theme="dark"] .scrollx::after { background: linear-gradient(to right, rgba(30,34,40,0), rgba(30,34,40,0.95) 55%); }
html[data-theme="dark"] .scrollx::before { background: linear-gradient(to left, rgba(30,34,40,0), rgba(30,34,40,0.95) 55%); }
html[data-theme="dark"] .swatch[data-v="ink"] { background: #e6e8eb !important; }
html[data-theme="dark"] kbd { background: rgba(255, 255, 255, 0.10); color: var(--ink); border-color: var(--card-border); box-shadow: none; }
html[data-theme="dark"] .tool kbd { background: transparent; color: var(--ink-soft); }

/* a short crossfade when the theme changes */
html.theme-fade body, html.theme-fade #canvas, html.theme-fade #svg, html.theme-fade #minimap, html.theme-fade .card, html.theme-fade .panel, html.theme-fade .modal-card, html.theme-fade .menu { transition: background-color 0.4s ease, color 0.4s ease, filter 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease; }

/* theme picker in the settings */
.theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.theme-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1.5px solid var(--card-border); border-radius: 10px; cursor: pointer; background: var(--card); }
.theme-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-card svg { width: 100%; height: auto; border-radius: 6px; border: 1px solid rgba(127, 127, 127, 0.25); display: block; margin-bottom: 4px; }
.theme-card b { font-size: 15px; }
.theme-card small { font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.theme-card:has(input:checked), .theme-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings .lbl { margin: 8px 0 0; font-weight: 600; }

/* ?demo=1: the sample board framed on quadrille.it; the bar leads to the full app in the top window */
.topbar-notice { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 10px 8px 14px; background: var(--yellow, #f2c94c); color: #2b2b2b; border: 1.5px solid #2b2b2b; border-radius: 12px; box-shadow: 0 2px 0 rgba(43,43,43,0.9); font: inherit; font-size: 15px; }
.topbar-notice .pill { height: 30px; font-size: 14px; }
.topbar-notice .icon-btn { width: 28px; height: 28px; }
#noticeBar.warn { background: #f8cfa2; }
#recover { z-index: 70; }
#demoBar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 40; background: var(--yellow, #f2c94c); color: var(--ink, #2b2b2b); border: 1.5px solid var(--ink, #2b2b2b); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 15px; text-decoration: none; box-shadow: 0 2px 0 rgba(43,43,43,0.9); white-space: nowrap; }
#demoBar:hover { transform: translateX(-50%) translateY(-1px); }
body.phone #demoBar { bottom: 84px; }
/* smart guides drawn by the overlay while moving or resizing */
#overlay .guide { stroke: #e0409a; vector-effect: non-scaling-stroke; }
body.theme-dark #overlay .guide { stroke: #ff7cc0; }
/* ---------- first use: guided tour (coach marks) and the empty-sheet hint ---------- */
.coach { position: fixed; z-index: 45; background: var(--card); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 15px; line-height: 1.4; animation: toast-in 0.18s ease-out; }
.coach::before { content: ''; position: absolute; width: 12px; height: 12px; background: var(--card); border: 1.5px solid var(--ink); transform: rotate(45deg); }
.coach[data-side="left"]::before { left: -7px; top: calc(var(--ay) - 6px); border-right: 0; border-top: 0; }
.coach[data-side="right"]::before { right: -7px; top: calc(var(--ay) - 6px); border-left: 0; border-bottom: 0; }
.coach[data-side="top"]::before { top: -7px; left: calc(var(--ax) - 6px); border-right: 0; border-bottom: 0; }
.coach[data-side="bottom"]::before { bottom: -7px; left: calc(var(--ax) - 6px); border-left: 0; border-top: 0; }
.coach .coach-text { margin-bottom: 10px; }
.coach .coach-row { display: flex; align-items: center; gap: 8px; }
.coach .grow { flex: 1; }
.coach button { font: inherit; font-size: 14px; border: 1.5px solid var(--ink); border-radius: 8px; padding: 4px 12px; background: #fff; color: var(--ink); cursor: pointer; }
.coach button.primary { background: var(--yellow); }
.coach button.ghost { background: transparent; border-color: transparent; color: var(--ink-soft, #6b6b66); }
.coach-target { outline: 3px solid #e0409a !important; outline-offset: 3px; border-radius: 10px; }
.empty-hint { left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; color: var(--ink-soft, #6b6b66); font-size: 16px; z-index: 1; padding: 0 20px; max-width: 480px; }
.empty-hint b { display: block; font-family: var(--title, inherit); font-size: 26px; color: var(--ink); margin-bottom: 4px; }

/* ---------- shape library ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px; }
.chip { font: inherit; font-size: 14px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 999px; padding: 2px 10px; background: transparent; color: var(--ink); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--paper, #fff); border-color: var(--ink); }
.shape-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; align-content: start; }
.shape-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 4px; border: 1.5px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; font: inherit; font-size: 11px; line-height: 1.15; text-align: center; }
.shape-item svg { width: 34px; height: 34px; }
.shape-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shape-item:hover { border-color: rgba(43,43,43,0.35); }
.shape-item.active { background: var(--yellow); border-color: var(--ink); }
.panel-foot { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1.5px dashed rgba(43,43,43,0.3); }
.panel-foot .tiny { flex: 1; }
#shapeMore.active { background: var(--yellow); }

/* ---------- context menu: property rows, phone bottom sheet ---------- */
.menu.ctx { background: var(--card-opaque, #fffdf7); }   /* opaque: the paper under a translucent menu showed through the icon rows */
.menu.ctx .ctx-row { display: flex; gap: 2px; padding: 4px 6px 6px; border-bottom: 1.5px dashed rgba(43,43,43,0.3); margin-bottom: 4px; }
.menu.ctx .ctx-props { flex-wrap: wrap; row-gap: 4px; }
.menu.ctx .ctx-pgroup { display: inline-flex; gap: 2px; align-items: center; padding-right: 6px; margin-right: 4px; border-right: 1.5px dashed rgba(43,43,43,0.25); }
.menu.ctx .ctx-pgroup:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.menu.ctx .ctx-props button.sw { width: 20px; height: 20px; min-width: 20px; border-radius: 50%; padding: 0; margin: 2px 1px; border: 2px solid rgba(43,43,43,0.55); background: var(--c); box-shadow: inset 0 -3px 0 rgba(0,0,0,0.12); }
.menu.ctx .ctx-props button.sw.active { outline: 2px solid var(--ink); outline-offset: 1px; }
.menu.ctx .ctx-props button.pb { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 7px; font-size: 13px; }
.menu.ctx .ctx-props button.pb.active { background: var(--yellow); }
.menu.ctx .ctx-props button .pt { font-size: 13px; font-weight: 700; }
.menu.ctx .ctx-grip { display: none; }
body.phone .menu.ctx { position: fixed; left: 6px; right: 6px; top: auto !important; bottom: 6px; width: auto; min-width: 0; max-width: none; max-height: 62vh; border-radius: 16px; padding: 4px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
body.phone .menu.ctx .ctx-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: rgba(43,43,43,0.3); margin: 4px auto 2px; }
body.phone .menu.ctx .ctx-quick, body.phone .menu.ctx .ctx-row { flex-wrap: wrap; }
body.phone .menu.ctx .ctx-quick button { width: 44px; height: 44px; }
body.phone .menu.ctx .ctx-props button.sw { width: 26px; height: 26px; min-width: 26px; }
body.phone .menu.ctx .ctx-props button.pb { width: 40px; height: 40px; }
body.phone .menu.ctx button { min-height: 40px; }
body.phone .menu.ctx .ctx-props button.sw { min-height: 0; height: 26px; }
body.phone .menu.ctx .ctx-quick button.danger { margin-left: 0; }

/* ---------- boards list: views, favourites, folders, trash ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px; }
.chip { font: inherit; font-size: 14px; border: 1.5px solid rgba(43,43,43,0.4); border-radius: 999px; padding: 2px 10px; background: transparent; color: var(--ink); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--paper, #fff); border-color: var(--ink); }
.chip .n { font-size: 12px; opacity: 0.7; }
.board-row .star { color: #d9a400; }
.board-row .folder-badge { font-size: 12px; font-weight: 400; font-family: var(--font-body, inherit); color: var(--ink-soft); }
.board-row .row-actions button.on { color: #d9a400; }
.board-row .row-actions { top: auto; bottom: 6px; right: 8px; }   /* the actions replace the date line while hovering, the title keeps its width */
.board-row:hover .who { opacity: 0; }
.board-row .board-title { padding-right: 0; }
.panel footer.hint { display: flex; align-items: center; gap: 8px; }
.panel footer.hint span { flex: 1; }
#boardPick { max-height: 60vh; }
