/* ============ Tokens ============ */
:root {
  color-scheme: light dark;
  --bg: #f2f2f5; --bg-2: #ffffff; --dot: rgba(0,0,0,.14);
  --panel: rgba(255,255,255,.72); --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.14);
  --fg: #1c1c1e; --muted: #7b7b84; --hover: rgba(0,0,0,.06);
  --ok: #30c26b;
  --accent: #ff6b45; --accent-2: #ff8a6a; --accent-soft: rgba(255,107,69,.16); --on-accent: #fff;
  --shadow: 0 10px 30px rgba(20,20,30,.16), 0 2px 6px rgba(20,20,30,.08);
  --shadow-lg: 0 24px 60px rgba(20,20,30,.22), 0 4px 10px rgba(20,20,30,.08);
  --glass-shadow: 0 10px 40px rgba(0,0,0,.14), 0 0 0 .5px rgba(0,0,0,.06);
  --radius: 14px;
  --ease: cubic-bezier(.2,.8,.2,1); --spring: cubic-bezier(.34,1.3,.5,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214; --bg-2: #1b1b1f; --dot: rgba(255,255,255,.11);
    --panel: rgba(32,32,37,.74); --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14);
    --fg: #ededf0; --muted: #8b8b94; --hover: rgba(255,255,255,.08);
    --ok: #3ddc84;
    --accent: #ff7a59; --accent-2: #ffb199; --accent-soft: rgba(255,122,89,.22); --on-accent: #141414;
    --shadow: 0 14px 40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.3);
    --shadow-lg: 0 30px 80px rgba(0,0,0,.65), 0 4px 10px rgba(0,0,0,.4);
    --glass-shadow: 0 10px 40px rgba(0,0,0,.4), 0 0 0 .5px rgba(255,255,255,.06);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--fg);
  -webkit-font-smoothing: antialiased; overflow: hidden; user-select: none; -webkit-user-select: none; cursor: default;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: default; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.spacer { flex: 1; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
@keyframes popOut { to { opacity: 0; transform: scale(.9); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toolsIn { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes breathe { 0%, 100% { opacity: .55; } 50% { opacity: .9; } }

/* ============ Glass ============ */
.glass {
  background: var(--panel);
  backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--line); box-shadow: var(--glass-shadow);
}

/* ============ Home ============ */
#home { height: 100%; overflow: auto; padding: 56px clamp(20px, 6vw, 96px) 80px; animation: fade .25s var(--ease); }
html.app #home { padding-top: 32px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 36px; }
.home-head h1 { font-size: 40px; letter-spacing: -.03em; margin: 0 0 6px; font-weight: 700; }
.home-head p { margin: 0; font-size: 14px; }
.btn { padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: transform .15s var(--spring), background .15s, box-shadow .2s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px rgba(255,107,69,.3); }
.btn.primary:hover { background: var(--accent-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; }
.card {
  position: relative; border-radius: 18px; background: var(--bg-2); border: 1px solid var(--line);
  overflow: hidden; transition: transform .25s var(--spring), box-shadow .25s var(--ease), border-color .2s;
  animation: rise .45s var(--ease) both; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card:hover { transform: translateY(-4px) scale(1.01); border-color: var(--line-2); box-shadow: var(--shadow); }
.card:active { transform: translateY(-1px) scale(.99); transition-duration: .1s; }
.card .cover { aspect-ratio: 4 / 3; background-size: cover; background-position: center; display: grid; place-items: center; transition: transform .6s var(--ease); }
.card:hover .cover { transform: scale(1.03); }
.card .cover.empty { font-size: 13px; color: rgba(255,255,255,.6); letter-spacing: .02em; }
.card .meta { padding: 14px 16px 16px; background: var(--bg-2); position: relative; }
.card .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .del {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 10px;
  background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(8px); opacity: 0; transform: scale(.9);
  transition: opacity .15s, transform .15s var(--spring), background .15s; font-size: 18px; line-height: 1;
}
.card:hover .del { opacity: 1; transform: none; }
.card .del:hover { background: #e0443a; }

/* ============ Auth ============ */
#auth { height: 100%; display: grid; place-items: center; padding: 24px; animation: fade .25s var(--ease); }
.auth-card { width: min(380px, 100%); padding: 32px 28px 24px; border-radius: 22px; display: flex; flex-direction: column; gap: 12px; animation: pop .35s var(--spring); }
.auth-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); margin-bottom: 4px;
  background-image: linear-gradient(135deg, rgba(255,255,255,.25), transparent); box-shadow: 0 6px 18px rgba(255,107,69,.35); }
.auth-card h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.auth-card p { margin: 0 0 6px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.auth-card input { font: inherit; font-size: 15px; color: var(--fg); background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-card .btn { margin-top: 6px; width: 100%; }
.auth-error { color: #e5484d; font-size: 13px; margin: 0; }
.auth-card a { color: var(--accent); text-decoration: none; }
.home-actions { display: flex; align-items: center; gap: 14px; }
.account { display: flex; align-items: center; gap: 10px; }
.invite-out { margin: -16px 0 24px; font-size: 14px; }
.invite-out code { font-size: 16px; font-weight: 700; letter-spacing: .06em; background: var(--hover); padding: 4px 10px; border-radius: 8px; user-select: text; -webkit-user-select: text; }
.invite-out a { color: var(--accent); text-decoration: none; margin-left: 8px; }

/* ============ Board ============ */
#board { position: fixed; inset: 0; animation: fade .3s var(--ease); }
#viewport {
  position: absolute; inset: 0; overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 24px 24px; touch-action: none;
}
#viewport.panning { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; --s: 1; }
#hint {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none;
  font-size: 20px; font-weight: 600; color: var(--muted); line-height: 1.5; animation: breathe 4s ease-in-out infinite;
}
#hint span { font-size: 13px; font-weight: 400; opacity: .7; }
.guide { position: absolute; background: var(--ok); pointer-events: none; opacity: .95; z-index: 45; }
#marquee { position: absolute; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 4px; pointer-events: none; z-index: 40; }
#viewport.grab { cursor: grab; }
#world.multi .item .rs { display: none; }
.gap { position: absolute; background: var(--ok); pointer-events: none; }
.gap.h { height: calc(1px / var(--s)); }
.gap.v { width: calc(1px / var(--s)); }
.gap::before, .gap::after { content: ""; position: absolute; background: var(--ok); }
.gap.h::before, .gap.h::after { top: calc(-5px / var(--s)); width: calc(1px / var(--s)); height: calc(11px / var(--s)); }
.gap.h::before { left: 0; } .gap.h::after { right: 0; }
.gap.v::before, .gap.v::after { left: calc(-5px / var(--s)); height: calc(1px / var(--s)); width: calc(11px / var(--s)); }
.gap.v::before { top: 0; } .gap.v::after { bottom: 0; }
.gap span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ok); color: #fff; font-size: calc(11px / var(--s)); font-weight: 600; padding: calc(2px / var(--s)) calc(6px / var(--s)); border-radius: calc(5px / var(--s)); white-space: nowrap; font-variant-numeric: tabular-nums; }
.item.sel.snapped { outline-color: var(--ok); }
.item.sel.snapped .rs { border-color: var(--ok); }
.guide.v { width: 1px; top: 0; bottom: 0; }
.guide.h { height: 1px; left: 0; right: 0; }

.topbar {
  position: absolute; top: 14px; left: 14px; right: 14px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; z-index: 50; animation: rise .4s var(--ease) both;
}
html.app .topbar { display: none; }
.topbar .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; transition: background .15s, transform .15s var(--spring); }
.topbar .icon svg { width: 20px; height: 20px; }
.topbar .icon:hover, .pill:hover { background: var(--hover); }
.topbar .icon:active, .pill:active { transform: scale(.94); }
.bname { font-weight: 600; font-size: 15px; padding: 6px 10px; border-radius: 8px; outline: none; min-width: 60px; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .15s; }
.bname:hover { background: var(--hover); }
.bname:focus { background: var(--hover); text-overflow: clip; user-select: text; -webkit-user-select: text; }
.pill { padding: 7px 11px; border-radius: 9px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); transition: background .15s, color .15s, transform .15s var(--spring); min-width: 52px; }
.pill:hover { color: var(--fg); }

/* Контекстная панель объекта */
.tools { position: absolute; z-index: 60; border-radius: 13px; padding: 5px; display: flex; align-items: center; gap: 2px; white-space: nowrap; animation: toolsIn .22s var(--ease) both; }
.tools.moving { animation: none; }
.tools button { height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; color: var(--fg); transition: background .12s, transform .15s var(--spring); }
.tools button:hover { background: var(--hover); }
.tools button:active { transform: scale(.92); }
.tools button.on { background: var(--accent-soft); color: var(--accent); }
.tools button svg { width: 16px; height: 16px; }
.tools .sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.tools .num { width: 42px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
.tools .sw { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; margin: 0 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); transition: transform .15s var(--spring), border-color .15s; }
.tools .sw:hover { transform: scale(1.15); }
.tools .sw.on { border-color: var(--fg); transform: scale(1.1); }
.tools .danger:hover { background: rgba(255,70,70,.18); color: #e5484d; }

/* ============ Items ============ */
.item { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; animation: pop .3s var(--spring) both; }
.item.still { animation: none; }
.item.leaving { animation: popOut .18s var(--ease) forwards; pointer-events: none; }
.item.sel { outline: calc(2px / var(--s)) solid var(--accent); outline-offset: calc(3px / var(--s)); border-radius: calc(12px / var(--s)); }
.item .rs {
  position: absolute; right: calc(-8px / var(--s)); bottom: calc(-8px / var(--s)); width: calc(16px / var(--s)); height: calc(16px / var(--s));
  border-radius: 50%; background: #fff; border: calc(2px / var(--s)) solid var(--accent); cursor: nwse-resize; display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.item.sel .rs { display: block; animation: pop .2s var(--spring) both; }
.item.sel .rs:hover { background: var(--accent); }

.item img, .item video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.item img { opacity: 0; transition: opacity .35s var(--ease); }
.item img.ok { opacity: 1; }
.item.image, .item.video, .item.carousel { border-radius: 12px; box-shadow: var(--shadow); background: var(--bg-2); transition: box-shadow .25s var(--ease); }
.item.image:hover, .item.video:hover, .item.carousel:hover { box-shadow: var(--shadow-lg); }
.item.carousel .car { border-radius: 12px; overflow: hidden; }
/* Уровни детализации: превью снизу, оригинал поверх с плавным появлением; обложка видео и плеер так же */
.item.image .thumb, .item.image .full, .item.video .poster, .item .player { position: absolute; inset: 0; border-radius: 12px; }
.item .player { opacity: 0; transition: opacity .25s var(--ease); }
.live > .player { opacity: 1; }
.item.off { visibility: hidden; }
#world.zooming .item { box-shadow: none !important; transition: none; }
.play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; transition: opacity .2s, transform .25s var(--spring); }
.play::before { content: ""; width: calc(64px / var(--s)); height: calc(64px / var(--s)); border-radius: 50%; background: rgba(0,0,0,.45); backdrop-filter: blur(8px); display: block; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.play::after { content: ""; position: absolute; width: 0; height: 0; border-left: calc(22px / var(--s)) solid #fff; border-top: calc(13px / var(--s)) solid transparent; border-bottom: calc(13px / var(--s)) solid transparent; margin-left: calc(6px / var(--s)); }
.live > .play { opacity: 0; transform: scale(1.15); }
.item.video .badge { position: absolute; left: calc(10px / var(--s)); bottom: calc(10px / var(--s)); font-size: calc(11px / var(--s)); font-weight: 600; letter-spacing: .04em; background: rgba(0,0,0,.55); color: #fff; padding: calc(3px / var(--s)) calc(7px / var(--s)); border-radius: calc(6px / var(--s)); pointer-events: none; }

.car { position: relative; width: 100%; height: 100%; }
.car .track { position: absolute; inset: 0; display: flex; transition: transform .5s var(--ease); }
.car .slide { flex: none; width: 100%; height: 100%; position: relative; overflow: hidden; background: var(--bg-2); }
.car .slide img, .car .slide video { position: absolute; inset: 0; }
/* Пустой слайд «+» у своих каруселей */
.car .slide.add { display: grid; place-items: center; background: var(--bg-2); }
.car .slide.add .sadd { display: flex; flex-direction: column; align-items: center; gap: calc(10px / var(--s)); color: var(--muted); font-size: calc(14px / var(--s)); font-weight: 600; width: 100%; height: 100%; justify-content: center; transition: color .15s; }
.car .slide.add .sadd svg { width: calc(64px / var(--s)); height: calc(64px / var(--s)); padding: calc(14px / var(--s)); border-radius: 50%; background: var(--hover); color: var(--fg); transition: transform .2s var(--spring), background .15s; }
.car .slide.add .sadd:hover { color: var(--fg); } .car .slide.add .sadd:hover svg { transform: scale(1.06); background: var(--accent-soft); }
/* Режим редактирования: кнопка удаления на самом слайде */
.car .slide .sdel { display: none; position: absolute; left: calc(10px / var(--s)); top: calc(10px / var(--s)); width: calc(34px / var(--s)); height: calc(34px / var(--s)); border-radius: 50%; background: rgba(0,0,0,.55); backdrop-filter: blur(8px); color: #fff; place-items: center; z-index: 3; transition: background .15s, transform .15s var(--spring); }
.car .slide .sdel svg { width: calc(18px / var(--s)); height: calc(18px / var(--s)); }
.item.carousel.editing .slide:not(.add) .sdel { display: grid; animation: pop .2s var(--spring); }
.car .slide .sdel:hover { background: #e5484d; } .car .slide .sdel:active { transform: scale(.9); }
.item.carousel.editing { outline-color: var(--ok); }
.car .nav {
  position: absolute; top: 50%; transform: translateY(-50%) scale(.9); width: calc(36px / var(--s)); height: calc(36px / var(--s)); border-radius: 50%;
  background: rgba(0,0,0,.45); backdrop-filter: blur(8px); color: #fff; font-size: calc(22px / var(--s)); line-height: 1; opacity: 0;
  transition: opacity .18s, transform .2s var(--spring), background .15s; display: grid; place-items: center; padding-bottom: calc(3px / var(--s));
}
.car .nav.prev { left: calc(10px / var(--s)); } .car .nav.next { right: calc(10px / var(--s)); }
.item:hover .car .nav { opacity: 1; transform: translateY(-50%) scale(1); }
.car .nav:hover { background: rgba(0,0,0,.7); }
.car .nav:active { transform: translateY(-50%) scale(.9); }
.car .dots { position: absolute; left: 0; right: 0; bottom: calc(10px / var(--s)); display: flex; justify-content: center; gap: calc(5px / var(--s)); pointer-events: none; }
.car .dots i { width: calc(6px / var(--s)); height: calc(6px / var(--s)); border-radius: calc(3px / var(--s)); background: rgba(255,255,255,.45); display: block; transition: width .3s var(--spring), background .2s; }
.car .dots i.on { background: #fff; width: calc(16px / var(--s)); }
.car .cnt { position: absolute; top: calc(10px / var(--s)); right: calc(10px / var(--s)); font-size: calc(11px / var(--s)); font-weight: 600; background: rgba(0,0,0,.5); color: #fff; padding: calc(3px / var(--s)) calc(7px / var(--s)); border-radius: calc(6px / var(--s)); pointer-events: none; font-variant-numeric: tabular-nums; }

.item.text { min-height: 1em; }
.item.text .tx {
  font-family: var(--font); line-height: 1.25; letter-spacing: -.01em; white-space: pre-wrap; word-wrap: break-word; outline: none;
  min-height: 1.25em; padding: .15em .2em; border-radius: .3em; color: var(--fg); transition: background .2s, color .2s;
}
.item.text.sticker .tx { padding: .7em .8em; border-radius: .5em; box-shadow: var(--shadow); }
/* «Тег»: текст поверх медиа получает обводку и подложку, чтобы читался; .clear — свободен, зелёный контур гаснет */
.item.text.tagged .tx { outline: calc(2px / var(--s)) solid var(--accent); outline-offset: calc(4px / var(--s)); border-radius: .4em; transition: outline-color .3s, background .3s; }
.item.text.tagged:not(.sticker) .tx { background: color-mix(in srgb, var(--bg) 88%, transparent); }
.item.text.tagged.clear .tx { outline-color: var(--ok); }
.item.text.tagged.clear:not(.sticker) .tx { background: transparent; }
.item.text .tx[contenteditable="true"] { cursor: text; user-select: text; -webkit-user-select: text; caret-color: var(--accent); }
.item.text .tx:empty::before { content: "Введите текст"; opacity: .35; }

/* ============ Lightbox ============ */
#lightbox {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 48px;
  background: rgba(0,0,0,.72); backdrop-filter: blur(30px) saturate(1.2); -webkit-backdrop-filter: blur(30px) saturate(1.2);
  animation: fade .2s var(--ease);
}
#lightbox.closing { animation: fade .18s var(--ease) reverse forwards; }
#lightbox .lb { max-width: 100%; max-height: 100%; display: grid; place-items: center; animation: pop .3s var(--spring); position: relative; }
#lightbox img, #lightbox video { max-width: calc(100vw - 96px); max-height: calc(100vh - 96px); border-radius: 12px; box-shadow: var(--shadow-lg); object-fit: contain; }
#lightbox .lbnav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 26px; display: grid; place-items: center; padding-bottom: 3px; transition: background .15s, transform .15s var(--spring); }
#lightbox .lbnav:hover { background: rgba(255,255,255,.26); }
#lightbox .lbnav:active { transform: translateY(-50%) scale(.92); }
#lightbox .lbnav.prev { left: -60px; } #lightbox .lbnav.next { right: -60px; }
#lightbox .lbcnt { position: absolute; bottom: -34px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.7); font-size: 13px; font-variant-numeric: tabular-nums; }

#toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: 100px; z-index: 300;
  background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); pointer-events: none; animation: toastIn .3s var(--spring) both;
}
#toast.out { animation: toastOut .2s var(--ease) forwards; }
#toast.progress { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; align-items: center; min-width: 260px; padding: 10px 14px 11px; }
#toast .pct { font-variant-numeric: tabular-nums; opacity: .6; font-size: 12px; }
#toast .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--bg) 25%, transparent); margin-top: 8px; overflow: hidden; }
#toast .bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); transition: width .4s var(--ease); }

/* ============ Лист вставки ссылки ============ */
.sheet { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; width: min(520px, calc(100% - 24px));
  border-radius: 16px; padding: 10px; display: flex; gap: 8px; align-items: center; animation: toolsIn .22s var(--ease); }
.sheet input { flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--fg); background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.sheet input:focus { border-color: var(--accent); }
.sheet .btn { padding: 10px 14px; }

/* ============ Ввод текста на телефоне ============ */
.textsheet { display: none; }
html.mobile .textsheet {
  display: flex; flex-direction: column; gap: 8px; position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom) + var(--kb, 0px)); z-index: 80;
  border-radius: 16px; padding: 10px; animation: toolsIn .2s var(--ease);
}
html.mobile .textsheet textarea { font: inherit; font-size: 17px; line-height: 1.3; color: var(--fg); background: var(--hover); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none; resize: none; width: 100%; }
html.mobile .textsheet textarea:focus { border-color: var(--accent); }
html.mobile .textsheet .row { display: flex; align-items: center; gap: 6px; }
html.mobile .textsheet .pill { width: 40px; height: 36px; padding: 0; font-size: 18px; background: var(--hover); color: var(--fg); }
html.mobile .textsheet .pill.style { width: 36px; font-size: 16px; }
html.mobile .textsheet .pill.on { background: var(--accent); color: var(--on-accent); }
html.mobile .textsheet .row { flex-wrap: wrap; }
html.mobile .textsheet .num { width: 36px; text-align: center; font-variant-numeric: tabular-nums; }
html.mobile .textsheet .btn { padding: 9px 18px; }
html.mobile .tools.behind { display: none; }

/* ============ Сенсорные устройства ============ */
html.touch .item .rs { width: calc(28px / var(--s)); height: calc(28px / var(--s)); right: calc(-14px / var(--s)); bottom: calc(-14px / var(--s)); }
html.touch .car .nav { opacity: 1; transform: translateY(-50%); }
html.touch .tools button:hover { background: none; color: inherit; }
#hint .m { display: none; }

/* ============ Кнопка «+» и лист форматов ============ */
.fab {
  display: grid; place-items: center; position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 28px rgba(255,107,69,.4), 0 2px 6px rgba(0,0,0,.25); z-index: 65;
  transition: transform .2s var(--spring), opacity .2s, background .15s; animation: pop .35s var(--spring);
}
.fab svg { width: 26px; height: 26px; transition: transform .25s var(--spring); }
.fab:hover { background: var(--accent-2); }
.fab:active { transform: scale(.92); }
.fab.open svg { transform: rotate(45deg); }
.fab.hide { opacity: 0; pointer-events: none; transform: scale(.6); }
.addsheet {
  display: flex; flex-direction: column; position: fixed; right: 22px; bottom: calc(92px + env(safe-area-inset-bottom)); width: 320px; z-index: 64;
  border-radius: 18px; padding: 6px; animation: toolsIn .22s var(--ease);
}
.addsheet button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-align: left; font-size: 14px; transition: background .12s; }
.addsheet button:hover, .addsheet button:active { background: var(--hover); }
.addsheet button svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.addsheet button span { font-weight: 600; }
.addsheet button small { margin-left: auto; color: var(--muted); font-size: 12px; }
html.mobile .fab { right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 60px; height: 60px; }
html.mobile .addsheet { left: 12px; right: 12px; width: auto; bottom: calc(90px + env(safe-area-inset-bottom)); border-radius: 20px; padding: 8px; }
html.mobile .addsheet button { padding: 12px 14px; font-size: 16px; }

/* ============ Телефон ============ */
html.mobile body { -webkit-touch-callout: none; }
html.mobile .glass { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
html.mobile #hint { font-size: 17px; padding: 0 32px; }
html.mobile #hint .d { display: none; } html.mobile #hint .m { display: inline; }
html.mobile .topbar { top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; height: 44px; gap: 2px; }
html.mobile .bname { max-width: 46vw; font-size: 14px; }
html.mobile #saved { display: none; }
html.mobile .tools {
  left: 8px !important; right: 8px; top: auto !important; bottom: calc(16px + env(safe-area-inset-bottom) + var(--kb, 0px)); border-radius: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; animation: toolsIn .2s var(--ease);
}
html.mobile .tools::-webkit-scrollbar { display: none; }
html.mobile .tools > * { flex: none; }
html.mobile .tools { justify-content: center; gap: 6px; padding: 8px; }
html.mobile .tools button { height: 44px; min-width: 44px; padding: 0 16px; font-size: 15px; font-weight: 600; border-radius: 12px; background: var(--hover); }
html.mobile .tools button.on { background: var(--accent); color: var(--on-accent); }
html.mobile .tools button.danger { color: #e5484d; }
html.mobile .item .rs { display: none !important; }
html.mobile .item.sel { outline-color: var(--line-2); }
html.mobile .item.movable { outline-color: var(--accent); outline-width: calc(3px / var(--s)); }
html.mobile .item.held { outline-color: var(--accent); outline-width: calc(3px / var(--s)); }
html.mobile .tools button svg { width: 18px; height: 18px; }
html.mobile .tools .sw { width: 22px; height: 22px; }
html.mobile .sheet { bottom: calc(24px + env(safe-area-inset-bottom) + var(--kb, 0px)); flex-wrap: wrap; }
html.mobile .sheet input { flex-basis: 100%; }
html.mobile #toast { bottom: calc(96px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); white-space: normal; text-align: center; }
html.mobile #home { padding: calc(24px + env(safe-area-inset-top)) 16px 48px; }
html.mobile .home-head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 20px; }
html.mobile .home-head h1 { font-size: 30px; }
html.mobile .home-actions { flex-wrap: wrap; justify-content: space-between; gap: 10px; }
html.mobile .account { flex-wrap: wrap; row-gap: 4px; }
html.mobile .cards { grid-template-columns: 1fr; gap: 16px; }
html.mobile .card .del { opacity: 1; transform: none; }
html.mobile #auth { padding: 16px; }
html.mobile .auth-card { padding: 28px 22px 20px; }
html.mobile #lightbox { padding: 16px; }
html.mobile #lightbox img, html.mobile #lightbox video { max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }
html.mobile #lightbox .lbnav { width: 40px; height: 40px; }
html.mobile #lightbox .lbnav.prev { left: 4px; } html.mobile #lightbox .lbnav.next { right: 4px; }
html.mobile #lightbox .lbcnt { bottom: -26px; }
html.mobile .item.text .tx { font-size: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
