:root {
  --bg: #14161a;
  --bg2: #1b1e24;
  --card: #20242b;
  --card2: #282d36;
  --line: #333a45;
  --text: #e6e8eb;
  --muted: #8b93a1;
  --accent: #e0a040;
  --accent2: #4fc3f7;
  --danger: #e5534b;
  --ok: #3fb950;
  --s-idea: #4fa3ff;
  --s-wip: #e0a040;
  --s-done: #3fb950;
  --radius: 10px;
  --topbar: 56px;
  --tabbar: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent2); text-decoration: none; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0; }
.muted { color: var(--muted); }
.icon { flex: none; }
[hidden] { display: none !important; }
.loading, .empty { padding: 40px; text-align: center; color: var(--muted); }

/* --- кнопки и контролы --- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn, .icon-btn, .tool, .seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 8px; cursor: pointer; text-decoration: none;
}
.btn { padding: 7px 12px; min-height: 36px; }
.btn.small { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn.big { padding: 10px 18px; min-height: 44px; font-size: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1205; font-weight: 600; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 36px; height: 36px; padding: 0; background: transparent; border-color: transparent; }
.icon-btn:hover, .btn:hover { border-color: #4a5260; }
.icon-btn.active { color: var(--accent); }
.icon-btn:disabled { opacity: .35; }
.danger { color: var(--danger) !important; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 13px; }
button.link:hover { color: var(--text); }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px;
  width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 6px 11px; min-height: 34px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--card2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 99px;
  background: var(--card2); color: var(--muted); font-size: 11px; line-height: 16px; border: 1px solid var(--line);
}
.badge.mod { background: var(--accent2); color: #04202c; border-color: transparent; font-weight: 700; }
.badge.comments { color: var(--text); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.s-idea.status-dot, .status-chip.s-idea { background: var(--s-idea); }
.s-wip.status-dot, .status-chip.s-wip { background: var(--s-wip); }
.s-done.status-dot, .status-chip.s-done { background: var(--s-done); }
.status-chip { padding: 3px 10px; border-radius: 99px; color: #111; font-size: 13px; background: var(--card2); }
.status-chip.s-none { color: var(--muted); }

/* --- каркас --- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: rgba(20, 22, 26, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 700; letter-spacing: .5px; }
.brand-mark { background: var(--accent); color: #1a1205; padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.brand.big { font-size: 26px; justify-content: center; }
.brand.big .brand-mark { font-size: 22px; }
.topnav { display: flex; gap: 4px; }
.topnav a, .tabbar a { display: flex; align-items: center; gap: 6px; color: var(--muted); padding: 7px 12px; border-radius: 8px; }
.topnav a.active, .tabbar a.active { color: var(--text); background: var(--card2); }
.user { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-name { font-size: 14px; }
.tabbar { display: none; }
.main { max-width: 1500px; margin: 0 auto; padding: 16px; }
body[data-route=board] .main { max-width: none; padding: 0; height: calc(100dvh - var(--topbar) - var(--tabbar)); }
body[data-route=board] { overflow: hidden; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.show-mobile { display: none !important; }

/* --- вход --- */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px; text-align: center; }
.login-error { color: var(--danger); min-height: 20px; font-size: 14px; }

/* --- каталог --- */
.catalog { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; }
.cat-sidebar { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100dvh - var(--topbar) - 32px);
  overflow: auto; padding-right: 6px; font-size: 13px; }
.nav-cat { margin-bottom: 12px; }
.nav-cat-title { font-weight: 700; border-left: 3px solid; padding-left: 8px; margin-bottom: 4px; }
.nav-ent { display: flex; justify-content: space-between; gap: 8px; padding: 3px 8px 3px 11px; color: var(--text); border-radius: 6px; }
.nav-ent:hover { background: var(--card2); }
.cat-toolbar { position: sticky; top: var(--topbar); z-index: 5; background: var(--bg); padding: 4px 0 12px;
  display: flex; flex-direction: column; gap: 10px; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search-wrap input { padding-left: 36px; min-height: 42px; }
.cat-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cat-count { margin-left: auto; font-size: 13px; }
.cat-heading { border-left: 4px solid; padding-left: 10px; margin: 26px 0 8px; font-size: 18px; }
.ent { margin-bottom: 22px; scroll-margin-top: calc(var(--topbar) + 110px); }
.ent-title { margin-bottom: 8px; font-size: 15px; }
.grid-img { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin-bottom: 10px; }
.grid-snd { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin-bottom: 10px; }
.grid-other { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--text); min-width: 0; }
.tile:hover { border-color: #4a5260; }
.tile-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-img { display: flex; flex-direction: column; overflow: hidden; }
.tile-img .tile-name { padding: 5px 7px; }
.thumb { aspect-ratio: 1; display: grid; place-items: center; color: var(--muted);
  background: repeating-conic-gradient(#262a31 0 25%, #1e2127 0 50%) 0 0 / 16px 16px; }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.thumb.split { grid-template-columns: 1fr 1fr; gap: 2px; }
.thumb.split img:last-child { outline: 2px solid var(--accent2); outline-offset: -2px; }
.badges { position: absolute; top: 5px; right: 5px; display: flex; gap: 3px; align-items: center; }
.tile-snd { display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 52px; }
.tile-snd .tile-name { flex: 1; font-size: 13px; }
.tile-snd .badges { position: static; }
.tile-other { display: flex; align-items: center; gap: 6px; padding: 6px 8px; color: var(--muted); }
.tile-other .tile-name { color: var(--text); flex: 1; }
.tile-other .badges { position: static; }
.play-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--card2); color: var(--accent); cursor: pointer; padding: 0 9px; }
.play-btn.small { min-width: 30px; height: 30px; font-size: 11px; }
.play-btn:has(span) { border-radius: 99px; color: var(--accent2); }
.play-btn.playing { background: var(--accent); color: #1a1205; }
.play-btn.big { min-width: 54px; height: 54px; }
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; }
.sheet-panel { background: var(--bg2); width: 100%; max-height: 80dvh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 15px; }
.sheet-body .nav-ent { padding: 8px 8px 8px 11px; }

/* --- плеер внизу --- */
.now-playing { position: fixed; left: 50%; bottom: calc(16px + var(--tabbar) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  z-index: 40; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; max-width: min(460px, calc(100% - 24px));
  background: var(--card2); border: 1px solid var(--line); border-radius: 99px; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  opacity: 0; visibility: hidden; pointer-events: none; transition: transform .2s, opacity .2s, visibility .2s; }
.now-playing.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; }
.np-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
body[data-route=board] .now-playing { bottom: calc(70px + var(--tabbar)); }

/* --- ассет --- */
.asset-view { max-width: 1100px; margin: 0 auto; }
.asset-head { margin-bottom: 14px; }
.asset-head-row { display: flex; align-items: center; gap: 8px; }
.asset-title { flex: 1; min-width: 0; }
.asset-title h1 { overflow-wrap: anywhere; }
.entity-link { font-size: 13px; }
.asset-nav { display: flex; align-items: center; gap: 2px; font-size: 12px; }
.path-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.path { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; overflow-wrap: anywhere; }
.status-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.status-seg button.active.s-idea { box-shadow: inset 0 -3px 0 var(--s-idea); }
.status-seg button.active.s-wip { box-shadow: inset 0 -3px 0 var(--s-wip); }
.status-seg button.active.s-done { box-shadow: inset 0 -3px 0 var(--s-done); }
.cmp { display: flex; flex-direction: column; gap: 12px; }
.checker { background: repeating-conic-gradient(#2a2e36 0 25%, #1f2228 0 50%) 0 0 / 20px 20px; border-radius: 8px; }
.cmp-single .checker, .cmp-fig .checker { display: grid; place-items: center; min-height: 160px; padding: 8px; }
.cmp-single img, .cmp-fig img { max-width: 100%; max-height: 60dvh; image-rendering: auto; }
.cmp-side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp-fig { margin: 0; }
.cmp-fig figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.cmp-fig figcaption b { color: var(--text); }
.cmp-overlay { position: relative; display: grid; place-items: center; touch-action: none; user-select: none; overflow: hidden; }
.cmp-overlay img { max-width: 100%; max-height: 62dvh; grid-area: 1 / 1; }
.cmp-overlay .cmp-top { width: 100%; height: 100%; object-fit: contain; }
.cmp-overlay img:first-child { width: 100%; height: 100%; object-fit: contain; }
.cmp-handle { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent2); box-shadow: 0 0 0 1px #000; pointer-events: none; }
.cmp-range { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.cmp-range input { flex: 1; accent-color: var(--accent2); }
.model-stub { text-align: center; color: var(--muted); padding: 20px; }
.tech { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; font-size: 13px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text); }
.chip:first-child { color: var(--accent); font-weight: 600; }
button.chip.copyable { cursor: pointer; }
button.chip.copyable:hover { border-color: var(--accent); }
.ab-timeline { display: flex; flex-direction: column; gap: 4px; }
.ab-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; align-items: center; }
.ab-lane-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-row.side-a .ab-lane-label { color: #e0a040; }
.ab-row.side-b .ab-lane-label { color: #4fc3f7; }
.ab-ruler { width: 100%; height: 18px; display: block; }
.ab-lane { width: 100%; height: 64px; display: block; border-radius: 6px; cursor: pointer; touch-action: none; }
.ab-diff { color: var(--text); }
.volume-wrap { display: flex; align-items: center; gap: 2px; }
.volume { width: 110px; accent-color: var(--accent); }
.ab { display: flex; flex-direction: column; gap: 10px; }
.ab-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ab-spacer { flex: 1; }
.wave { width: 100%; height: 72px; display: block; cursor: pointer; }
.wave.mini { height: 30px; cursor: default; }
.ab-bottom { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.variants { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.variant { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); }
.variant.selected { border-color: var(--accent2); }
.variant.comparing { box-shadow: 0 0 0 2px rgba(79, 195, 247, .35); }
.v-preview { width: 120px; flex: none; cursor: pointer; }
.v-thumb { width: 120px; height: 90px; object-fit: contain; border-radius: 6px;
  background: repeating-conic-gradient(#2a2e36 0 25%, #1f2228 0 50%) 0 0 / 14px 14px; }
.v-audio { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.v-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.v-file { overflow-wrap: anywhere; }
.v-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.warnings { margin: 2px 0; padding-left: 18px; color: #e3b341; font-size: 12px; }
.dropzone { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px; border: 2px dashed var(--line);
  border-radius: 10px; cursor: pointer; color: var(--muted); overflow: hidden; }
.dropzone b { color: var(--text); }
.dropzone.over { border-color: var(--accent); background: rgba(224, 160, 64, .08); }
.dropzone.busy { pointer-events: none; opacity: .7; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.comments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.thread { border-left: 2px solid var(--line); padding-left: 10px; }
.thread.resolved { opacity: .6; }
.replies { margin-left: 14px; border-left: 1px dashed var(--line); padding-left: 10px; }
.comment { padding: 4px 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 2px 0; }
.comment-actions { display: flex; gap: 12px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; }
.reply-box .comment-form { margin: 6px 0 4px; }

/* --- сейвы --- */
.save-btn { color: var(--accent); }
.save-btn.busy { opacity: .5; pointer-events: none; }
.saves-view { max-width: 900px; margin: 0 auto; }
.saves-list { display: flex; flex-direction: column; gap: 8px; }
.save-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
.save-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.save-name { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 15px; }
.save-name code { font-size: 15px; color: var(--text); }
.save-note { color: var(--muted); font-style: italic; }

/* --- сборка --- */
.build-view { max-width: 1000px; margin: 0 auto; }
.build-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 14px 0 6px; }
.build-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.build-form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); max-width: 360px; }
.build-form input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.build-list { display: flex; flex-direction: column; gap: 6px; }
.build-row { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; background: var(--bg2); color: var(--text); }
.build-thumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); flex: none; }
.build-thumbs img { width: 52px; height: 52px; object-fit: contain; background: #1f2228; border-radius: 4px; }
.build-info { min-width: 0; font-size: 13px; }
.build-info code { overflow-wrap: anywhere; }
.script { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 300px; white-space: pre; }
.steps { padding-left: 20px; font-size: 13px; }

/* --- холст --- */
.board { position: relative; width: 100%; height: 100%; overflow: hidden; background:
  radial-gradient(circle, #262a31 1px, transparent 1px) 0 0 / 24px 24px, var(--bg); }
.board-viewport { position: absolute; inset: 0; touch-action: none; overflow: hidden; cursor: default;
  /* iOS: долгое нажатие не должно открывать «Сохранить изображение» и выделять текст — им мы берём карточку */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.board-viewport img { -webkit-touch-callout: none; pointer-events: none; }
.board[data-tool=hand] .board-viewport { cursor: grab; }
.board[data-tool=pen] .board-viewport, .board[data-tool=arrow] .board-viewport { cursor: crosshair; }
.board[data-tool=note] .board-viewport { cursor: copy; }
.board[data-tool=eraser] .board-viewport { cursor: not-allowed; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.layer { position: absolute; left: 0; top: 0; }
.layer > * { position: absolute; left: 0; top: 0; }
.ink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.ink path { pointer-events: visibleStroke; }
.ink path.selected { filter: drop-shadow(0 0 4px #fff); }
.frame { border: 2px solid rgba(255, 255, 255, .12); border-radius: 14px; background: rgba(255, 255, 255, .025); }
.frame.category { border: 4px solid var(--frame-color); background: color-mix(in srgb, var(--frame-color) 6%, transparent); border-radius: 30px; }
.frame-title { position: absolute; left: 18px; bottom: 100%; margin-bottom: 6px; white-space: nowrap; font-weight: 700;
  font-size: calc(18px * min(var(--inv, 1), 6)); transform-origin: left bottom; color: #cfd5dd; }
.frame.entity .frame-title { left: 12px; bottom: auto; top: 12px; margin: 0; font-size: calc(17px * min(var(--inv, 1), 5)); max-width: none; }
.frame.category .frame-title { font-size: calc(46px * max(1, min(var(--inv, 1) * .6, 12))); color: var(--frame-color); }
.frame.selected { outline: 2px dashed var(--accent); outline-offset: 4px; }
.bcard { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--line); border-radius: 8px;
  overflow: hidden; user-select: none; font-size: 12px; }
.bcard.s-idea { border-color: var(--s-idea); }
.bcard.s-wip { border-color: var(--s-wip); }
.bcard.s-done { border-color: var(--s-done); }
.bcard.selected { box-shadow: 0 0 0 3px var(--accent); }
/* Захват долгим нажатием: на iOS вибрации нет, поэтому заметная визуальная отдача */
.bcard.lifted, .note.lifted { scale: 1.06; z-index: 5; box-shadow: 0 0 0 3px var(--accent), 0 18px 36px rgba(0, 0, 0, .7);
  transition: scale .12s ease-out; }
.mode-toggle { width: auto; padding: 0 10px; gap: 6px; font-size: 13px; border-color: var(--line); }
.mode-toggle.active { background: var(--accent); color: #1a1205; border-color: var(--accent); }
.bcard.pulse { animation: pulse 1.4s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(79, 195, 247, .9); } 100% { box-shadow: 0 0 0 40px rgba(79, 195, 247, 0); } }
.bcard-thumb { flex: 1; min-height: 0; display: grid; place-items: center;
  background: repeating-conic-gradient(#262a31 0 25%, #1e2127 0 50%) 0 0 / 14px 14px; }
.bcard-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.bcard-thumb.split { grid-template-columns: 1fr 1fr; gap: 2px; }
.bcard-thumb.split img:last-child { outline: 2px solid var(--accent2); outline-offset: -2px; }
.bcard-name { padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard-badges { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.bcard.k-snd { flex-direction: row; align-items: center; gap: 6px; padding: 0 8px; }
.bcard.k-snd .bcard-name { flex: 1; padding: 0; }
.bcard.k-snd .bcard-badges { top: 2px; }
.bcard.k-other { flex-direction: row; align-items: center; gap: 4px; padding: 0 6px; color: var(--muted); }
.bcard.k-other .bcard-name { color: var(--text); padding: 0; }
.bcard.lite { background: #2b3038; }
.bcard.lite .bcard-badges .badge { font-size: calc(11px * min(var(--inv, 1), 3)); }
.note { background: var(--note); color: #1d1d1d; border-radius: 4px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); padding: 10px 12px; display: flex; flex-direction: column; }
.note-text { flex: 1; white-space: pre-wrap; overflow: hidden; font-size: 15px; overflow-wrap: anywhere; }
.note-edit { flex: 1; background: transparent; border: 0; color: #1d1d1d; resize: none; padding: 0; min-height: 0; font-size: 15px; }
.note-author { font-size: 11px; opacity: .6; }
.note.selected { outline: 3px solid var(--accent); }
.note-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, .3) 50%); }
.cursor { display: flex; align-items: flex-start; gap: 2px; pointer-events: none; transform-origin: 0 0; transition: transform .08s linear; }
.cursor span { background: currentColor; border-radius: 4px; padding: 1px 5px; font-size: 11px; }
.cursor span::first-line { color: #111; }
.board-toolbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 10; display: flex; gap: 8px;
  align-items: center; padding: 6px; background: rgba(32, 36, 43, .95); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45); max-width: calc(100% - 20px); flex-wrap: wrap; justify-content: center; }
.tool-group { display: flex; gap: 3px; align-items: center; }
.tool { width: 36px; height: 36px; padding: 0; background: transparent; border-color: transparent; font-size: 18px; }
.tool.active { background: var(--card2); border-color: var(--accent); color: var(--accent); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: #fff; }
.zoom-label { font-size: 12px; color: var(--muted); min-width: 42px; text-align: center; }
.search-group { position: relative; }
.board-search { width: 200px; min-height: 34px; padding: 5px 9px; }
.suggest { position: absolute; bottom: calc(100% + 8px); left: 0; width: 340px; max-width: 80vw; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.suggest button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 7px 10px; background: none;
  border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; font-size: 13px; }
.suggest button:hover { background: var(--card2); }
.suggest .muted { font-size: 11px; overflow-wrap: anywhere; }
.board-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; z-index: 10; }
.board-status { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(32, 36, 43, .9); border: 1px solid var(--line); }
.board-status[data-kind=ok]::before { content: "● "; color: var(--ok); }
.board-status[data-kind=bad]::before { content: "● "; color: var(--danger); }
.board-status[data-kind=wait]::before { content: "● "; color: var(--accent); }
.board-peers { display: flex; gap: 4px; }
.peer { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #111; border: 2px solid var(--bg); }
.minimap { position: absolute; right: 12px; bottom: 14px; z-index: 9; width: 220px; height: 150px; border-radius: 10px;
  background: rgba(20, 22, 26, .85); border: 1px solid var(--line); cursor: pointer; }
.board-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 15; overflow: auto;
  background: var(--bg); border-left: 1px solid var(--line); padding: 14px; box-shadow: -10px 0 30px rgba(0, 0, 0, .4); }
.board.panel-open .minimap { display: none; }

/* --- уведомления --- */
.toasts { position: fixed; top: calc(var(--topbar) + 10px); left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 6px; }
.toast { background: var(--card2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); transition: opacity .4s; font-size: 14px; }
.toast.error { border-color: var(--danger); }
.toast.hide { opacity: 0; }

/* --- телефон --- */
@media (max-width: 760px) {
  :root { --topbar: 50px; --tabbar: calc(58px + env(safe-area-inset-bottom)); }
  .show-mobile { display: inline-flex !important; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); }
  .topnav { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--tabbar);
    padding-bottom: env(safe-area-inset-bottom); background: rgba(20, 22, 26, .96); border-top: 1px solid var(--line); }
  .tabbar a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; font-size: 11px; border-radius: 0; }
  .tabbar a.active { background: transparent; color: var(--accent); }
  .main { padding: 12px 12px calc(var(--tabbar) + 16px); }
  body[data-route=board] .main { height: calc(100dvh - var(--topbar) - env(safe-area-inset-top) - var(--tabbar)); }
  .catalog { grid-template-columns: 1fr; }
  .cat-sidebar { display: none; }
  .cat-toolbar { top: calc(var(--topbar) + env(safe-area-inset-top)); }
  .cat-filters .seg { width: 100%; }
  .cat-filters .seg button { flex: 1; padding: 6px 4px; }
  .cat-filters select { flex: 1; }
  .cat-count { margin-left: 0; width: 100%; }
  .grid-img { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .grid-snd { grid-template-columns: 1fr; }
  .grid-other { grid-template-columns: 1fr 1fr; }
  .ent { scroll-margin-top: calc(var(--topbar) + 170px); }
  .cmp-side { grid-template-columns: 1fr; }
  .ab-row { grid-template-columns: 1fr; gap: 2px; }
  .ruler-row .ab-lane-label { display: none; }
  .ab-lane { height: 56px; }
  .volume { width: 80px; }
  .variant { flex-direction: column; }
  .v-preview, .v-thumb { width: 100%; }
  .v-thumb { height: 160px; }
  .comment-form { flex-direction: column; align-items: stretch; }
  /* Панель холста на телефоне: одна строка с горизонтальной прокруткой, кнопки под палец */
  .board-toolbar { bottom: 10px; left: 8px; transform: none; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
    max-width: calc(100% - 16px); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .board-toolbar::-webkit-scrollbar { display: none; }
  .board-toolbar .tool { width: 40px; height: 40px; flex: none; }
  .board-toolbar .mode-toggle { width: auto; }
  .board-toolbar .swatch { width: 26px; height: 26px; flex: none; }
  .board-search { width: 130px; }
  .suggest { position: fixed; left: 8px; right: 8px; width: auto; bottom: calc(var(--tabbar) + 70px); }
  .note-resize { width: 30px; height: 30px; }
  .minimap { display: none; }
  .board-panel { width: 100%; padding: 12px 12px 40px; }
  input, select, textarea { font-size: 16px; } /* iOS не зумит поле при фокусе */
}
