:root {
  --bg: #f0f1f2;
  /* Milanote's grid: a 2x2px square dot every 10px, black at 5% (white at 3% in dark) */
  --grid-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='2' height='2' fill='%23000' fill-opacity='0.051'/%3E%3C/svg%3E");
  --chrome: #ffffff;
  --chrome-line: #e2e3e5;
  --ink: #1f2124;
  --ink-2: #5c6066;
  --ink-3: #93979d;
  --card: #ffffff;
  --card-line: rgba(20, 24, 30, 0.08);
  --card-shadow: 0 1px 2px rgba(20, 24, 30, 0.08);
  --accent: #3b6ef5;
  --accent-soft: rgba(59, 110, 245, 0.14);
  --link: #d0532c;
  --rail: #ebedee;
  --panel: #ffffff;
  --sel: #1b2536;
  --tip: #1b2536;
  --line: #3a3d42;
  --logo-ink: #ffffff;
  --tool-hover: #f2f3f4;
  --danger: #d6453d;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1f22; --grid-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='2' height='2' fill='%23fff' fill-opacity='0.031'/%3E%3C/svg%3E"); --chrome: #26282c; --chrome-line: #34373c;
    --ink: #eceef1; --ink-2: #b2b6bc; --ink-3: #7d828a; --card: #2d3035;
    --card-line: rgba(255, 255, 255, 0.07); --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --line: #c9ccd1; --link: #f08a62; --rail: #222428; --panel: #2d3035; --sel: #e8eaee; --tip: #3a3e45; --logo-ink: #26282c; --tool-hover: #303337; --accent: #6b93ff; --accent-soft: rgba(107, 147, 255, .18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1f22; --grid-dot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='2' height='2' fill='%23fff' fill-opacity='0.031'/%3E%3C/svg%3E"); --chrome: #26282c; --chrome-line: #34373c;
  --ink: #eceef1; --ink-2: #b2b6bc; --ink-3: #7d828a; --card: #2d3035;
  --card-line: rgba(255, 255, 255, 0.07); --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --line: #c9ccd1; --link: #f08a62; --rail: #222428; --panel: #2d3035; --sel: #e8eaee; --tip: #3a3e45; --logo-ink: #26282c; --tool-hover: #303337; --accent: #6b93ff; --accent-soft: rgba(107, 147, 255, .18);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
svg { display: block; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: 73px 1fr; grid-template-rows: 52px 1fr; }

/* ── Top bar ───────────────────────────── */
#topbar { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 0 12px; background: var(--chrome); border-bottom: 1px solid var(--chrome-line); z-index: 30; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.logo { border: 0; background: none; color: var(--ink); padding: 4px; border-radius: 8px; cursor: pointer; flex: none; }
#crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 13px; }
#crumbs a { color: var(--ink-2); text-decoration: none; padding: 4px 6px; border-radius: 6px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
#crumbs a:hover { background: var(--tool-hover); color: var(--ink); }
#crumbs a.drop-hot { background: var(--accent-soft); color: var(--accent); }
#crumbs .sep { color: var(--ink-3); }
#boardTitle { margin: 0; font: 700 21px/1.2 var(--serif); letter-spacing: .01em; padding: 3px 8px; border-radius: 6px; outline: none;
  max-width: 44vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
#boardTitle:hover { background: var(--tool-hover); }
#boardTitle[contenteditable="plaintext-only"], #boardTitle[contenteditable="true"] { background: var(--tool-hover); text-overflow: clip; }
.icon-btn { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--tool-hover); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn svg, #zoomFit svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.save-state { font-size: 12px; color: var(--ink-3); margin-right: 6px; white-space: nowrap; }
.save-state.err { color: var(--danger); }

/* ── Tool rail (Milanote: 72px wide, light grey, slides between toolbars) ── */
#tools { position: relative; z-index: 20; display: flex; flex-direction: column; background: var(--rail); border-right: 1px solid var(--chrome-line); overflow: hidden; }
.tb-dismiss { flex: none; height: 0; border: 0; background: none; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; overflow: hidden;
  opacity: 0; pointer-events: none; transition: opacity .1s ease-in-out, height .18s cubic-bezier(.3, 1, .7, 1); border-bottom: 1px solid transparent; }
.tb-dismiss.show { height: 36px; opacity: 1; pointer-events: auto; border-bottom-color: var(--chrome-line); }
.tb-dismiss svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tb-dismiss:hover { color: var(--ink); background: var(--tool-hover); }
.tb-window { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.tb-track { position: absolute; left: 0; top: 0; bottom: 0; display: flex; will-change: transform; }
.tb-panel { width: 72px; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; overflow-y: auto; scrollbar-width: none; }
.tb-panel::-webkit-scrollbar { display: none; }
.tool { width: 64px; flex: none; border: 0; background: none; border-radius: 10px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; color: inherit; }
.tool[data-kind="create"] { cursor: grab; }
.tool[data-kind="create"]:active { cursor: grabbing; }
.tool:hover .ti { box-shadow: 0 0 0 1px var(--card-line), 0 3px 8px rgba(20, 24, 30, .12); transform: translateY(-1px); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ti { width: 34px; height: 30px; display: grid; place-items: center; border-radius: 6px; background: var(--card); box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease; }
.ti svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ti-swatch { width: 18px; height: 18px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.board-ti { background: #5882f8; color: #fff; box-shadow: none; }
.board-ti svg { fill: currentColor; stroke: none; }
.tool-more { padding: 2px 2px 4px; }
.tool-more .ti { height: 18px; width: 30px; border-radius: 5px; }
.tool-more .ti svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.tool.on .ti { background: var(--sel); color: var(--card); box-shadow: none; }
.tool.open .ti { box-shadow: 0 0 0 2px var(--sel); }
.tl { font-size: 11px; color: var(--ink-2); line-height: 1.2; text-align: center; }
.tool-sep { width: 36px; height: 1px; background: var(--chrome-line); margin: 8px 0; flex: none; }
.tool-trash { margin: 4px auto 10px; }
.tool-trash .ti { background: transparent; box-shadow: none; color: var(--ink-3); transition: transform .15s ease, background .15s, color .15s; }
.tool-trash.drop-hot .ti { background: var(--danger); color: #fff; transform: scale(1.18); }
/* clicking instead of dragging: Milanote's nudge */
.tool.bounce { animation: toolBounce .4s; }
@keyframes toolBounce { 0% { transform: translate(0, 0); } 40% { transform: translate(1rem, 0); } 80% { transform: translate(0, 0); } 90% { transform: translate(.3rem, 0); } 100% { transform: translate(0, 0); } }

/* tooltip */
#tooltip { position: fixed; z-index: 95; transform: translateY(-50%); background: var(--tip); color: #fff; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
#tooltip::before { content: ""; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px; background: inherit; transform: translateY(-50%) rotate(45deg); border-radius: 1px; }
#tooltip.in { animation: tipIn .14s ease-out; }
@keyframes tipIn { from { opacity: 0; transform: translate(-4px, -50%); } to { opacity: 1; transform: translate(0, -50%); } }

/* floating panels next to the toolbar */
.fp { position: fixed; z-index: 70; background: var(--panel); color: var(--ink); border-radius: 8px; padding: 14px;
  box-shadow: rgba(27, 37, 54, .12) 0 8px 22px -6px, rgba(27, 37, 54, .14) 0 14px 32px -4px, rgba(27, 37, 54, .06) 0 2px 20px 4px;
  animation: fpIn .16s cubic-bezier(.3, 1, .7, 1); max-height: calc(100vh - 80px); overflow: auto; }
.fp::before { content: ""; position: absolute; left: -5px; top: var(--caret, 24px); width: 10px; height: 10px; background: var(--panel); transform: translateY(-50%) rotate(45deg); border-radius: 2px; }
@keyframes fpIn { from { opacity: 0; transform: translateX(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.fp-title { font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.fp-hint { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; max-width: 240px; }
.fp-input { width: 240px; border: 1px solid var(--chrome-line); background: var(--bg); color: var(--ink); border-radius: 6px; padding: 8px 10px; font: inherit; outline: none; }
.fp-input:focus { border-color: var(--accent); }
.create-grid { display: flex; gap: 4px; }
.fp-addimage { width: 300px; display: flex; flex-direction: column; gap: 10px; }
.fp-addimage .fp-title { margin: 0; }
.btn.wide { width: 100%; }
.url-form { display: flex; gap: 6px; }
.url-form input { flex: 1; min-width: 0; border: 1px solid var(--chrome-line); background: var(--bg); color: var(--ink); border-radius: 6px; padding: 7px 9px; font: inherit; outline: none; }
.url-form input:focus { border-color: var(--accent); }
/* menus */
.fp-menu { padding: 6px; }
.menu { display: flex; flex-direction: column; min-width: 200px; }
.menu-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink); text-decoration: none; }
.menu-item:hover { background: var(--tool-hover); }
.menu-item.on { background: var(--tool-hover); font-weight: 600; }
.menu-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.menu-item span { flex: 1; }
.menu-item kbd { font: 11px var(--sans); color: var(--ink-3); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--chrome-line); margin: 5px 4px; }
/* colour menu */
.cp-grid { display: grid; grid-template-columns: repeat(5, 26px); gap: 10px; }
.cp-sw { width: 26px; height: 26px; border-radius: 4px; border: 0; padding: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); transition: transform .1s; }
.cp-sw:hover { transform: scale(1.08); }
.cp-sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--sel); }
.cp-sep { height: 1px; background: var(--chrome-line); margin: 14px -14px; }
.cp-sub { font-size: 11px; color: var(--ink-3); margin: -4px 0 8px; text-transform: uppercase; letter-spacing: .05em; }
.cp-custom { display: flex; align-items: center; gap: 8px; border: 1px solid var(--chrome-line); border-radius: 6px; padding: 7px 12px; font-size: 13px; cursor: pointer; position: relative; color: var(--ink-2); }
.cp-custom:hover { background: var(--tool-hover); }
.cp-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cp-wheel { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(#ff5757, #ffd14d, #7cd651, #62dbc8, #4ebafd, #ad6fff, #ff6ed4, #ff5757); -webkit-mask: radial-gradient(circle, transparent 3.5px, #000 4px); mask: radial-gradient(circle, transparent 3.5px, #000 4px); }
/* icon menu */
.ip { display: grid; grid-template-columns: 220px 1fr; gap: 18px; width: min(600px, calc(100vw - 110px)); }
.ip-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ip-tabs { display: flex; flex-direction: column; gap: 2px; }
.ip-tabs button { text-align: left; border: 0; background: none; padding: 9px 14px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-tabs button:hover { background: var(--tool-hover); }
.ip-tabs button.on { background: var(--tool-hover); font-weight: 500; }
.ip-search { position: relative; margin-top: auto; }
.ip-search input { width: 100%; border: 1px solid var(--ink-3); background: var(--panel); color: var(--ink); border-radius: 6px; padding: 9px 34px 9px 12px; font: inherit; outline: none; }
.ip-search input:focus { border-color: var(--accent); }
.ip-search svg { position: absolute; right: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--ink-3); stroke-width: 1.8; pointer-events: none; }
.ip-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; align-content: start; padding: 2px; }
.ip-cell { height: 76px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: #7b818b; }
.ip-cell:hover { background: var(--tool-hover); }
.ip-cell.on { box-shadow: inset 0 0 0 2px var(--sel); color: var(--ink); }
.ip-cell svg { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ip-cell .txt { font: 700 30px/1 var(--sans); }
.ip-cell .txt.small { font-size: 21px; }
.ip-empty { grid-column: 1 / -1; color: var(--ink-3); font-size: 13px; }
.ip-upload { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 6px; }
.ip-upload img { width: 96px; height: 96px; object-fit: cover; border-radius: 16px; }
/* trash */
.fp-trash { width: 320px; }
.trash-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; margin-bottom: 8px; }
.trash-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; background: var(--bg); }
.trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.trash-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-text span { font-size: 11.5px; color: var(--ink-3); }

/* ── Canvas ───────────────────────────── */
#viewport { position: relative; overflow: hidden; outline: none; touch-action: none; cursor: default;
  background-color: var(--bg); background-image: var(--grid-dot); background-size: 10px 10px; }
/* like Milanote, the grid is hidden below 100% zoom (and while zooming out); from 100% up it scales with the board */
#viewport { background-image: none !important; }
#scroller { position: absolute; inset: 0; overflow: auto; overscroll-behavior: none; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; outline: none; scrollbar-width: thin; scrollbar-color: rgba(120, 125, 135, .45) transparent; }
#scroller::-webkit-scrollbar { width: 8px; height: 8px; }
#scroller::-webkit-scrollbar-thumb { background: rgba(120, 125, 135, .4); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
#scroller::-webkit-scrollbar-track, #scroller::-webkit-scrollbar-corner { background: transparent; }
#sizer { position: absolute; left: 0; top: 0; background-image: var(--grid-dot); pointer-events: none; }
#viewport.scaled #sizer, #viewport.zooming #sizer { background-image: none; }
#viewport.panning, body.space-pan #viewport { cursor: grab; }
#viewport.panning:active { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; width: 1px; height: 1px; transform-origin: 0 0; will-change: transform; }
#layer { position: absolute; left: 0; top: 0; }
.lines-svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; z-index: 5; pointer-events: none; }
#lineTop { z-index: 200000; }
.lines-svg g[data-id] { pointer-events: auto; cursor: pointer; }
.lines-svg .hit { stroke: transparent; stroke-width: 16; fill: none; pointer-events: stroke; }
.lines-svg .stroke { stroke: var(--line); stroke-width: 2; fill: none; stroke-linecap: round; pointer-events: none; }
.lines-svg .stroke.dashed { stroke-dasharray: 7 6; }
.lines-svg g.selected .stroke { filter: drop-shadow(0 0 1.5px var(--accent)); }
.lines-svg .arrow-fill { fill: var(--line); }
.lines-svg .line-label { font: 500 12px var(--sans); fill: var(--ink-2); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; pointer-events: none; }
.lines-svg .handle { fill: var(--card); stroke: var(--accent); stroke-width: 2; pointer-events: auto; cursor: grab; }
.lines-svg .handle.bend { fill: var(--accent); stroke: var(--card); }
.lines-svg .temp-line { stroke: var(--line); stroke-width: 2; fill: none; opacity: .75; }
.lines-svg .temp { stroke: var(--accent); stroke-width: 2; fill: none; stroke-dasharray: 5 5; }

#marquee { position: absolute; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 2px; pointer-events: none; z-index: 40; }
#emptyHint { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; color: var(--ink-3); pointer-events: none; font-size: 13px; }
#emptyHint .eh-title { font: 700 18px var(--serif); color: var(--ink-2); margin: 0 0 6px; }

/* ── Elements ───────────────────────────── */
.el { position: absolute; background: var(--card); color: var(--ink); border-radius: 3px;
  box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); user-select: none; -webkit-user-select: none;
  --rx: 0deg; --ry: 0deg; --shadow: 0; }
.el.in-col { position: relative; left: auto !important; top: auto !important; width: auto !important; z-index: auto !important; }
.el.selected { box-shadow: 0 0 0 2px var(--sel), var(--card-shadow); }
.el.editing { user-select: text; -webkit-user-select: text; }
.el.remote-flash { animation: remoteFlash 1.2s ease-out; }
@keyframes remoteFlash { 0% { box-shadow: 0 0 0 3px #f2b84b, var(--card-shadow); } 100% { box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); } }

/* lifted while dragging: 3D tilt + growing shadow (values driven from JS each frame) */
.el.dragging { z-index: 100000 !important; cursor: grabbing;
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) scale(calc(1 + 0.025 * var(--shadow)));
  box-shadow: 0 0 0 1px var(--card-line),
              0 calc(4px + 14px * var(--shadow)) calc(8px + 30px * var(--shadow)) rgba(15, 20, 30, calc(0.08 + 0.2 * var(--shadow))); }
.el.dragging.selected { box-shadow: 0 0 0 2px var(--sel),
              0 calc(4px + 14px * var(--shadow)) calc(8px + 30px * var(--shadow)) rgba(15, 20, 30, calc(0.08 + 0.2 * var(--shadow))); }
.el.settle-width { transition: width .18s ease; }
.el.into-board { transition: transform .24s cubic-bezier(.4, 0, .6, 1), opacity .24s ease; opacity: 0; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.no-select, body.no-select * { user-select: none !important; -webkit-user-select: none !important; }
.el.dragging { pointer-events: none; }

.rich, [data-edit] { outline: none; overflow-wrap: anywhere; }
[contenteditable] { cursor: text; }
.col-title, .todo-title, .link-title, .img-caption, .swatch-label { cursor: text; }
.rich p, .rich div { margin: 0; }
.rich ul, .rich ol { margin: 4px 0; padding-left: 20px; }
.rich a { color: var(--accent); }

/* note */
.el-note { padding: 12px 14px; min-height: 44px; }
.el-note .rich { min-height: 20px; }
.el-note.editing .rich:empty::before, .el-heading.editing .rich:empty::before { content: attr(data-ph); color: var(--ink-3); }
.el[data-color] { --tint: var(--card); }
.el.c-dark { color: #f2f3f5; }
.el.c-dark .todo-check { border-color: #9aa0a8; }

/* heading */
.el-heading { background: transparent; box-shadow: none; padding: 4px 6px; }
.el-heading .rich { font: 700 30px/1.15 var(--serif); }
.el-heading.selected { box-shadow: 0 0 0 2px var(--sel); }
.el-heading.dragging { background: transparent; box-shadow: none; }

/* to-do */
.el-todo { padding: 12px 14px 10px; }
.todo-title { font-weight: 600; margin-bottom: 6px; min-height: 20px; }
.todo-title:empty::before { content: "To-do list"; color: var(--ink-3); font-weight: 600; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; gap: 9px; align-items: flex-start; padding: 3px 0; }
.todo-check { flex: none; width: 17px; height: 17px; margin-top: 1.5px; border: 1.6px solid var(--ink-3); border-radius: 4px; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.todo-list li.done .todo-check { background: var(--accent); border-color: var(--accent); }
.todo-list li.done .todo-check::after { content: ""; width: 8px; height: 4.5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.todo-list li.done .todo-text { color: var(--ink-3); text-decoration: line-through; }
.todo-text { flex: 1; min-width: 0; min-height: 20px; }
.todo-text:empty::before { content: "Add a task"; color: var(--ink-3); }
.todo-progress { margin-top: 8px; height: 3px; border-radius: 3px; background: var(--card-line); overflow: hidden; }
.todo-progress span { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }

/* link — media on top, then favicon + address, title, description (Milanote's layout) */
.el-link { padding: 0; overflow: hidden; }
.link-body { padding: 12px 14px 13px; display: flex; flex-direction: column; gap: 4px; }
.link-domain { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); min-width: 0; text-decoration: none; cursor: pointer; }
.link-domain:hover span { text-decoration: underline; }
a.link-title { display: block; cursor: pointer; }
.el-link.editing a.link-title { cursor: text; }
.embed-frame { background: #f1f3f4; }
.link-domain span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-domain img { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.link-title { font-weight: 600; color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.editing .link-title { text-decoration: none; color: var(--ink); }
.link-desc { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.link-input { margin: 12px 14px; width: calc(100% - 28px); border: 1px solid var(--chrome-line); background: var(--bg); color: var(--ink); border-radius: 6px; padding: 8px 10px; font: inherit; outline: none; }
.link-input:focus { border-color: var(--accent); }
.link-media { position: relative; background: #111; }
.link-media img.og { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover; background: var(--bg); }
.link-media iframe { display: block; width: 100%; border: 0; }
.video-frame { position: relative; width: 100%; }
.video-frame > img, .video-frame > iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.video-frame.no-thumb { background: linear-gradient(135deg, #2a2d33, #121316); }
.play-btn { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(20, 22, 26, .62); display: grid; place-items: center; transition: transform .15s ease, background .15s; }
.play-btn::after { content: ""; margin-left: 4px; border-left: 17px solid #fff; border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.play-btn:hover { transform: scale(1.08); background: rgba(20, 22, 26, .8); }
.provider-tag { position: absolute; left: 10px; bottom: 10px; font: 600 11px var(--sans); color: #fff; background: rgba(0, 0, 0, .55); padding: 3px 7px; border-radius: 5px; pointer-events: none; }
/* embedded players only take clicks once the card is selected, so the card stays draggable */
.media-blocker { position: absolute; inset: 0; cursor: inherit; }
.el.selected:not(.dragging) .media-blocker { display: none; }
.link-loading .link-title::after { content: " ·"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* image */
.el-image { padding: 0; overflow: hidden; }
.el-image.uploading img { opacity: .55; filter: saturate(.6); }
.el-image.uploading::after { content: "Uploading…"; position: absolute; left: 10px; top: 10px; font: 600 11px var(--sans); color: #fff; background: rgba(0,0,0,.55); padding: 3px 7px; border-radius: 5px; }
.el-image img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.img-caption { padding: 8px 12px; font-size: 13px; color: var(--ink-2); }
.img-caption:empty { display: none; }
.el-image.editing .img-caption:empty { display: block; }
.el-image.editing .img-caption:empty::before { content: "Add a caption"; color: var(--ink-3); }
.img-empty { padding: 30px 14px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* column */
.el-column { background: var(--card); padding: 0 0 8px; }
.col-head { padding: 12px 14px 8px; text-align: center; }
.col-title { font: 700 17px/1.3 var(--serif); min-height: 22px; }
.col-title:empty::before { content: "New Column"; color: var(--ink-3); }
.col-count { font-size: 11px; color: var(--ink-3); }
.col-body { padding: 0 8px; display: flex; flex-direction: column; gap: 8px; min-height: 52px; }
.col-body > .el { box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); }
.col-body > .el.selected { box-shadow: 0 0 0 2px var(--sel); }
.col-body:empty::after { content: "Drag cards here"; display: grid; place-items: center; height: 52px; border: 1.5px dashed var(--card-line); border-radius: 4px; color: var(--ink-3); font-size: 12px; }
.el-column.drop-hot { box-shadow: 0 0 0 2px var(--accent), var(--card-shadow); }
.col-gap { height: 0; flex: none; border-radius: 4px; background: var(--accent-soft); transition: height .18s cubic-bezier(.2, .8, .2, 1), margin .18s; margin-bottom: -8px; }
.col-gap.open { margin-bottom: 0; }
.col-gap.ghost { background: transparent; }

/* board card */
.el-board { background: transparent; box-shadow: none; text-align: center; padding: 6px 4px; }
.board-tile { width: 76px; height: 76px; margin: 0 auto 8px; border-radius: 16px; display: grid; place-items: center; color: rgba(30, 32, 36, .72);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05); transition: transform .18s ease, box-shadow .18s ease; }
.board-tile svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.board-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.tile-text { font: 700 30px/1 var(--sans); color: rgba(30, 32, 36, .72); }
.tile-text.small { font-size: 21px; }
.col-body > .el-board .tile-text { font-size: 16px; }
.el.has-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--bar); border-radius: 3px 3px 0 0; z-index: 2; pointer-events: none; }
.board-title { font-weight: 700; font-size: 13px; line-height: 1.25; text-transform: uppercase; letter-spacing: .01em; min-height: 16px; }
.board-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.el-board.selected { box-shadow: none; }
.el-board.selected .board-tile { box-shadow: 0 0 0 2.5px var(--sel); }
.el-board.drop-hot .board-tile { transform: scale(1.12); box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0, 0, 0, .15); }
.el-board.dragging { transform: none; box-shadow: none; }
.el-board.dragging .board-tile { box-shadow: 0 calc(4px + 12px * var(--shadow)) calc(10px + 20px * var(--shadow)) rgba(15, 20, 30, .25); }
.col-body > .el-board { background: var(--card); display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px; }
.col-body > .el-board .board-tile { width: 40px; height: 40px; margin: 0; border-radius: 9px; flex: none; }
.col-body > .el-board .board-tile svg { width: 22px; height: 22px; }

/* swatch */
.el-swatch { padding: 6px; }
.swatch-chip { height: 64px; border-radius: 2px; }
.swatch-label { font-size: 12px; padding: 6px 2px 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* handles */
.resize-handle { position: absolute; right: -1px; bottom: -1px; width: 16px; height: 16px; cursor: nwse-resize; opacity: 0; transition: opacity .15s; }
.resize-handle::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); }
.el:hover > .resize-handle, .el.selected > .resize-handle { opacity: 1; }
.in-col > .resize-handle, .dragging > .resize-handle { display: none; }
.el.connect-hot { box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--accent-soft); }
.el-board.connect-hot { box-shadow: none; }
.el-board.connect-hot .board-tile { box-shadow: 0 0 0 3px var(--accent), 0 0 0 7px var(--accent-soft); }
.lines-svg .snap-ring { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; opacity: .75; }
.lines-svg .snap-ring.on { fill: var(--accent); opacity: 1; }
.lines-svg .handle.dragging { fill: var(--accent); }

/* ── Zoom ───────────────────────────── */
#zoomctl { position: fixed; right: 14px; bottom: 14px; z-index: 30; display: flex; align-items: center; background: var(--chrome); border-radius: 10px;
  box-shadow: 0 0 0 1px var(--chrome-line), 0 4px 14px rgba(0, 0, 0, .08); padding: 3px; }
#zoomctl button { border: 0; background: none; height: 30px; min-width: 30px; border-radius: 7px; cursor: pointer; font-size: 15px; color: var(--ink-2); display: grid; place-items: center; }
#zoomctl #zoomLabel { font-size: 12px; min-width: 50px; font-variant-numeric: tabular-nums; }
#zoomctl button:hover { background: var(--tool-hover); color: var(--ink); }

/* ── Ghost (dragging a new card from the rail) ─────────── */
#ghostLayer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.ghost { position: absolute; left: 0; top: 0; background: var(--card); border-radius: 3px; padding: 12px 14px; color: var(--ink-3); font-size: 13px;
  box-shadow: 0 0 0 1px var(--card-line), 0 14px 32px rgba(15, 20, 30, .25); transform-origin: 20px 20px; }
.ghost.ghost-board { background: transparent; box-shadow: none; padding: 0; }
.ghost.ghost-board .board-tile { width: 76px; height: 76px; box-shadow: 0 12px 26px rgba(15, 20, 30, .25); }
.ghost.ghost-heading { background: transparent; box-shadow: none; font: 700 26px var(--serif); color: var(--ink-3); }
.ghost.ghost-line { background: transparent; box-shadow: none; padding: 0; }

/* ── Toast & dialogs ───────────────────────────── */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: min(90vw, 520px); }
#toast button { margin-left: 12px; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--chrome); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 22, 26, .35); }
.dlg { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg h2 { margin: 0; font: 700 19px var(--serif); }
.dlg h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.dlg input { border: 1px solid var(--chrome-line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 9px 11px; font: inherit; outline: none; }
.dlg input:focus { border-color: var(--accent); }
.dlg p { margin: 0; }
.muted { color: var(--ink-2); font-size: 13px; }
.msg { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); }
.msg.err { background: rgba(214, 69, 61, .12); color: var(--danger); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--chrome-line); background: var(--chrome); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--tool-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn.link { border: 0; background: none; color: var(--ink-3); text-decoration: underline; padding: 0; align-self: flex-start; font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--tool-hover); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e0a83a; }
.pill.ok::before { background: #2fa36b; }
code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

html, body { overscroll-behavior: none; }
.back-btn, .eh-phone { display: none; }
.back-btn[hidden] { display: none !important; }

/* ── Phone (Milanote's phone layout: header with back arrow + centred title, board fills the screen,
      card tools in a bar along the bottom, zoom % pops up while pinching) ── */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  body { touch-action: manipulation; }
  #scroller { scrollbar-width: none; }
  #scroller::-webkit-scrollbar { display: none; }
  #app { grid-template-columns: 1fr; grid-template-rows: calc(48px + env(safe-area-inset-top)) 1fr calc(62px + env(safe-area-inset-bottom)); }
  #topbar { grid-template-columns: 1fr auto 1fr; gap: 4px; padding: env(safe-area-inset-top) 6px 0; }
  #crumbs, .save-state, #redoBtn { display: none; }
  .back-btn { display: grid; }
  .tb-center { display: block; min-width: 0; }
  #boardTitle { font-size: 19px; max-width: 52vw; }
  .icon-btn { width: 38px; height: 38px; }
  .tb-left:has(.back-btn:not([hidden])) .logo { display: none; }

  #tools { grid-row: 3; grid-column: 1; flex-direction: row; border-right: 0; border-top: 1px solid var(--chrome-line); padding-bottom: env(safe-area-inset-bottom); }
  .tb-dismiss { height: auto; width: 0; border-bottom: 0; border-right: 1px solid transparent; transition: opacity .1s ease-in-out, width .18s cubic-bezier(.3, 1, .7, 1); }
  .tb-dismiss.show { height: auto; width: 46px; border-right-color: var(--chrome-line); }
  .tb-window { height: 100%; }
  .tb-panel { width: var(--bar-w, 100vw); flex-direction: row; align-items: center; gap: 0; padding: 0 4px; overflow-x: auto; overflow-y: hidden; }
  .tool { width: 58px; padding: 4px 1px 3px; touch-action: pan-x; }
  .tl { font-size: 10px; white-space: nowrap; }
  .tool-sep { width: 1px; height: 34px; margin: 0 4px; }
  .tool-spacer, .tool-hint { display: none; }
  .tool-trash { margin: 0 4px 0 0; align-self: center; border-left: 1px solid var(--chrome-line); border-radius: 0; width: 56px; }
  .tool:hover .ti { box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); transform: none; }
  #tooltip { display: none; }

  .fp { max-width: calc(100vw - 16px); max-height: 60vh; overflow-y: auto; }
  .fp::before { left: var(--caret-x, 50%); top: auto; bottom: -5px; transform: translateX(-50%) rotate(45deg); }

  /* zoom %: hidden until you zoom, like Milanote's pill */
  #zoomctl { left: 50%; right: auto; bottom: calc(74px + env(safe-area-inset-bottom)); transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .25s; }
  #zoomctl.flash { opacity: 1; transition: opacity .05s; }
  #zoomctl button:not(#zoomLabel) { display: none; }
  #zoomctl #zoomLabel { font-size: 14px; min-width: 64px; height: 34px; }

  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .eh-desk { display: none; }
  .eh-phone { display: block; }

  .resize-handle { display: none; }
  dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
  dialog input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .col-gap, .el.into-board, .board-tile { transition: none; }
}

/* ───────── comments ───────── */
.cmt-badge { position: absolute; top: 6px; right: 6px; z-index: 3; min-width: 22px; height: 22px; padding: 0 6px; border: 0; border-radius: 11px 11px 11px 3px;
  background: #5882f8; color: #fff; font: 600 11px/22px var(--sans); text-align: center; cursor: pointer; box-shadow: 0 1px 3px rgba(20, 30, 60, .3);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), background .15s; }
.cmt-badge:hover { transform: scale(1.12); background: #4a74ec; }
.cmt-badge.open { background: #3b62d8; box-shadow: 0 0 0 3px rgba(88, 130, 248, .3); }
.el-board > .cmt-badge, .el-column > .cmt-badge { display: none; }

.thread-pop { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 16px); background: var(--panel); color: var(--ink); border-radius: 8px;
  box-shadow: 0 0 0 1px var(--card-line), 0 12px 32px rgba(15, 20, 30, .22); display: flex; flex-direction: column; max-height: min(520px, calc(100vh - 80px));
  animation: thIn .16s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes thIn { from { opacity: 0; transform: translateY(4px) scale(.97); } }
.th-list { overflow-y: auto; padding: 6px 0; border-bottom: 1px solid var(--card-line); }
.th-msg { display: flex; gap: 10px; padding: 8px 14px; }
.th-msg:hover .th-acts { opacity: 1; }
.th-av { flex: none; width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font: 600 12px var(--sans); }
.th-main { min-width: 0; flex: 1; }
.th-head { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.th-head b { font-weight: 600; }
.th-time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.th-acts { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.th-acts button { border: 0; background: none; color: var(--ink-3); font: 12px var(--sans); padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.th-acts button:hover { color: var(--ink); background: var(--tool-hover); }
@media (hover: none) { .th-acts { opacity: 1; } }
.th-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; margin-top: 1px; }
.th-text a { color: var(--accent); }
.th-edit textarea, .th-input { width: 100%; border: 0; resize: none; background: transparent; color: var(--ink); font: 14px/1.45 var(--sans); outline: none; }
.th-edit textarea { border: 1px solid var(--card-line); border-radius: 6px; padding: 6px 8px; background: var(--bg); }
.th-edit-acts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.th-edit-acts .btn, .th-send { padding: 4px 12px; font-size: 13px; min-height: 0; }
.th-reply { padding: 10px 14px; }
.th-input { display: block; min-height: 22px; padding: 2px 0; }
.th-input::placeholder { color: var(--ink-3); }
.th-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.th-as { color: var(--ink-3); font-size: 12px; margin-right: auto; display: flex; align-items: center; gap: 4px; }
.th-as button { border: 0; background: none; color: var(--ink-2); font: 600 12px var(--sans); padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.th-as button:hover { background: var(--tool-hover); color: var(--ink); }
.th-name-input { font: 600 12px var(--sans); width: 120px; border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; background: var(--bg); color: var(--ink); outline: none; }
.th-send:disabled { opacity: .45; cursor: default; }

/* a free-standing comment on the board */
.el-comment { padding: 6px 0 0; border-left: 3px solid #5882f8; }
.el-comment .cc-list { max-height: 260px; overflow: hidden; }
.el-comment .th-msg { padding: 6px 12px; }
.el-comment .cc-empty { padding: 8px 12px; color: var(--ink-3); font-style: italic; }
.cc-reply { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--card-line); background: none; color: var(--ink-3);
  font: 13px var(--sans); padding: 8px 12px; margin-top: 4px; cursor: pointer; }
.cc-reply:hover { color: var(--accent); }
.ghost .ghost-comment { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.ghost .ghost-comment svg { width: 18px; height: 18px; fill: none; stroke: #5882f8; stroke-width: 1.6; }

/* phones: comments open as a sheet from the bottom (after the comment styles so it wins) */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  /* comments open as a sheet from the bottom */
  .thread-pop { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-width: none; border-radius: 14px 14px 0 0;
    max-height: 70vh; padding-bottom: env(safe-area-inset-bottom); animation: thSheet .22s cubic-bezier(.2, .9, .3, 1); }
  @keyframes thSheet { from { transform: translateY(40%); opacity: 0; } }
  .th-input { font-size: 16px; } /* 16px stops iOS from zooming into the field */
  .th-acts { opacity: 1; }
  .cmt-badge { min-width: 26px; height: 26px; line-height: 26px; font-size: 12px; }
}

/* ───────── drawings ───────── */
.el-sketch { padding: 0; overflow: hidden; }
.sketch-wrap { position: relative; width: 100%; }
.sketch-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.sketch-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 150px; color: var(--ink-3); font-size: 13px; }
.sketch-empty svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.sk-editor { position: fixed; inset: 52px 0 0 0; z-index: 85; display: flex; background: var(--bg); animation: skIn .18s ease-out; }
.sk-editor.closing { animation: skOut .16s ease-in forwards; }
@keyframes skIn { from { opacity: 0; transform: scale(.985); } }
@keyframes skOut { to { opacity: 0; transform: scale(.985); } }
.sk-bar { flex: none; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; background: var(--rail); border-right: 1px solid var(--chrome-line); overflow-y: auto; }
.sk-group { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--chrome-line); }
.sk-btn { width: 60px; border: 0; background: none; border-radius: 9px; padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; color: var(--ink-2); font-size: 10.5px; }
.sk-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sk-btn:hover { background: var(--tool-hover); color: var(--ink); }
.sk-btn.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--card-line), var(--card-shadow); }
.sk-btn:disabled { opacity: .35; cursor: default; background: none; }
.sk-sizes { flex-direction: column; }
.sk-size { width: 40px; height: 30px; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.sk-size i { width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink-2); }
.sk-size:hover { background: var(--tool-hover); }
.sk-size.on { background: var(--accent-soft); }
.sk-size.on i { background: var(--accent); }
.sk-colors { display: grid; grid-template-columns: repeat(2, 24px); gap: 6px; }
.sk-color { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); cursor: pointer; }
.sk-color.on { box-shadow: 0 0 0 2px var(--rail), 0 0 0 4px var(--accent); }
.sk-done { margin-top: auto; padding: 7px 14px; }
.sk-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: crosshair;
  background-color: var(--card); background-image: var(--grid-dot); background-size: 20px 20px; }
.sk-stage[data-tool="erase"] { cursor: cell; }
.sk-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sk-hint { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); color: var(--ink-3); font-size: 14px; pointer-events: none; }
body.sk-open #zoomctl, body.sk-open #ctxbar { display: none; }

/* ───────── files ───────── */
.el-file { padding: 0; overflow: hidden; }
.file-media { position: relative; background: #000; }
.file-media video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.file-thumb { background: var(--bg); border-bottom: 1px solid var(--card-line); max-height: 460px; overflow: hidden; }
.file-thumb img { display: block; width: 100%; height: auto; pointer-events: none; }
.file-audio { position: relative; padding: 12px 12px 0; }
.file-audio audio { width: 100%; display: block; }
.file-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.file-ico { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.file-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 12px; color: var(--ink-3); }
.file-open { flex: none; width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-2); }
.file-open:hover { background: var(--tool-hover); color: var(--ink); }
.file-open svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.file-caption { padding: 0 12px 10px; font-size: 13px; color: var(--ink-2); margin-top: -4px; }
.file-caption:empty { display: none; }
.el-file.editing .file-caption:empty { display: block; }
.el-file.editing .file-caption:empty::before { content: attr(data-ph); color: var(--ink-3); }
.file-progress { height: 4px; background: var(--bg); overflow: hidden; }
.file-progress span { display: block; height: 100%; width: 40%; background: var(--accent); animation: fileProg 1.1s ease-in-out infinite; }
@keyframes fileProg { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ───────── trash ───────── */
.trash-tile { flex: none; width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: rgba(0, 0, 0, .55); overflow: hidden; }
.trash-tile svg { width: 18px; height: 18px; }
.trash-tile img { width: 100%; height: 100%; object-fit: cover; }
.trash-tile .tile-text { font-size: 13px; font-weight: 700; }
.trash-ico { flex: none; width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; background: var(--card); color: var(--ink-2); box-shadow: 0 0 0 1px var(--card-line); }
.trash-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.trash-forever { width: 30px; height: 30px; color: var(--ink-3); }
.trash-forever.sure { background: var(--danger); color: #fff; }
.fp-trash { width: 360px; }

/* ───────── header: search, share, view-only ───────── */
.share-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--chrome-line); background: var(--chrome); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; position: relative; }
.share-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-btn:hover, .share-btn.open { background: var(--tool-hover); }
.share-btn.shared::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: #2fa36b; box-shadow: 0 0 0 2px var(--chrome); }
#searchBtn.open { background: var(--tool-hover); color: var(--ink); }
.ro-badge { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--bg); border: 1px solid var(--chrome-line); padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.ro-badge[hidden] { display: none; }

.search-pop { position: fixed; top: 58px; right: 12px; z-index: 90; width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 76px); display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink); border-radius: 10px; box-shadow: 0 0 0 1px var(--card-line), 0 16px 40px rgba(15, 20, 30, .22); animation: thIn .14s ease-out; }
.sp-top { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.sp-field { flex: 1; display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--ink-2); border-radius: 8px; padding: 0 8px 0 10px; background: var(--card); }
.sp-field:focus-within { border-color: var(--accent); }
.sp-field > svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; }
.sp-field input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font: 16px var(--sans); padding: 9px 0; }
.sp-field input::-webkit-search-cancel-button { display: none; }
.sp-clear { flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--ink-3); color: var(--card); display: grid; place-items: center; cursor: pointer; padding: 0; }
.sp-clear svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.sp-close { display: none; }
.sp-mods { display: flex; align-items: center; gap: 10px; padding: 0 14px 8px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--card-line); }
.sp-mods[hidden] { display: none; }
.sp-sort select { border: 0; background: transparent; color: var(--ink); font: 600 13px var(--sans); cursor: pointer; padding: 2px 0; }
.sp-count { margin-left: auto; color: var(--ink-3); }
.sp-results { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
.sp-empty { padding: 18px 16px; color: var(--ink-3); font-size: 13.5px; line-height: 1.5; margin: 0; }
.sp-group { padding: 12px 0 8px; border-bottom: 1px solid var(--card-line); }
.sp-group:last-child { border-bottom: 0; }
.sp-crumb { padding: 0 16px 6px; font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-board, .sp-item, .sp-more { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.sp-board { padding: 4px 16px; }
.sp-tile { flex: none; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; color: rgba(0, 0, 0, .55); overflow: hidden; }
.sp-tile svg { width: 20px; height: 20px; }
.sp-tile img { width: 100%; height: 100%; object-fit: cover; }
.sp-tile .tile-text { font-weight: 700; font-size: 15px; }
.sp-tile.home { background: var(--bg); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--card-line); }
.sp-tile.home svg { fill: currentColor; stroke: none; }
.sp-bt { display: flex; flex-direction: column; min-width: 0; }
.sp-bt b { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-bt small { font-size: 12px; color: var(--ink-3); }
.sp-items { padding: 4px 0 0 58px; }
.sp-item { padding: 5px 16px 5px 8px; border-radius: 6px; font-size: 13.5px; }
.sp-ico { flex: none; width: 18px; height: 18px; color: var(--ink-3); }
.sp-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sp-item.is-comment .sp-ico { color: #5882f8; }
.sp-snip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-snip mark, #searchPill mark, mark.hl { background: #ffe14d; color: #1f2124; border-radius: 2px; padding: 0 1px; }
.sp-board.focused, .sp-item.focused { background: var(--accent-soft); }
.sp-more { padding: 4px 8px; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.sp-skel { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-bottom: 1px solid var(--card-line); }
.sp-skel i { display: block; height: 12px; border-radius: 6px; background: var(--bg); animation: skel 1.2s ease-in-out infinite; }
.sp-skel i:nth-child(1) { width: 40%; } .sp-skel i:nth-child(2) { width: 75%; height: 18px; } .sp-skel i:nth-child(3) { width: 55%; }
@keyframes skel { 50% { opacity: .45; } }
#searchPill { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px;
  background: var(--panel); color: var(--ink); border-radius: 10px; font-size: 13px; box-shadow: 0 0 0 1px var(--card-line), 0 8px 24px rgba(15, 20, 30, .18); white-space: nowrap; }
#searchPill[hidden] { display: none; }
#searchPill button { border: 0; background: none; width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; }
#searchPill button:hover { background: var(--tool-hover); }
#searchPill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.cmt-badge.hl { background: #ffd200; color: #1f2124; }

.hdr-pop { position: fixed; z-index: 90; width: 380px; max-width: calc(100vw - 16px); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 16px;
  box-shadow: 0 0 0 1px var(--card-line), 0 16px 40px rgba(15, 20, 30, .22); animation: thIn .14s ease-out; display: flex; flex-direction: column; gap: 12px; }
.hp-title { font-weight: 700; font-size: 15px; }
.hp-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.hp-switch input { position: absolute; opacity: 0; pointer-events: none; }
.hp-switch .sw { flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--ink-3); position: relative; transition: background .15s; margin-top: 2px; }
.hp-switch .sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.3, 1.4, .6, 1); }
.hp-switch input:checked + .sw { background: #2fa36b; }
.hp-switch input:checked + .sw::after { transform: translateX(16px); }
.hp-switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.hp-sw-text { display: flex; flex-direction: column; font-size: 13.5px; }
.hp-sw-text small { color: var(--ink-3); font-size: 12.5px; }
.hp-link { display: flex; gap: 8px; }
.hp-link input { flex: 1; min-width: 0; border: 1px solid var(--chrome-line); border-radius: 8px; padding: 8px 10px; background: var(--bg); color: var(--ink); font: 13px var(--sans); }
.hp-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }

/* someone viewing a shared link */
body.read-only #app { grid-template-columns: 1fr; }
body.read-only #tools, body.read-only #undoBtn, body.read-only #redoBtn, body.read-only #settingsBtn, body.read-only #searchBtn, body.read-only #shareBtn, body.read-only .save-state { display: none !important; }
body.read-only #viewport { grid-column: 1 / -1; grid-row: 2; }
body.read-only .th-reply, body.read-only .th-acts, body.read-only .cc-reply, body.read-only .resize-handle { display: none !important; }
body.read-only #boardTitle { cursor: default; }

/* phones */
@media (max-width: 700px), (pointer: coarse) and (max-height: 500px) {
  .share-btn span { display: none; }
  .share-btn { width: 38px; height: 38px; padding: 0; justify-content: center; border: 0; background: none; }
  .search-pop { inset: 0; top: 0; width: auto; max-height: none; border-radius: 0; padding-top: env(safe-area-inset-top); animation: thSheet .2s ease-out; }
  .sp-close { display: block; }
  .sp-item { padding-top: 8px; padding-bottom: 8px; }
  .hdr-pop { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100%; max-width: none; border-radius: 14px 14px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); animation: thSheet .22s ease-out; }
  #searchPill { bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.read-only #app { grid-template-rows: calc(48px + env(safe-area-inset-top)) 1fr; }
  body.read-only #searchPill { bottom: 22px; }
  .sk-editor { inset: 0; flex-direction: column-reverse; padding-top: env(safe-area-inset-top); }
  .sk-bar { width: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--chrome-line); overflow-x: auto; overflow-y: hidden; gap: 8px; }
  .sk-group { flex-direction: row; border-bottom: 0; padding: 0 8px 0 0; border-right: 1px solid var(--chrome-line); }
  .sk-btn { width: 48px; }
  .sk-done { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 2; box-shadow: 0 4px 14px rgba(15, 20, 30, .2); }
  .sk-colors { grid-template-columns: repeat(12, 24px); }
  .ro-badge { font-size: 11px; padding: 3px 8px; }
}
