/* Limmo — Personal Visual Planner */
:root {
  --bg: #F4F3EF;
  --dot: #CBC7BE;
  --grid-line: rgba(40, 36, 30, .07);
  --panel: #FFFFFF;
  --panel-2: #F3F2EE;
  --panel-3: #E9E7E2;
  --text: #1F2328;
  --muted: #6B6F76;
  --line: rgba(20, 20, 30, .09);
  --accent: #6D5DFC;
  --accent-2: #EEEBFF;
  --sel: #6D5DFC;
  --ink: #1F2328;
  --link: #5B6170;
  --card: #FFFFFF;
  --frame-fill: #FFFFFF;
  --shape-fill: #FFFFFF;
  --auto-swatch: linear-gradient(135deg, #1F2328 50%, #FFFFFF 50%);
  --shadow: 0 0 0 1px rgba(20, 20, 30, .05), 0 2px 4px rgba(20, 20, 30, .04), 0 8px 24px rgba(20, 20, 30, .08);
  --shadow-lg: 0 0 0 1px rgba(20, 20, 30, .06), 0 12px 40px rgba(20, 20, 30, .16);
  --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #17171B;
  --dot: #393942;
  --grid-line: rgba(255, 255, 255, .05);
  --panel: #232329;
  --panel-2: #2C2C33;
  --panel-3: #36363E;
  --text: #ECECF1;
  --muted: #9C9CA8;
  --line: rgba(255, 255, 255, .09);
  --accent: #8E80FF;
  --accent-2: #312C55;
  --sel: #8E80FF;
  --ink: #ECECF1;
  --link: #A3A6B4;
  --card: #26262D;
  --frame-fill: #1E1E24;
  --shape-fill: #2A2A31;
  --auto-swatch: linear-gradient(135deg, #ECECF1 50%, #1E1E24 50%);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, .08), 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body { position: fixed; inset: 0; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; }
#boot-error { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--panel); padding: 16px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 100; max-width: 90vw; }
#boot-error[hidden] { display: none; }

/* ================= canvas ================= */
#stage {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  contain: strict; cursor: default; outline: none;
}
#grid {
  position: absolute; left: -200px; top: -200px;
  width: calc(100% + 400px); height: calc(100% + 400px);
  pointer-events: none; will-change: transform;
}
.grid-dots #grid { background-image: radial-gradient(circle at 1px 1px, var(--dot) 1.15px, transparent 1.6px); }
.grid-lines #grid { background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px); }
.grid-plain #grid { display: none; }

#world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; will-change: transform; --z: 1; }
#layer-frames, #layer-items { position: absolute; left: 0; top: 0; }
.svg-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }

#stage[data-tool="hand"], #stage.space { cursor: grab; }
#stage[data-tool="hand"]:active, #stage.space:active { cursor: grabbing; }
#stage[data-tool="sticky"], #stage[data-tool="shape"], #stage[data-tool="frame"], #stage[data-tool="list"], #stage[data-tool="link"] { cursor: crosshair; }
#stage[data-tool="text"] { cursor: text; }
#stage[data-tool="pen"], #stage[data-tool="highlighter"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='3' fill='%236D5DFC' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 10 10, crosshair; }
#stage[data-tool="eraser"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='11' cy='11' r='8' fill='white' fill-opacity='.6' stroke='%236B6F76' stroke-width='1.5'/%3E%3C/svg%3E") 11 11, crosshair; }

/* ----- items ----- */
.it, .frame { position: absolute; left: 0; top: 0; }
.txt {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  line-height: 1.3; outline: none; min-width: 1px;
}
.txt a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.txt ul, .txt ol { margin: 0; padding-left: 1.2em; }
.txt p { margin: 0; }
.measure-box { position: fixed; left: 0; top: 0; width: 0; height: 0; overflow: hidden; contain: strict; visibility: hidden; pointer-events: none; }
.measure {
  position: absolute; left: 0; top: 0; width: 100px; visibility: hidden; pointer-events: none; contain: layout style;
  font-family: var(--font); overflow-wrap: normal; word-break: normal; white-space: pre-wrap; line-height: 1.3;
}

.sticky {
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px; color: #1F2328;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06), 0 6px 14px -6px rgba(0, 0, 0, .22);
}
.sticky .txt { width: 100%; max-height: 100%; overflow: hidden; }
.sticky.dark { color: #F4F4F6; }
[data-theme="dark"] .sticky { box-shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 6px 14px -6px rgba(0, 0, 0, .7); }

.text { padding: 2px 0; }
.text .txt { color: var(--ink); }

.shape { display: flex; align-items: center; justify-content: center; color: var(--ink); }
.shape .shape-bg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.shape .shape-bg path { stroke-linejoin: round; }
.shape .txt { position: relative; width: 100%; max-height: 100%; overflow: hidden; }

.frame-body { position: absolute; inset: 0; border-radius: 8px; box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgba(0, 0, 0, .04); }
[data-theme="dark"] .frame-body.tinted { background: color-mix(in srgb, var(--ff) 13%, var(--frame-fill)) !important; }
.frame.clear .frame-body { box-shadow: 0 0 0 1.5px var(--line); }
.frame-title {
  position: absolute; left: 0; bottom: 100%;
  padding: 0 2px calc(6px / var(--z)); max-width: 100%;
  font-size: calc(14px / var(--z)); font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25;
}
.frame-title .ft { display: inline-block; min-width: 2em; outline: none; }
.frame-title .ft:empty::before { content: attr(data-ph); opacity: .55; }
.frame.editing .frame-title { overflow: visible; }

.image { background: transparent; border-radius: 3px; }
.image img { display: block; width: 100%; height: 100%; object-fit: fill; border-radius: 3px; pointer-events: none; -webkit-user-drag: none; }
.image.loading { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.image.loading img { visibility: hidden; }

.pen { pointer-events: none; }
.pen svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.pen .hit { fill: none; stroke: transparent; pointer-events: stroke; stroke-linecap: round; stroke-linejoin: round; }
.pen .ink { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.pen.hl .ink { opacity: .42; }

.list {
  background: var(--card); color: var(--text); border-radius: 12px;
  padding: 14px 16px 12px;
  box-shadow: 0 0 0 1px var(--line), 0 6px 16px -8px rgba(0, 0, 0, .25);
  border-top: 4px solid var(--acc, #7C5CFC);
}
.list-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.list-title { flex: 1; font-size: 18px; font-weight: 650; line-height: 1.3; outline: none; min-height: 1.3em; overflow-wrap: anywhere; }
.list-title:empty::before, .lt:empty::before { content: attr(data-ph); opacity: .4; }
.list-prog { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list-items { display: flex; flex-direction: column; }
.li { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; font-size: 15px; line-height: 1.35; }
.cb { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 6px; border: 2px solid #BDBDC7; position: relative; cursor: pointer; transition: background .12s, border-color .12s; }
.cb::before { content: ''; position: absolute; inset: -9px; }
.li.done .cb { background: var(--acc, #7C5CFC); border-color: var(--acc, #7C5CFC); }
.li.done .cb::after { content: ''; position: absolute; left: 4px; top: 0; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.lt { flex: 1; min-width: 0; outline: none; overflow-wrap: anywhere; white-space: pre-wrap; }
.li.done .lt { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.li-add { color: var(--muted); font-size: 14px; padding: 5px 0 2px 28px; opacity: .75; cursor: pointer; }
.li-add:hover { opacity: 1; color: var(--accent); }
.list-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.list-bar i { display: block; height: 100%; background: var(--acc, #7C5CFC); width: 0; transition: width .25s ease; }
.list.complete .list-title { color: var(--muted); }

.link .hit { fill: none; stroke: transparent; stroke-width: calc(18px / var(--z)); pointer-events: stroke; stroke-linecap: round; }
.link .ln { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.link .ah, .link .as { stroke-linejoin: round; stroke-width: 1; }
.link.sel .ln { filter: drop-shadow(0 0 calc(3px / var(--z)) color-mix(in srgb, var(--sel) 70%, transparent)); }

.live-link { fill: none; stroke: var(--sel); stroke-width: calc(2px / var(--z)); stroke-dasharray: calc(6px / var(--z)) calc(5px / var(--z)); stroke-linecap: round; }
.live-head { fill: var(--sel); }
.live-ink { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.live-ink.hl { opacity: .42; }

/* editing */
.editing [contenteditable] { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; cursor: text; caret-color: var(--accent); }
.sticky.editing [contenteditable], .shape.editing [contenteditable] { caret-color: currentColor; }
.txt[contenteditable]:empty::before { content: attr(data-ph); opacity: .38; pointer-events: none; }
.sticky .txt[contenteditable]:empty::before, .shape .txt[contenteditable]:empty::before { content: '\200b'; }

/* ================= overlay ================= */
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.ov { position: absolute; left: 0; top: 0; pointer-events: none; }
.ov-box { border: 1.5px solid var(--sel); border-radius: 3px; }
.ov-box.locked { border-style: dashed; }
.ov-box.editing { border-color: color-mix(in srgb, var(--sel) 55%, transparent); }
.ov-item { border: 1px solid color-mix(in srgb, var(--sel) 55%, transparent); border-radius: 2px; }
.ov-hover { border: 1.5px solid color-mix(in srgb, var(--sel) 55%, transparent); border-radius: 3px; }
.ov-target { border: 2px solid var(--sel); border-radius: 6px; background: color-mix(in srgb, var(--sel) 10%, transparent); margin: -4px; padding: 4px; box-sizing: content-box; }
.ov-marquee { border: 1px solid var(--sel); background: color-mix(in srgb, var(--sel) 9%, transparent); border-radius: 2px; }
.ov-guides { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ov-guides line { stroke: #F43F8E; stroke-width: 1; stroke-dasharray: 4 3; }
.ov-h {
  position: absolute; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: #fff; border: 1.5px solid var(--sel); border-radius: 3px; pointer-events: auto;
}
.ov-h::after { content: ''; position: absolute; inset: -7px; }
.ov-h[data-h="n"], .ov-h[data-h="s"] { cursor: ns-resize; width: 16px; height: 8px; margin: -4px 0 0 -8px; border-radius: 4px; }
.ov-h[data-h="e"], .ov-h[data-h="w"] { cursor: ew-resize; width: 8px; height: 16px; margin: -8px 0 0 -4px; border-radius: 4px; }
.ov-h[data-h="nw"], .ov-h[data-h="se"] { cursor: nwse-resize; }
.ov-h[data-h="ne"], .ov-h[data-h="sw"] { cursor: nesw-resize; }
.ov-dot {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--sel); border: 2.5px solid #fff; pointer-events: auto; cursor: crosshair;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25); transition: scale .12s ease;
}
.ov-dot::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }
.ov-dot:hover { scale: 1.3; }
.ov-end {
  position: absolute; left: 0; top: 0; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  border-radius: 50%; background: #fff; border: 2px solid var(--sel); pointer-events: auto; cursor: move;
}
.ov-end::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }
@media (pointer: coarse) {
  .ov-h { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
  .ov-h::after { inset: -12px; }
  .ov-dot { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
  .ov-dot::after { inset: -12px; }
  .ov-end { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
  .ov-end::after { inset: -12px; }
}

/* ================= chrome ================= */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
.panel {
  position: fixed; display: flex; align-items: center;
  background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow);
}
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.btn {
  appearance: none; border: 0; background: transparent; color: var(--text);
  width: 40px; height: 40px; padding: 0; border-radius: 10px; flex: none;
  display: grid; place-items: center; cursor: pointer; position: relative;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { background: var(--panel-3); }
.btn.on { background: var(--accent-2); color: var(--accent); }
.btn:disabled { opacity: .35; cursor: default; background: transparent; }
.btn:focus-visible, .pbtn:focus-visible, .board-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.has-opts::after { content: ''; position: absolute; right: 4px; bottom: 4px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .35; }
.btn.accent { color: var(--accent); }
.btn.danger-hover:hover { color: #E5484D; }
.sep { flex: none; width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toolbar .sep { width: 24px; height: 1px; margin: 4px auto; }

.topbar-left { top: calc(12px + var(--st)); left: calc(12px + var(--sl)); height: 48px; padding: 0 4px; gap: 2px; max-width: calc(100vw - 230px); }
.logo { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 2px; font-weight: 750; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.logo-mark { width: 24px; height: 24px; flex: none; }
.logo.lg { font-size: 18px; }
.logo.lg .logo-mark { width: 28px; height: 28px; }
.board-name {
  appearance: none; border: 0; background: transparent; color: var(--text);
  padding: 7px 10px; border-radius: 9px; font-weight: 560; font-size: 14px;
  max-width: 280px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.board-name:hover { background: var(--panel-2); }
.topbar-right { top: calc(12px + var(--st)); right: calc(12px + var(--sr)); height: 48px; padding: 0 4px; gap: 2px; }
.sync-ind[data-state="ok"] { color: #2F9E5B; }
.sync-ind[data-state="syncing"] { color: var(--accent); }
.sync-ind[data-state="syncing"] .ic { animation: pulse 1.1s ease-in-out infinite; }
.sync-ind[data-state="error"], .sync-ind[data-state="auth"], .sync-ind[data-state="unconfigured"] { color: #E5484D; }
.sync-ind[data-state="offline"] { color: var(--muted); }
.sync-ind[data-state="off"] { color: var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }

.toolbar { left: calc(12px + var(--sl)); top: 50%; transform: translateY(-50%); flex-direction: column; padding: 6px; gap: 2px; }
.zoombar { right: calc(12px + var(--sr)); bottom: calc(12px + var(--sb)); height: 44px; padding: 0 2px; gap: 0; }
.zoombar .btn { width: 36px; height: 36px; }
.zoom-label { appearance: none; border: 0; background: transparent; min-width: 52px; height: 36px; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); cursor: pointer; }
.zoom-label:hover { background: var(--panel-2); }

.ctxbar { left: 0; top: 0; height: 44px; padding: 0 4px; gap: 1px; z-index: 12; transition: opacity .12s ease; will-change: transform; }
.ctxbar.hiding { opacity: 0; pointer-events: none; }
.ctxbar .btn { width: 36px; height: 36px; border-radius: 9px; }
.ctxbar .sep { height: 20px; margin: 0 3px; }
.ctxbar .text-btn { width: auto; min-width: 40px; padding: 0 8px; font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; }
.swatch-btn i { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); display: block; }
.ctx-count { font-size: 13px; color: var(--muted); padding: 0 8px 0 6px; white-space: nowrap; }

/* popovers & menus */
.popover { position: fixed; z-index: 30; background: var(--panel); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 8px; animation: pop .14s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.pop-col { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.pop-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 2px 4px 0; }
.pop-hint { font-size: 13px; color: var(--muted); padding: 2px 4px 4px; max-width: 200px; }
.row-btns { display: flex; gap: 2px; flex-wrap: wrap; }
.row-btns .btn { width: 38px; height: 38px; }
.btn.width i { display: block; border-radius: 50%; background: currentColor; }
.palette { display: grid; grid-template-columns: repeat(5, 30px); gap: 6px; padding: 2px; }
.sw { appearance: none; border: 0; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .1s; }
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.size-list { display: flex; flex-direction: column; min-width: 84px; max-height: 320px; overflow: auto; }
.size-list button { appearance: none; border: 0; background: transparent; text-align: left; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; }
.size-list button:hover { background: var(--panel-2); }
.size-list button.on { color: var(--accent); font-weight: 650; }
.menu { display: flex; flex-direction: column; min-width: 210px; }
.menu button { appearance: none; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--panel-2); }
.menu button .ic { width: 18px; height: 18px; color: var(--muted); }
.menu .danger { color: #E5484D; }
.menu .danger .ic { color: #E5484D; }
.menu .grow { flex: 1; }
.menu kbd { font: 12px var(--font); color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* sidebar */
.scrim { position: fixed; inset: 0; z-index: 38; background: rgba(12, 12, 20, .2); opacity: 0; pointer-events: none !important; transition: opacity .2s; }
.scrim.on { opacity: 1; pointer-events: auto !important; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 330px; max-width: 88vw;
  background: var(--panel); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  padding: calc(10px + var(--st)) 0 calc(6px + var(--sb)) var(--sl);
  transform: translateX(-104%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
.sidebar.open { transform: none; visibility: visible; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px 8px 16px; }
.sb-sec { padding: 8px 10px; }
.sb-sec.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sb-title { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.mini-btn { appearance: none; border: 0; background: var(--accent-2); color: var(--accent); display: flex; align-items: center; gap: 4px; padding: 5px 10px 5px 7px; border-radius: 8px; font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; cursor: pointer; }
.mini-btn .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.board-list { display: flex; flex-direction: column; gap: 1px; max-height: 38vh; overflow: auto; }
.brow { display: flex; align-items: center; gap: 10px; padding: 7px 6px 7px 8px; border-radius: 10px; cursor: pointer; }
.brow:hover { background: var(--panel-2); }
.brow.on { background: var(--accent-2); }
.brow.on .bicon { color: var(--accent); }
.bicon .ic { width: 18px; height: 18px; color: var(--muted); }
.bname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bname b { font-weight: 560; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bname small { font-size: 12px; color: var(--muted); }
.row-more { appearance: none; border: 0; background: transparent; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted); opacity: 0; }
.brow:hover .row-more, .brow.on .row-more { opacity: 1; }
@media (hover: none) { .row-more { opacity: 1; } }
.row-more:hover { background: var(--panel-3); }
.search { width: 100%; height: 38px; border: 0; border-radius: 10px; background: var(--panel-2); color: var(--text); padding: 0 12px; font: inherit; font-size: 15px; outline: none; margin-bottom: 6px; }
.search:focus { box-shadow: 0 0 0 2px var(--accent); }
.outline { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.outline .row { appearance: none; border: 0; background: transparent; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; text-align: left; cursor: pointer; }
.outline .row:hover { background: var(--panel-2); }
.outline .row .ic { width: 17px; height: 17px; color: var(--muted); }
.outline .row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline .empty { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.sb-foot { display: flex; justify-content: space-between; padding: 8px 16px; border-top: 1px solid var(--line); }
.link-btn { appearance: none; border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px 2px; }
.link-btn:hover { color: var(--accent); }

/* modals */
.modal-root:empty { display: none; }
.modal-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(12, 12, 20, .32); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-height: calc(100vh - 32px); overflow: auto; animation: pop .18s cubic-bezier(.2, .9, .3, 1.15); }
.modal.small { max-width: 400px; }
.modal.wide { max-width: 680px; }
.dialog { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { margin: 0; font-size: 18px; }
.dialog p { margin: 0; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.field { width: 100%; height: 42px; border: 0; border-radius: 10px; background: var(--panel-2); color: var(--text); padding: 0 12px; font: inherit; font-size: 15px; outline: none; }
.field:focus { box-shadow: 0 0 0 2px var(--accent); }
.pbtn { appearance: none; border: 0; background: var(--panel-2); color: var(--text); height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 560; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.pbtn:hover { background: var(--panel-3); }
.pbtn.primary { background: var(--accent); color: #fff; }
.pbtn.primary:hover { filter: brightness(1.06); }
.pbtn.danger { background: #E5484D; color: #fff; }
.pbtn:disabled { opacity: .5; }
.pbtn .ic { width: 18px; height: 18px; }

.settings { display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto 1fr; min-height: 420px; }
.set-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px 22px; }
.set-head h2 { margin: 0; font-size: 20px; }
.set-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px 16px; }
.set-nav button { appearance: none; border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-weight: 520; }
.set-nav button:hover { background: var(--panel-2); }
.set-nav button.on { background: var(--accent-2); color: var(--accent); }
.set-body { padding: 6px 22px 22px 8px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; }
.set-row > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.set-row small { color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; flex: none; }
.seg button { appearance: none; border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.lead { margin: 0; color: var(--muted); }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: -8px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline.wrap { flex-wrap: wrap; }
.status-pill { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); font-size: 13.5px; }
.status-pill.s-ok { background: color-mix(in srgb, #2F9E5B 14%, var(--panel)); }
.status-pill.s-auth, .status-pill.s-error, .status-pill.s-unconfigured { background: color-mix(in srgb, #E5484D 12%, var(--panel)); }
.howto { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; color: var(--muted); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.krow { display: flex; align-items: center; gap: 10px; font-size: 13px; min-width: 0; }
.krow kbd { flex: none; min-width: 64px; font: 12px var(--font); background: var(--panel-2); border-radius: 6px; padding: 3px 7px; color: var(--text); box-shadow: inset 0 -1px 0 var(--line); }
.about-head { display: flex; align-items: center; gap: 12px; }
.about-head .logo-mark { width: 44px; height: 44px; }
.about-head div { display: flex; flex-direction: column; }
.about-head b { font-size: 20px; }
.about-head span { color: var(--muted); font-size: 13px; }
.settings h4 { margin: 6px 0 -4px; }
.cl { font-size: 13.5px; }
.cl small { color: var(--muted); margin-left: 8px; }
.cl ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: calc(20px + var(--sb)); transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none !important; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: #24242B; color: #F2F2F6; padding: 10px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 14px; max-width: min(92vw, 480px); animation: toast-in .2s ease; }
[data-theme="dark"] .toast { background: #3A3A44; }
.toast button { appearance: none; border: 0; background: transparent; color: #B9AEFF; font-weight: 650; cursor: pointer; padding: 2px 4px; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ================= phones & small tablets ================= */
.desk { }
@media (max-width: 720px) {
  .desk { display: none !important; }
  .topbar-left { top: calc(8px + var(--st)); left: calc(8px + var(--sl)); height: 44px; max-width: calc(100vw - 196px); }
  .topbar-left .logo, .topbar-left .sep { display: none; }
  .board-name { max-width: 44vw; padding: 6px 6px; }
  .topbar-right { top: calc(8px + var(--st)); right: calc(8px + var(--sr)); height: 44px; }
  .topbar-left .btn, .topbar-right .btn { width: 38px; height: 38px; }
  .toolbar {
    top: auto; left: 50%; bottom: calc(10px + var(--sb)); transform: translateX(-50%);
    flex-direction: row; padding: 5px; max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .btn { width: 38px; height: 42px; }
  .toolbar .sep { width: 1px; height: 22px; margin: 0 3px; }
  .zoombar { bottom: calc(70px + var(--sb)); right: calc(8px + var(--sr)); height: 38px; }
  .zoombar .btn { width: 34px; height: 34px; }
  .zoom-label { min-width: 46px; font-size: 12px; }
  .toasts { bottom: calc(120px + var(--sb)); }
  .settings { grid-template-columns: 1fr; }
  .set-nav { flex-direction: row; overflow-x: auto; padding: 0 12px 6px; }
  .set-nav button { white-space: nowrap; }
  .set-body { padding: 6px 18px 22px; }
  .set-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .keys { grid-template-columns: 1fr; }
  .modal.wide { max-height: calc(100vh - 24px); }
  .inline:not(.wrap) { flex-direction: column; align-items: stretch; }
}
@media (max-width: 380px) {
  .toolbar .btn { width: 35px; }
  .toolbar .sep { margin: 0 1px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.noscript { position: fixed; inset: 0; display: grid; place-items: center; }
