/* ---------- Темы: по умолчанию тёмная, светлая — по системе или вручную ---------- */
:root {
  --bg: #000;
  --card: #1c1c1e;
  --card2: #2c2c2e;
  --fill: #3a3a3c;
  --sep: #38383a;
  --text: #fff;
  --muted: #8e8e93;
  --accent: #0a84ff;
  --danger: #ff453a;
  --today-bg: #efeff4;
  --today-fg: #000;
  --we: rgba(255,255,255,.045);
  --note: #d8d8dc;
  --bar: rgba(22,22,24,.9);
  --sheet: #1c1c1e;
  --group: #2c2c2e;
  --seg-on: #636366;
  --fab-bg: #f2f2f7;
  --fab-fg: #111;
  --shadow: 0 6px 20px rgba(0,0,0,.5);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 50px;
  --pop: #e5e5ea;
  --pop-sep: rgba(60,60,67,.22);
  --ease: cubic-bezier(.32,.72,0,1);
  --pick: rgba(255,255,255,.16);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme=dark]) {
    --bg: #f2f2f7; --card: #fff; --card2: #e9e9ee; --fill: #e3e3e8; --sep: #e2e2e7;
    --text: #000; --muted: #8a8a8e; --accent: #007aff; --danger: #ff3b30;
    --today-bg: #1c1c1e; --today-fg: #fff; --we: rgba(0,0,0,.03); --note: #3a3a3c;
    --bar: rgba(249,249,251,.92); --sheet: #f2f2f7; --group: #fff; --seg-on: #fff;
    --fab-bg: #1c1c1e; --fab-fg: #fff; --shadow: 0 6px 20px rgba(0,0,0,.18); --pop: #fff; --pop-sep: rgba(60,60,67,.2); --pick: rgba(0,0,0,.07);
    color-scheme: light;
  }
}
:root[data-theme=light] {
  --bg: #f2f2f7; --card: #fff; --card2: #e9e9ee; --fill: #e3e3e8; --sep: #e2e2e7;
  --text: #000; --muted: #8a8a8e; --accent: #007aff; --danger: #ff3b30;
  --today-bg: #1c1c1e; --today-fg: #fff; --we: rgba(0,0,0,.03); --note: #3a3a3c;
  --bar: rgba(249,249,251,.92); --sheet: #f2f2f7; --group: #fff; --seg-on: #fff;
  --fab-bg: #1c1c1e; --fab-fg: #fff; --shadow: 0 6px 20px rgba(0,0,0,.18); --pop: #fff; --pop-sep: rgba(60,60,67,.2); --pick: rgba(0,0,0,.07);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); touch-action: manipulation; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { height: 100%; display: flex; flex-direction: column; }
.view {
  display: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 8px) 14px calc(var(--tabbar-h) + var(--sab) + 16px);
}
.view.active { display: block; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 14px; }
.top h1, .month-title { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: .2px; }
.month-title small { font-size: 20px; color: var(--muted); font-weight: 600; margin-left: 8px; }
.top-actions { display: flex; gap: 14px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--accent); }
.icon-btn svg { width: 27px; height: 27px; }
.icon-btn.sm { width: 36px; height: 36px; font-size: 28px; line-height: 1; background: var(--card); color: var(--text); border-radius: 50%; }
.icon-btn:active { opacity: .5; }

/* ---------- Календарь: заголовок месяца едет вместе с сеткой ---------- */
#view-calendar.active { display: flex; flex-direction: column; overflow: hidden; position: relative; padding: calc(var(--sat) + 8px) 0 calc(var(--tabbar-h) + var(--sab)); }
#view-calendar.active { transition: padding-bottom .38s var(--ease); }
body.painting #view-calendar.active { padding-bottom: calc(var(--tabbar-h) + var(--sab) + 92px); }
.cal-actions { position: absolute; top: calc(var(--sat) + 12px); right: 16px; z-index: 5; }
.cal-scroll { flex: 1; position: relative; overflow: hidden; touch-action: none; }
.track { height: 300%; will-change: transform; }
.page { height: 33.3334%; padding: 0 8px 8px; display: flex; flex-direction: column; }
.page .month-title { padding: 6px 12px 10px; cursor: pointer; flex: none; align-self: flex-start; }
.weekdays, .week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-card { flex: 1; background: var(--card); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.weekdays { flex: none; }
.weekdays div { text-align: center; padding: 8px 0 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.weekdays div.we, .day.we { background: var(--we); }
.weekdays div.we { color: var(--danger); opacity: .85; }
.cal-card .week { flex: 1; min-height: 0; border-top: .5px solid var(--sep); }
.day {
  padding: 3px 2px 4px; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  position: relative; min-height: 0; overflow: hidden;
}
.day .num {
  align-self: center; font-size: 15px; font-weight: 500; height: 24px; min-width: 24px; line-height: 24px;
  text-align: center; border-radius: 8px; margin-bottom: 1px;
}
.day.other { opacity: .28; }
.day.today::before { content: ""; position: absolute; inset: 3px; background: var(--today-bg); border-radius: 10px; z-index: 0; }
.day.today .num { color: var(--today-fg); font-weight: 700; }
.day > * { position: relative; z-index: 1; }
.chip {
  height: 18px; border-radius: 5px; font-size: 11.5px; line-height: 18px; text-align: center; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: clip; padding: 0 2px; font-weight: 600; flex: none;
}
.chip .t { display: block; font-size: 10px; line-height: 11px; opacity: .85; font-weight: 500; }
.chip.withtime { height: 28px; line-height: 16px; padding-top: 1px; }
.note { font-size: 11.5px; font-weight: 600; line-height: 18px; color: var(--note); display: flex; align-items: center; gap: 3px; overflow: hidden; white-space: nowrap; padding: 0 2px; flex: none; }
.note::before { content: ""; flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.day.today .note { color: var(--today-fg); }


.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  width: 46px; height: 46px; border-radius: 50%; background: var(--fab-bg); color: var(--fab-fg);
  display: grid; place-items: center; box-shadow: var(--shadow); z-index: 20; transition: transform .15s;
}
.fab:active { transform: scale(.92); }
body.painting .fab { bottom: calc(var(--tabbar-h) + var(--sab) + 104px); }
.fab { transition: transform .15s, bottom .38s var(--ease), background-color .25s, color .25s; }
.fab svg { width: 21px; height: 21px; stroke-width: 2.3; position: absolute; transition: opacity .2s, transform .3s var(--ease); }
.fab .i-done { opacity: 0; transform: rotate(-45deg) scale(.6); }
.fab.on .i-pen { opacity: 0; transform: rotate(45deg) scale(.6); }
.fab.on .i-done { opacity: 1; transform: none; stroke-width: 2.6; }
.fab.on { background: var(--accent); color: #fff; }

.paint-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab));
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--sep); padding: 10px 12px 10px; z-index: 19; transform: translateY(130%);
  transition: transform .38s var(--ease);
}
.paint-bar:not(.on) { visibility: hidden; transition: transform .38s var(--ease), visibility 0s .38s; }
.paint-bar.on { transform: none; }
.paint-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.link { color: var(--accent); font-size: 17px; }
.link.strong { font-weight: 600; }

/* ---------- Круглые кнопки смен (как в Supershift) ---------- */
.tools { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 7px 6px; }
.tools::-webkit-scrollbar { display: none; }
.tools.wrap { flex-wrap: wrap; overflow: visible; gap: 6px 0; }
.tools.wrap .tool { width: 25%; }
.tool { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.tool > span { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool.sel > span { color: var(--text); font-weight: 600; }
.circ {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-style: normal; font-weight: 700; font-size: 16px; letter-spacing: -.3px; overflow: hidden; white-space: nowrap;
  transition: box-shadow .12s, transform .12s;
}
.circ.s { font-size: 13px; }
.circ.xs { font-size: 11px; }
.tool:active .circ { transform: scale(.92); }
.tool.sel .circ { box-shadow: 0 0 0 3px var(--bar), 0 0 0 5.5px var(--text); }
.circ.ghost { background: var(--fill); color: var(--muted); font-size: 20px; }
.circ.empty { background: transparent; border: 2px dashed var(--muted); color: var(--muted); font-size: 20px; }
.sheet .tool.sel .circ { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5.5px var(--text); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--sab)); padding-bottom: var(--sab);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--sep);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 10px; font-weight: 500; }
.tabbar button.on { color: var(--accent); }
.tab-ico { position: relative; height: 26px; display: grid; place-items: center; }
.tab-ico svg { width: 25px; height: 25px; }
.cal-ico .fill { fill: currentColor; }
.cal-ico b { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--bg); font-weight: 700; }

/* ---------- Списки ---------- */
.hint { color: var(--muted); font-size: 13px; padding: 0 12px; line-height: 1.4; margin: 6px 0 12px; }
.sec { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; margin: 22px 14px 8px; }
.sub-title { font-size: 22px; font-weight: 700; margin: 26px 6px 0; }
.list { background: var(--card); border-radius: 14px; margin: 0 0 18px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left; font-size: 16px;
  border-top: .5px solid var(--sep);
}
.list > .row:first-child { border-top: 0; }
.row > span:nth-child(2), .row > span:first-child:not(.rot-prev):not(.ficon) { flex: 1; }
.accent-row { color: var(--accent); }
button.row:active, label.row:active { background: var(--card2); }
.row-ico { width: 26px; text-align: center; font-size: 20px; }
.row select { background: var(--card2); border: 0; border-radius: 8px; padding: 6px 8px; }
.row .circ { width: 40px; height: 40px; }
.row .sub { color: var(--muted); font-size: 13px; display: block; margin-top: 2px; }
.row .chev { color: var(--muted); font-size: 22px; }
.rot-prev { display: flex; gap: 2px; flex: none; width: 64px; }
.rot-prev i { flex: 1; height: 30px; border-radius: 3px; background: var(--card2); }
.rot-prev i.e { background: transparent; border: 1px dashed var(--muted); }

.switch { -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); position: relative; transition: background .2s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Отчеты ---------- */
.seg { display: flex; background: var(--card2); border-radius: 9px; padding: 2px; margin: 0 2px 14px; }
.seg button { flex: 1; padding: 7px; border-radius: 7px; font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--seg-on); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.period { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 14px; font-size: 20px; font-weight: 700; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px; }
.stat b { font-size: 28px; display: block; }
.stat span { color: var(--muted); font-size: 13px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.bar-row .cnt { min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .cnt small { color: var(--muted); display: block; font-size: 12px; }

/* ---------- Bottom sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .3s ease; z-index: 40; }
.sheet-bg.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 90vh; overflow-y: auto;
  background: var(--sheet); border-radius: 16px 16px 0 0; padding: 6px 16px calc(var(--sab) + 20px);
  transform: translateY(105%); transition: transform .42s var(--ease);
}
.sheet.tall { height: calc(100% - var(--sat) - 12px); max-height: none; }
.sheet input, .sheet textarea { -webkit-user-select: text; user-select: text; }
.sheet.on { transform: none; }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--fill); margin: 4px auto 8px; }
.sheet h2 { font-size: 20px; margin: 4px 0 14px; display: flex; justify-content: space-between; align-items: center; }
.sheet h2 small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 8px; }
.sheet h3 { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; margin: 20px 6px 8px; }
.sheet-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 0 6px; min-height: 40px; }
.sheet-nav b { font-size: 17px; }
.sheet-nav > :first-child { justify-self: start; }
.sheet-nav > :last-child { justify-self: end; }
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick button { height: 48px; border-radius: 10px; color: var(--text); background: var(--group); font-weight: 600; font-size: 16px; border: 2px solid transparent; }
.pick button.sel { border-color: var(--accent); }
.pick button.now { color: var(--accent); }

/* Группы-формы в стиле iOS */
.group { background: var(--group); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.frow { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px; border-top: .5px solid var(--sep); font-size: 16px; }
.group > .frow:first-child { border-top: 0; }
.frow > span:first-child { flex: 1; white-space: nowrap; }
.frow input[type=text], .frow input[type=number] { text-align: right; background: none; border: 0; outline: none; min-width: 0; width: 55%; color: var(--muted); padding: 6px 0; }
.frow input[type=time] { background: var(--fill); border: 0; border-radius: 8px; padding: 6px 10px; outline: none; color: var(--text); min-height: 34px; }
.frow select { background: none; border: 0; outline: none; color: var(--accent); text-align: right; font-size: 16px; direction: rtl; max-width: 60%; }
button.frow { width: 100%; text-align: left; }
button.frow:active { background: var(--card2); }
.frow.danger { color: var(--danger); justify-content: center; }
.frow.accent { color: var(--accent); }
.group.hidden-times .timerow, .group:not(.hidden-times) .alldayrow { display: none; }
.frow .dur { font-weight: 500; color: var(--muted); }
.group textarea { width: 100%; min-height: 90px; border: 0; outline: none; background: none; padding: 12px 14px; font-size: 16px; resize: vertical; display: block; }
.colors { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; padding: 14px; justify-items: center; }
.colors button { width: 34px; height: 34px; border-radius: 50%; transition: box-shadow .12s; }
.colors button.sel { box-shadow: 0 0 0 3px var(--group), 0 0 0 5px var(--text); }
.preview { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 18px; }
.preview .circ { width: 76px; height: 76px; font-size: 24px; }
.preview .circ.s { font-size: 19px; }
.preview .circ.xs { font-size: 15px; }
.preview span { color: var(--muted); font-size: 14px; }

.btn { display: block; width: 100%; height: 50px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; margin-top: 10px; }
.btn.secondary { background: var(--group); color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); padding-left: 4px; }
.field input[type=text], .field input[type=date] {
  background: var(--group); border: 0; border-radius: 10px; padding: 12px; font-size: 16px; width: 100%; outline: none; min-height: 46px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px; font-size: 16px; }

/* ---------- День ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; }
.day-head .dt { text-align: center; }
.day-head .dt small { display: block; color: var(--muted); font-size: 14px; font-weight: 500; }
.day-head .dt b { font-size: 22px; }
.day-head .icon-btn.sm { background: var(--group); }
.srow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: .5px solid var(--sep); }
.group > .srow:first-child { border-top: 0; }
.srow .circ { width: 42px; height: 42px; font-size: 14px; }
.srow div { flex: 1; min-width: 0; }
.srow b { display: block; font-size: 17px; font-weight: 600; }
.srow small { color: var(--muted); font-size: 13px; }
.srow .rm { width: 30px; height: 30px; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: 14px; flex: none; }
.empty-msg { padding: 16px 14px; color: var(--muted); font-size: 15px; text-align: center; }

/* ---------- Сетка чередования ---------- */
.rot-grid { background: var(--group); border-radius: 12px; overflow: hidden; margin: 8px 0 12px; }
.rot-row { display: grid; grid-template-columns: 22px repeat(7, 1fr); border-top: .5px solid var(--sep); }
.rot-row:first-child { border-top: 0; }
.rot-num { font-size: 11px; color: var(--muted); display: grid; place-items: center; }
.rot-row button { height: 44px; padding: 5px 2px; border-left: .5px solid var(--sep); display: grid; place-items: center; }
.rot-row .chip { width: 100%; font-size: 12px; height: 24px; line-height: 24px; }
.rot-row .empty-cell { width: 14px; height: 14px; border-radius: 50%; background: var(--fill); }
.rot-row .off-cell { width: 100%; height: 24px; border-radius: 6px; border: 1.5px dashed var(--muted); color: var(--muted); font-size: 11px; line-height: 21px; text-align: center; }
.rot-head { display: grid; grid-template-columns: 22px repeat(7, 1fr); font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }
.rot-bar { position: sticky; top: -6px; margin: 0 -16px; padding: 6px 12px; background: var(--sheet); z-index: 2; }

.toast {
  animation: toastIn .3s var(--ease);
  position: fixed; left: 50%; top: calc(var(--sat) + 12px); transform: translateX(-50%); z-index: 60;
  background: var(--card2); color: var(--text); padding: 10px 18px; border-radius: 20px; font-size: 14px; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}
@media (max-width: 360px) { .chip, .note { font-size: 10.5px; } .day .num { font-size: 14px; } }

/* ---------- Выбранный день и всплывашка ---------- */
.day::after { content: ""; position: absolute; inset: 2px; border-radius: 10px; background: var(--pick); opacity: 0; transition: opacity .2s ease; z-index: 0; pointer-events: none; }
.day.picked::after { opacity: 1; }

/* Окно дня — светлое, как в Supershift, в любой теме */
.day-pop {
  position: absolute; z-index: 25; flex-direction: column; width: calc(100% - 28px); max-width: 340px;
  background: var(--pop); color: #000; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.12);
  transform-origin: var(--ax, 50%) 0; display: none;
}
.day-pop.up { transform-origin: var(--ax, 50%) 100%; }
.day-pop.on { display: flex; }
.day-pop::before {
  content: ""; position: absolute; left: calc(var(--ax, 50%) - 7px); top: -6px; width: 14px; height: 14px;
  background: var(--pop); transform: rotate(45deg); border-radius: 2px;
}
.day-pop.up::before { top: auto; bottom: -6px; }
.day-pop.noarrow::before { display: none; }
.pop-items { max-height: 44vh; overflow-y: auto; padding: 0; border-radius: 16px 16px 0 0; }
.pop-items:empty { display: none; }
.pop-item { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 7px 16px; position: relative; color: #000; background: var(--pop); will-change: transform; transition: opacity .15s; }
.pop-item::after { content: ""; position: absolute; left: 52px; right: 16px; bottom: 0; height: .5px; background: var(--pop-sep); }
.pop-item:active { opacity: .5; }
.pop-item .circ { width: 22px; height: 22px; font-size: 9.5px; letter-spacing: -.4px; }
.pop-item .circ.s { font-size: 8.5px; }
.pop-item .circ.xs { font-size: 7px; }
.pop-item .circ.ev { background: rgba(60,60,67,.14); color: #000; font-size: 12px; }
.pop-item div { flex: 1; min-width: 0; }
.pop-item b { display: flex; align-items: center; gap: 5px; font-size: 14.5px; font-weight: 400; line-height: 1.3; white-space: nowrap; overflow: hidden; color: #000; margin: 0; }
.pop-item small { display: block; font-size: 12px; color: rgba(60,60,67,.85); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pop-item .bell { width: 11px; height: 11px; stroke-width: 1.8; color: rgba(60,60,67,.6); flex: none; }
.pop-item .h { align-self: flex-start; font-size: 12px; color: #000; padding-top: 2px; font-variant-numeric: tabular-nums; }
.pop-btns { display: flex; height: 44px; }
.pop-btns button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14.5px; color: rgba(60,60,67,.75); position: relative; transition: background .15s; }
.pop-btns button + button::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: .5px; background: var(--pop-sep); }
.pop-btns button:active { background: rgba(0,0,0,.05); }
.pop-btns button:first-child { border-radius: 0 0 0 16px; }
.pop-btns button:last-child { border-radius: 0 0 16px 0; }
.pop-items:empty + .pop-btns button:first-child { border-radius: 16px 0 0 16px; }
.pop-items:empty + .pop-btns button:last-child { border-radius: 0 16px 16px 0; }
.pop-btns b { font-size: 21px; font-weight: 300; color: rgba(60,60,67,.75); line-height: 1; margin-top: -2px; }

/* Мягкие нажатия */
.btn, .modal-close, .link, .tool, .icon-btn, .row, .frow, .srow { transition: opacity .15s, background-color .15s, transform .15s; }
.btn:active { opacity: .8; transform: scale(.985); }

/* ---------- Карточка смены в дне ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.modal-wrap.on { pointer-events: auto; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .3s ease; }
.modal-wrap.on .modal-bg { opacity: 1; }
.modal {
  position: absolute; left: 12px; right: 12px; bottom: calc(var(--sab) + 10px); display: flex; flex-direction: column; gap: 10px;
  transform: translateY(110%); transition: transform .42s var(--ease); max-width: 480px; margin: 0 auto;
}
.modal-wrap.on .modal { transform: none; }
.modal-card { background: var(--card); border-radius: 22px; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 0 20px; height: 56px; color: #fff; font-size: 20px; font-weight: 700; }
.modal-head b { flex: 1; font-weight: 600; font-size: 19px; }
.modal-head span { font-size: 19px; font-weight: 600; }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 20px; min-height: 52px; border-bottom: .5px solid var(--sep); font-size: 17px; }
.mrow .v { color: var(--text); }
.mrow select { background: none; border: 0; outline: none; color: var(--text); font-size: 17px; text-align: right; direction: rtl; max-width: 60%; }
.mbox { margin: 16px 20px 18px; border: .5px solid var(--sep); border-radius: 10px; overflow: hidden; }
.mbox textarea, .mbox input { display: block; width: 100%; border: 0; outline: none; background: none; font-size: 17px; padding: 10px 12px; color: var(--text); -webkit-user-select: text; user-select: text; }
.mbox textarea { min-height: 110px; resize: none; border-bottom: .5px solid var(--sep); }
.mfoot { display: flex; justify-content: space-between; align-items: center; border-top: .5px solid var(--sep); height: 52px; padding: 0 12px 0 20px; }
.mdel { width: 44px; height: 44px; display: grid; place-items: center; color: var(--text); }
.mdel:active { opacity: .5; }
.modal-close { height: 54px; border-radius: 27px; background: var(--card); font-size: 17px; color: var(--text); }
.modal-close:active { background: var(--card2); }

/* ---------- События ---------- */
.circ.ev { background: var(--fill); color: var(--text); font-size: 20px; }
button.srow { width: 100%; text-align: left; }
button.srow:active { background: var(--card2); }
.srow .chev { color: var(--muted); font-size: 22px; }
.frow input.wide { width: 100%; text-align: left; color: var(--text); font-size: 17px; }
.frow input[type=date] { background: var(--fill); border: 0; border-radius: 8px; padding: 6px 10px; outline: none; color: var(--text); min-height: 34px; }
#eList .frow.accent { width: 100%; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.out { opacity: 0; transform: translate(-50%, -8px); transition: opacity .25s, transform .25s; }

/* Смена с заметкой: плашка + блёклое продолжение того же цвета */
.chip-wrap { display: flex; flex-direction: column; flex: none; border-radius: 5px; overflow: hidden; }
.chip-wrap .chip { border-radius: 0; }
.chip-note {
  background: color-mix(in srgb, var(--c) 34%, var(--card)); color: color-mix(in srgb, var(--c) 45%, var(--text));
  font-size: 11px; line-height: 16px; height: 16px; text-align: center; white-space: nowrap; overflow: hidden; padding: 0 2px; font-weight: 500;
}

/* ================= Чат ================= */
input, textarea { -webkit-user-select: text; user-select: text; }
.back { display: block; padding: 4px 6px 0; font-size: 17px; }
.row-val { color: var(--muted); font-size: 15px; }
.badge {
  position: absolute; top: -3px; left: 17px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.badge[hidden] { display: none; }

body[data-view=chat], body[data-view=chat] html { overflow: hidden; }
#view-chat.active {
  position: fixed; left: 0; right: 0; top: 0; padding: 0; display: flex; flex-direction: column;
  height: calc(var(--vvh, 100vh) - var(--tabbar-h) - var(--sab)); overflow: hidden;
}
body.kb #view-chat.active { top: var(--vvt, 0px); }
body.kb #view-chat.active { height: var(--vvh, 100vh); }
body.kb[data-view=chat] .tabbar { display: none; }
body.kb .composer { padding-bottom: 8px; }

.chat-join { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 28px; text-align: center; }
.chat-join[hidden], .chat-main[hidden] { display: none; }
.join-ico { width: 76px; height: 76px; border-radius: 22px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.join-ico svg { width: 40px; height: 40px; stroke-width: 1.8; }
.chat-join h2 { margin: 0 0 6px; font-size: 26px; }
.chat-join p { color: var(--muted); font-size: 15px; line-height: 1.4; margin: 0 0 22px; }
.chat-join .hint { margin-top: 18px; padding: 0; }
.chat-join input {
  width: 100%; height: 50px; border-radius: 12px; border: 0; outline: none; background: var(--card);
  font-size: 17px; text-align: center; padding: 0 14px;
}
.chat-join .btn { margin-top: 12px; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  flex: none; padding: calc(var(--sat) + 6px) 16px 8px; text-align: center; background: var(--bar);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: .5px solid var(--sep); z-index: 2;
}
body.kb .chat-head { padding-top: calc(max(0px, var(--sat) - var(--vvt, 0px)) + 6px); }
.chat-head b { display: block; font-size: 17px; font-weight: 600; }
.chat-head small { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; min-height: 16px; transition: color .2s; }
.chat-head small.on, .chat-head small.typing { color: var(--accent); }
.dots { display: inline-flex; gap: 2px; margin-left: 3px; vertical-align: middle; }
.dots b { width: 3.5px; height: 3.5px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite ease-in-out; display: block; }
.dots b:nth-child(2) { animation-delay: .15s; }
.dots b:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 8px 10px; overscroll-behavior: contain; }
.chat-empty { color: var(--muted); text-align: center; margin-top: 30vh; font-size: 15px; line-height: 1.5; }
.chat-more { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }
.chat-day { text-align: center; margin: 12px 0 8px; position: sticky; top: 4px; z-index: 1; }
.chat-day span { display: inline-block; font-size: 13px; font-weight: 500; padding: 3px 10px; border-radius: 12px; background: var(--card2); color: var(--muted); }
.bubble .nick { display: block; font-size: 14px; color: var(--accent); font-weight: 600; margin-bottom: 1px; }

.msg { display: flex; margin-top: 2px; }
.msg.anim { animation: msgIn .3s var(--ease); }
.msg.out { justify-content: flex-end; }
.msg.tail { margin-bottom: 7px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble {
  max-width: 80%; padding: 7px 10px 7px 12px; border-radius: 18px; font-size: 16px; line-height: 1.32;
  background: var(--card2); color: var(--text); position: relative; overflow: hidden; transition: transform .15s, opacity .15s;
  -webkit-user-select: none; user-select: none;
}
.msg.out .bubble { background: var(--accent); color: #fff; }
.msg.in.tail .bubble { border-bottom-left-radius: 6px; }
.msg.out.tail .bubble { border-bottom-right-radius: 6px; }
.msg.pending .bubble { opacity: .85; }
.txt { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.txt a { color: inherit; text-decoration: underline; }
.del { font-style: italic; opacity: .7; }
.meta {
  float: right; display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; opacity: .7;
  margin: 7px 0 -4px 10px; font-variant-numeric: tabular-nums; line-height: 1;
}
.tick { width: 15px; height: 10px; stroke-width: 1.6; fill: none; }
.msg.in .meta { color: var(--muted); opacity: 1; }

.photo { display: block; width: calc(100% + 16px); height: auto; object-fit: cover; border-radius: 13px; margin: -3px -7px 6px -9px; background: var(--fill); }
.msg.only-photo .bubble { padding: 3px; max-width: none; }
.msg.only-photo .photo { margin: 0; width: 100%; border-radius: 16px; }
.msg.only-photo .meta { position: absolute; right: 9px; bottom: 9px; margin: 0; background: rgba(0,0,0,.45); color: #fff; opacity: 1; padding: 4px 7px; border-radius: 10px; }
.msg.has-poll .bubble { width: 80%; }

.poll { padding: 2px 0 2px; }
.poll-q { display: block; font-size: 16px; font-weight: 600; }
.poll-kind { display: block; font-size: 13px; opacity: .7; margin: 2px 0 8px; }
.poll-o {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 4px; font-size: 15.5px;
  color: inherit; border-radius: 8px; overflow: hidden;
}
.poll-mark { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .6; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.poll-o.shown .poll-mark { border: 0; opacity: 1; }
.poll-o.mine .poll-mark { background: currentColor; }
.poll-o.mine .poll-mark { color: inherit; }
.msg.out .poll-o.mine .poll-mark::after, .msg.in .poll-o.mine .poll-mark::after { content: "✓"; color: var(--accent); position: absolute; }
.msg.in .poll-o.mine .poll-mark::after { color: var(--card2); }
.poll-o.mine .poll-mark { position: relative; font-size: 0; }
.poll-o.mine .poll-mark::after { font-size: 12px; }
.poll-t { flex: 1; position: relative; z-index: 1; }
.poll-pct { font-size: 14px; font-weight: 600; position: relative; z-index: 1; }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: currentColor; opacity: .14; border-radius: 8px; transition: width .4s var(--ease); }
.poll-total { display: block; font-size: 13px; opacity: .7; text-align: center; margin-top: 6px; }

.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 7px 10px 8px; background: var(--bar);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: .5px solid var(--sep);
}
.c-input {
  flex: 1; min-width: 0; min-height: 36px; max-height: 120px; overflow-y: auto; border-radius: 18px; border: .5px solid var(--sep);
  background: var(--card); padding: 7px 14px; font-size: 16px; line-height: 20px; outline: none; display: block;
  white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; cursor: text;
}
.c-input:empty::before { content: attr(data-ph); color: var(--muted); pointer-events: none; }
.c-btn { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); flex: none; }
.c-btn svg { width: 25px; height: 25px; stroke-width: 1.8; }
.c-send {
  width: 34px; height: 34px; margin: 1px 0; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none;
  transform: scale(0); width: 0; margin-left: -8px; transition: transform .22s var(--ease), width .22s var(--ease), margin .22s var(--ease);
}
.c-send.on { transform: none; width: 34px; margin-left: 0; }
.c-send svg { width: 20px; height: 20px; stroke-width: 2.6; }

.ph-prev { display: block; width: 100%; max-height: 55vh; object-fit: contain; border-radius: 12px; margin-bottom: 12px; background: #000; }
.ph-cap { width: 100%; border: 0; outline: none; background: none; padding: 14px; font-size: 16px; }
.po-row { padding-right: 8px; }
.po-rm { width: 26px; height: 26px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 18px; line-height: 1; flex: none; }

.viewer { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-items: center; opacity: 0; transition: opacity .25s ease; }
.viewer.on { opacity: 1; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; transform: scale(.94); transition: transform .3s var(--ease); }
.viewer.on img { transform: none; }
.viewer-x { position: absolute; top: calc(var(--sat) + 10px); right: 14px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 16px; }

/* iOS 26: в установленном приложении 100% бывает короче экрана — берём полную высоту */
@media (display-mode: standalone) { html, body { height: 100lvh; } }

/* Цитата ответа */
.quote { display: block; border-left: 3px solid currentColor; border-radius: 4px 8px 8px 4px; padding: 3px 8px; margin: 2px 0 5px; background: rgba(255,255,255,.14); cursor: pointer; }
.msg.in .quote { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.quote b { display: block; font-size: 13.5px; font-weight: 600; }
.msg.in .quote b { color: var(--accent); }
.quote span { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.meta .ed { font-style: normal; margin-right: 2px; }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { filter: brightness(1.35); } 100% { filter: none; } }

/* Полоска «Ответ / Редактирование» над полем */
.compose-bar {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 14px; max-height: 0; overflow: hidden; opacity: 0;
  background: var(--bar); border-top: .5px solid transparent; transition: max-height .25s var(--ease), opacity .2s, padding .25s var(--ease);
}
.compose-bar.on { max-height: 60px; opacity: 1; padding-top: 7px; padding-bottom: 3px; border-top-color: var(--sep); }
.cb-ico { color: var(--accent); flex: none; display: grid; }
.cb-ico svg { width: 22px; height: 22px; stroke-width: 2; }
.cb-txt { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 9px; }
.cb-txt b { display: block; color: var(--accent); font-size: 14px; font-weight: 600; }
.cb-txt small { display: block; font-size: 14px; color: var(--text); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-x { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); flex: none; }
.cb-x svg { width: 18px; height: 18px; }
.compose-bar.on + .composer { border-top-color: transparent; }
.c-send { position: relative; }
.c-send svg { position: absolute; transition: opacity .15s, transform .2s var(--ease); }
.c-send .i-ok { opacity: 0; transform: scale(.5); }
.c-send.edit .i-up { opacity: 0; transform: scale(.5); }
.c-send.edit .i-ok { opacity: 1; transform: none; }

/* Меню сообщения как в Telegram */
.ctx { position: fixed; inset: 0; z-index: 80; }
.ctx-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .14s ease-out; will-change: opacity; }
.ctx.on .ctx-bg { opacity: 1; }
.ctx-msg { position: fixed; margin: 0; overflow: hidden; border-radius: 18px; transform: translateY(var(--dy, 0px)); transition: transform .2s var(--ease); pointer-events: none; }
.ctx-msg .bubble { max-width: none; width: 100%; }
.ctx.on .ctx-msg { transform: none; animation: lift .2s var(--ease); }
.ctx.off .ctx-msg { transform: translateY(var(--dy, 0px)); }
@keyframes lift { from { scale: .96; } to { scale: 1; } }
.ctx-menu {
  position: fixed; width: 240px; border-radius: 14px; overflow: hidden; background: #2c2c2e; will-change: transform, opacity; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  transform-origin: top left; transform: scale(.5); opacity: 0; transition: transform .18s cubic-bezier(.2,1.1,.35,1), opacity .1s ease-out;
}
.ctx-menu.out { transform-origin: top right; }
.ctx.on .ctx-menu { transform: none; opacity: 1; }
.ctx.off .ctx-menu { transform: scale(.7); opacity: 0; transition: transform .14s ease-in, opacity .1s; }
.ctx-menu button { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 44px; padding: 0 16px; font-size: 17px; color: #fff; text-align: left; }
.ctx-menu button + button { border-top: .5px solid rgba(255,255,255,.12); }
.ctx-menu button:active { background: rgba(255,255,255,.1); }
.ctx-menu button svg { width: 21px; height: 21px; stroke-width: 1.8; }
.ctx-menu .danger { color: #ff453a; }
:root[data-theme=light] .ctx-menu { background: #fff; }
:root[data-theme=light] .ctx-menu button { color: #000; }
:root[data-theme=light] .ctx-menu button + button { border-top-color: rgba(0,0,0,.1); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme=dark]) .ctx-menu { background: #fff; }
  :root:not([data-theme=dark]) .ctx-menu button { color: #000; }
  :root:not([data-theme=dark]) .ctx-menu button + button { border-top-color: rgba(0,0,0,.1); }
}

.msg.pressing .bubble { transform: scale(.96); transition: transform .25s ease-out; }

/* Свайп «Удалить» в окне дня */
.sw { position: relative; overflow: hidden; }
.sw-del {
  position: absolute; inset: 0; background: #ff3b30; color: #fff; font-size: 14.5px; font-weight: 500;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 16px;
}
.sw .pop-item:active { opacity: 1; }
.sw.full .sw-del { padding-right: 16px; }

/* ================= Свайп в списках ================= */
.list .sw { position: relative; overflow: hidden; border-top: .5px solid var(--sep); }
.list > .sw:first-child { border-top: 0; }
.list .sw > .row { border-top: 0; background: var(--card); will-change: transform; }
.list .sw .sw-del { font-size: 15px; }

/* ================= Диск ================= */
.disk-join { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18vh 18px 0; }
.disk-join[hidden], #diskMain[hidden], .disk-list[hidden], .disk-usage[hidden] { display: none; }
.disk-join h2 { margin: 0 0 6px; font-size: 26px; }
.disk-join p { color: var(--muted); font-size: 15px; line-height: 1.4; margin: 0 0 22px; }
.disk-join input { width: 100%; height: 50px; border-radius: 12px; border: 0; outline: none; background: var(--card); font-size: 17px; text-align: center; }
.disk-join .btn { margin-top: 12px; }
.join-ico.disk { background: #0a84ff; }
.disk-nav { min-height: 24px; padding: 0 6px; }
.disk-nav .link { font-size: 17px; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#diskTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80%; }
.disk-usage { margin: -6px 6px 14px; }
.disk-usage .bar { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.disk-usage .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s var(--ease); }
.disk-usage small { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; }
.disk-row { gap: 12px; min-height: 60px; }
.disk-row > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disk-row .sub { white-space: nowrap; }
.ficon { width: 40px; height: 40px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.ficon.dir { color: #0a84ff; }
.ficon.dir svg { width: 38px; height: 38px; fill: color-mix(in srgb, #0a84ff 30%, transparent); stroke-width: 1.6; }
.ficon.tile { color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .2px; }
.ficon.tile.big { width: 76px; height: 76px; border-radius: 18px; font-size: 18px; margin-bottom: 16px; }
.ficon.thumb { object-fit: cover; background: var(--fill); }
.uploading .sub { color: var(--accent); }
.upbar { display: block; height: 3px; border-radius: 2px; background: var(--fill); margin-top: 6px; overflow: hidden; }
.upbar b { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.fm-title { font-size: 16px !important; justify-content: center !important; text-align: center; word-break: break-all; color: var(--muted); font-weight: 500; }

/* Просмотрщик файлов */
.fv { position: fixed; inset: 0; z-index: 75; background: #000; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .38s var(--ease); }
.fv.on { transform: none; }
.fv-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 6px) 8px 8px; background: rgba(28,28,30,.96); color: #fff; }
.fv-btn { width: 40px; height: 40px; display: grid; place-items: center; color: #fff; flex: none; }
.fv-btn svg { width: 22px; height: 22px; }
.fv-name { flex: 1; min-width: 0; text-align: center; }
.fv-name b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-name small { color: #8e8e93; font-size: 12px; }
.fv-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; position: relative; overscroll-behavior: contain; overflow-anchor: none; }
.fv-wait { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #8e8e93; font-size: 15px; padding: 24px; text-align: center; }
.fv-wait .btn { width: auto; padding: 0 22px; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.zoom { width: 100%; min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.zoom img { width: 100%; height: auto; display: block; }
.zoom.pdf { justify-content: flex-start; padding: 2% 0 10%; background: #3a3a3c; }
.zoom.pdf .pgw { position: relative; width: 97%; margin-bottom: 2%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35); flex: none; }
.zoom.pdf .pg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hl { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.hl i { position: absolute; background: rgba(255, 214, 10, .4); border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 214, 10, .5); }
.hl i.cur { background: rgba(255, 149, 0, .45); box-shadow: 0 0 0 2px #ff9500; }
.fv-text mark { background: rgba(255, 214, 10, .55); color: inherit; border-radius: 2px; }
.fv-text mark.cur { background: #ff9500; color: #000; }

/* Строка поиска в просмотрщике: поле во всю ширину, ниже — режим и навигация */
.fv-search { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 0 12px; max-height: 0; overflow: hidden; background: rgba(28,28,30,.96); transition: max-height .28s var(--ease), padding .28s var(--ease); }
.fv-search.on { max-height: 130px; padding: 4px 12px 10px; }
.fv-srow { display: flex; align-items: center; gap: 6px; }
.fv-sfield { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 12px; border-radius: 12px; background: rgba(118,118,128,.24); color: #8e8e93; }
.fv-sfield > svg { width: 20px; height: 20px; flex: none; }
.fv-sfield input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: #fff; font-size: 17px; -webkit-appearance: none; }
.fv-sfield input::placeholder { color: #8e8e93; }
.fv-sfield input::-webkit-search-cancel-button { display: none; }
.fv-sclear { width: 32px; height: 32px; display: grid; place-items: center; color: #8e8e93; flex: none; }
.fv-sclear[hidden] { display: none; }
.fv-sclear svg { width: 20px; height: 20px; fill: rgba(142,142,147,.35); stroke: #1c1c1e; stroke-width: 2; }
.fv-sclear svg circle { stroke: none; fill: #8e8e93; }
.fv-sdone { color: #0a84ff; font-size: 17px; font-weight: 500; padding: 0 2px; flex: none; }
.fv-seg { display: flex; background: rgba(118,118,128,.24); border-radius: 9px; padding: 2px; flex: none; }
.fv-seg button { padding: 6px 8px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: #ebebf5; transition: background .2s, color .2s; white-space: nowrap; }
.fv-seg button.on { background: #636366; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.fv-scount { flex: 1; min-width: 0; text-align: right; font-size: 13.5px; color: #8e8e93; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-btn.sm { width: 34px; height: 38px; flex: none; }
.fv-btn.sm svg { width: 24px; height: 24px; stroke-width: 2.2; }
.fv-pages { position: absolute; left: 50%; bottom: calc(var(--sab) + 16px); transform: translateX(-50%); padding: 5px 13px; border-radius: 13px; background: rgba(0,0,0,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; z-index: 2; }
.fv video { width: 100%; height: 100%; background: #000; }
.fv audio { width: 86%; }
.fv-text { margin: 0; padding: 14px; color: #e5e5ea; font: 13px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.fv-table { background: #fff; color: #000; min-height: 100%; overflow: auto; -webkit-user-select: text; user-select: text; }
.fv-table table { border-collapse: collapse; font-size: 13px; }
.fv-table th, .fv-table td { border: 1px solid #d1d1d6; padding: 5px 8px; white-space: nowrap; text-align: left; }
.fv-table th { position: sticky; top: 0; background: #f2f2f7; font-weight: 600; }

/* ================= Обсуждения (комментарии к сообщению) ================= */
.cmt {
  display: flex; align-items: center; gap: 7px; width: calc(100% + 22px); margin: 8px -10px -7px -12px; padding: 9px 12px;
  border-top: .5px solid rgba(255,255,255,.18); color: inherit; font-size: 14.5px; font-weight: 500; text-align: left; clear: both;
}
.msg.in .cmt { border-top-color: var(--sep); color: var(--accent); }
.cmt svg { width: 19px; height: 19px; stroke-width: 1.9; flex: none; }
.cmt span { flex: 1; }
.cmt i { font-style: normal; font-size: 20px; opacity: .6; line-height: 1; }
.cmt:active { background: rgba(255,255,255,.08); }
.msg.has-cmt .bubble { min-width: 210px; }
.chat-head { position: relative; }
.chat-back { position: absolute; left: 10px; bottom: 14px; font-size: 17px; opacity: 0; pointer-events: none; transform: translateX(10px); transition: opacity .25s, transform .3s var(--ease); }
#chatMain.can-back .chat-back { opacity: 1; pointer-events: auto; transform: none; }
#chatMain.in-thread .chat-head { background: color-mix(in srgb, var(--accent) 12%, var(--bar)); }
.msg.post { margin-top: 6px; }
.msg.post .bubble { max-width: 92%; }
.msg.post.out { justify-content: flex-start; }
.th-sep { display: flex; align-items: center; gap: 10px; margin: 14px 4px 10px; color: var(--muted); font-size: 13px; }
.th-sep::before, .th-sep::after { content: ""; flex: 1; height: .5px; background: var(--sep); }

/* Поиск по Диску */
.disk-search { display: flex; align-items: center; gap: 8px; height: 42px; margin: -4px 2px 12px; padding: 0 6px 0 12px; border-radius: 12px; background: var(--card); color: var(--muted); }
.disk-search > svg { width: 19px; height: 19px; flex: none; }
.disk-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 16.5px; color: var(--text); -webkit-appearance: none; }
.disk-search input::-webkit-search-cancel-button { display: none; }
.ds-clear { width: 32px; height: 32px; display: grid; place-items: center; flex: none; }
.ds-clear[hidden] { display: none; }
.ds-clear svg { width: 19px; height: 19px; stroke: var(--card); stroke-width: 2; }
.ds-clear svg circle { fill: var(--muted); stroke: none; }
.disk-sopts { display: flex; align-items: center; gap: 10px; margin: -4px 2px 12px; }
.disk-sopts[hidden] { display: none; }
.disk-sopts small { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; text-align: right; }
.ds-seg { background: var(--card2); }
.ds-seg button { color: var(--text); }
.ds-seg button.on { background: var(--seg-on); color: var(--text); }
body.disk-searching .disk-usage, body.disk-searching .disk-nav, body.disk-searching #diskAdd { display: none; }
.sr { display: flex; gap: 12px; padding: 12px 14px; border-top: .5px solid var(--sep); }
.sr:first-child { border-top: 0; }
.sr:active { background: var(--card2); }
.sr-body { flex: 1; min-width: 0; }
.sr-name { display: block; font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-body > small { display: block; color: var(--muted); font-size: 13px; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr mark { background: rgba(255, 214, 10, .45); color: inherit; border-radius: 3px; padding: 0 1px; }
.sr-snip { display: block; width: 100%; text-align: left; font-size: 13.5px; line-height: 1.35; color: var(--text); opacity: .85; padding: 6px 8px; margin-top: 4px; border-radius: 8px; background: var(--card2); }
.sr-snip > span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-snip b { color: var(--accent); font-weight: 600; margin-right: 2px; }
.sr-snip:active { opacity: .6; }


/* АИП */
.ficon.aip { background: linear-gradient(160deg, #0a84ff, #0040dd); color: #fff; }
.ficon.aip svg { width: 24px; height: 24px; fill: #fff; stroke: none; }
.aip-row .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ficon.icao { background: #1c3d6e; color: #fff; font: 700 11.5px/1 ui-monospace, Menlo, monospace; letter-spacing: .3px; }
.ficon.tile.num { background: var(--fill); color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.aip-doc { white-space: normal !important; line-height: 1.3; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.aip-doc .sub { -webkit-line-clamp: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aip-group { padding: 14px 14px 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; border-top: .5px solid var(--sep); }
.aip-group:first-child { border-top: 0; padding-top: 10px; }
.aip-upd { padding: 10px 14px 12px !important; margin: 0; border-top: .5px solid var(--sep); }

.zoom.pdf .pg-hi { position: absolute; pointer-events: none; z-index: 1; }
.ficon.vdir { color: #ff9f0a; }
.ficon.vdir svg { width: 38px; height: 38px; fill: color-mix(in srgb, #ff9f0a 28%, transparent); stroke-width: 1.6; }
.aip-mode { padding: 10px 12px; border-bottom: .5px solid var(--sep); }
.aip-mode .fv-seg { display: flex; }
.aip-mode .fv-seg button { flex: 1; font-size: 14px; padding: 7px 8px; }
.aip-quick { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 12px; scrollbar-width: none; border-top: .5px solid var(--sep); }
.aip-quick::-webkit-scrollbar { display: none; }
.aip-group + .aip-quick { border-top: 0; padding-top: 2px; }
.qa { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; min-width: 92px; border-radius: 12px; background: var(--card2); text-align: left; transition: transform .12s; }
.qa:active { transform: scale(.96); }
.qa b { font: 700 15px/1.1 ui-monospace, Menlo, monospace; color: var(--accent); letter-spacing: .3px; }
.qa span { font-size: 12.5px; color: var(--muted); max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Пометки на PDF */
.zoom.pdf .ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 2; }
.ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ink path.mk { mix-blend-mode: multiply; }
.fv-body.inking { touch-action: none; }
.fv-btn.has-ink { color: #ffd60a; }
.fv.drawing [data-v="ink"] { color: #0a84ff; }
.fv-ink {
  position: absolute; left: 10px; right: 10px; bottom: calc(var(--sab) + 12px); z-index: 3; display: flex; flex-direction: column; gap: 4px;
  padding: 6px; border-radius: 18px; background: rgba(44,44,46,.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4); transform: translateY(calc(100% + 40px)); transition: transform .3s var(--ease);
}
.fv.drawing .fv-ink { transform: none; }
.fv-ink button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 50px; padding: 6px 4px; border-radius: 12px; color: #fff; font-size: 11px; transition: background .15s; }
.fv-ink button.on { background: rgba(255,255,255,.16); }
.fv-ink button i { display: block; width: 24px; height: 24px; border-radius: 50%; }
.fv-ink .tool-m i { background: #ffd60a; box-shadow: inset 0 0 0 2px rgba(0,0,0,.15); }
.fv-ink .tool-p i { background: #ff3b30; transform: scale(.6); }
.fv-ink button svg { width: 24px; height: 24px; }
.fv-ink-sep { flex: 1; }
.fv-ink [data-ink="undo"], .fv-ink [data-ink="clear"] { min-width: 40px; justify-content: center; }
.fv-ink .fv-ink-done { color: #0a84ff; font-size: 16px; font-weight: 600; padding: 0 10px; min-width: 0; }

/* Листание схем */
.fv-nav {
  position: absolute; left: 10px; right: 10px; bottom: calc(var(--sab) + 12px); z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 5px; border-radius: 18px; background: rgba(44,44,46,.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0,0,0,.4); transition: transform .3s var(--ease), opacity .2s;
}
.fv.drawing .fv-nav { transform: translateY(calc(100% + 40px)); opacity: 0; }
.fv-nav b { flex: none; color: #8e8e93; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; padding: 0 2px; }
.fv-nav button { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; padding: 8px 6px; border-radius: 13px; color: #fff; font-size: 13px; text-align: left; }
.fv-nav button:last-child { justify-content: flex-end; text-align: right; }
.fv-nav button:active { background: rgba(255,255,255,.1); }
.fv-nav button:disabled { opacity: .3; }
.fv-nav button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-nav svg { width: 20px; height: 20px; flex: none; color: #0a84ff; stroke-width: 2.4; }
.fv.has-nav .fv-pages { bottom: calc(var(--sab) + 124px); }
.fv-nav { flex-wrap: wrap; row-gap: 0; }
/* Полное название открытой схемы — до двух строк */
.fv-nav-t { flex: 0 0 100%; padding: 5px 12px 2px; color: #fff; font-size: 14px; font-weight: 600; line-height: 1.25; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fv.drawing .fv-pages { bottom: calc(var(--sab) + 128px); }
.aip-off { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; border-bottom: .5px solid var(--sep); font-size: 15.5px; color: var(--accent); }
.aip-off > span:nth-child(2) { flex: 1; min-width: 0; }
.aip-off .sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.aip-off.ok { color: #30d158; }
.aip-off.busy { color: var(--text); }
.aip-off .link { font-size: 15px; padding: 4px 2px; }
.danger-link { color: var(--danger) !important; }
.off-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--card2); display: grid; place-items: center; flex: none; font-size: 18px; }
.off-mark { color: #30d158; font-size: 15px; flex: none; margin-left: 6px; }

.fv-ink-row { display: flex; align-items: center; gap: 2px; }
.fv-ink-row button { min-width: 44px; }
.fv-ink .tool-p i { transform: scale(.6); }
.fv-ink .tool-t b { font: 700 21px/24px Georgia, "PT Serif", serif; color: #ff3b30; height: 24px; }
.fv-pal { display: none; gap: 12px; padding: 6px 8px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: .5px solid rgba(255,255,255,.12); scroll-snap-type: x proximity; -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent); }
.fv-pal::-webkit-scrollbar { display: none; }
.fv-pal button { scroll-snap-align: center; }
.fv-pal.on { display: flex; }
.fv-pal button { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25); transition: transform .15s, box-shadow .15s; }
.fv-pal button.on { box-shadow: 0 0 0 2.5px #2c2c2e, 0 0 0 4.5px #fff; transform: scale(1.05); }
.ink text.tx { font-family: -apple-system, "Helvetica Neue", Arial, sans-serif; paint-order: stroke; stroke-linejoin: round; }
.fv-tdlg {
  position: absolute; left: 10px; right: 10px; top: calc(var(--sat) + 64px); z-index: 4; padding: 10px; border-radius: 16px;
  background: rgba(44,44,46,.97); box-shadow: 0 10px 40px rgba(0,0,0,.5); display: none; flex-direction: column; gap: 10px;
}
.fv-tdlg.on { display: flex; animation: popIn .2s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.fv-tdlg input { height: 44px; border-radius: 11px; border: 0; outline: none; padding: 0 12px; font-size: 17px; background: rgba(118,118,128,.24); color: #fff; }
.fv-tdlg-row { display: flex; align-items: center; gap: 10px; }
.fv-tdlg-row .fv-seg { flex: 1; }
.fv-tdlg-row .fv-seg button { flex: 1; font-size: 12.5px; padding: 6px 4px; }
.fv-tdlg-row .link { font-size: 15px; flex: none; }
.fv-tdlg-row .link[hidden] { display: none; }
.fv-ink .fv-pal button { flex: none; min-width: 0; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--c); }
.fv-ink .fv-pal button.on { background: var(--c); }
.ink text.tx.ph { opacity: .45; }
.fv-tdlg-row.rot { gap: 8px; }
.fv-tdlg-row.rot input[type=range] { flex: 1; min-width: 0; accent-color: #0a84ff; }
.rot-b, .rot-v { flex: none; padding: 6px 8px; border-radius: 9px; background: rgba(118,118,128,.24); color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
.rot-v { min-width: 48px; color: #0a84ff; }
.fv-tdlg-hint { flex: 1; min-width: 0; color: #8e8e93; font-size: 12px; line-height: 1.25; }
.ink circle.pivot { fill: #0a84ff; stroke: #fff; stroke-width: 2; }
.fv-tdlg-lbl { color: #8e8e93; font-size: 13px; flex: none; }
.fv-seg.anc { flex: 1; }
.fv-seg.anc button { flex: 1; font-size: 12.5px; padding: 6px 4px; }
.tz { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tz button { width: 44px; height: 36px; border-radius: 10px; background: rgba(118,118,128,.24); color: #fff; font-size: 22px; line-height: 1; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.tz button:active { background: rgba(118,118,128,.45); }
.tz-v { min-width: 64px; text-align: center; font-size: 16px; color: #fff; font-variant-numeric: tabular-nums; }

.tsty { display: flex; gap: 6px; flex: none; }
.tsty button { width: 36px; height: 36px; border-radius: 10px; background: rgba(118,118,128,.24); color: #fff; font-size: 17px; font-family: Georgia, "PT Serif", serif; }
.tsty button.on { background: #0a84ff; }
.tsty .o-ic { font-weight: 700; color: transparent; -webkit-text-stroke: 1.4px #fff; font-family: -apple-system, Arial, sans-serif; }
.fv-tdlg-row .tz-v { min-width: 58px; }
.fv-tdlg-row .tz button { width: 38px; }
.fv-hud { position: absolute; left: 50%; top: calc(var(--sat) + 74px); transform: translateX(-50%) scale(.9); z-index: 5; padding: 7px 14px; border-radius: 14px; background: rgba(0,0,0,.72); color: #fff; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.fv-hud.on { opacity: 1; transform: translateX(-50%); }
.fv-tdlg.on ~ .fv-hud { display: none; }

/* Панель слоёв PDF */
.fv-layers {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; height: 72%; display: flex; flex-direction: column;
  background: rgba(28,28,30,.98); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); transform: translateY(105%); transition: transform .35s var(--ease); color: #fff;
  padding-bottom: var(--sab);
}
.fv.layers .fv-layers { transform: none; }
.fv.layers .fv-nav, .fv.layers .fv-pages { opacity: 0; pointer-events: none; }
.fl-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 8px; }
.fl-head b { font-size: 20px; }
.fl-head small { flex: 1; color: #8e8e93; font-size: 13px; }
.fl-head .link { font-size: 17px; }
.fl-search { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; height: 38px; padding: 0 10px; border-radius: 10px; background: rgba(118,118,128,.24); color: #8e8e93; }
.fl-search svg { width: 18px; height: 18px; flex: none; }
.fl-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: #fff; font-size: 16px; -webkit-appearance: none; }
.fl-acts { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.fl-acts button { flex: none; padding: 7px 12px; border-radius: 16px; background: rgba(118,118,128,.24); color: #fff; font-size: 13.5px; }
.fl-acts button:active { background: rgba(118,118,128,.45); }
.fl-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 16px; overscroll-behavior: contain; }
.fl-grp { background: rgba(44,44,46,.9); border-radius: 12px; margin-bottom: 8px; overflow: hidden; }
.fl-gh { display: flex; align-items: center; gap: 8px; padding-right: 12px; }
.fl-tg { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 12px 0 12px 12px; color: #fff; text-align: left; }
.fl-tg i { font-style: normal; color: #8e8e93; font-size: 20px; width: 14px; transition: transform .2s; display: inline-block; }
.fl-grp.open .fl-tg i { transform: rotate(90deg); }
.fl-tg b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-tg small { color: #8e8e93; font-size: 13px; flex: none; }
.fl-items { display: none; border-top: .5px solid rgba(255,255,255,.1); }
.fl-grp.open .fl-items { display: block; }
.fl-sub { padding: 10px 14px 4px; font-size: 12.5px; color: #8e8e93; text-transform: uppercase; letter-spacing: .3px; }
.fl-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 14px; font-size: 15px; border-top: .5px solid rgba(255,255,255,.06); -webkit-user-select: none; user-select: none; }
.fl-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fl-empty { text-align: center; color: #8e8e93; padding: 20px; }
.switch.sm { transform: scale(.82); transform-origin: right center; }
.switch.sm[data-mixed]::after { background: #ffd60a; }
/* Ссылки в PDF и оглавление */
.zoom.pdf .pdf-link { position: absolute; z-index: 4; border-radius: 3px; -webkit-tap-highlight-color: transparent; }
.zoom.pdf .pdf-link:active { background: rgba(10,132,255,.25); }
.fv-body.inking .pdf-link { pointer-events: none; }
.fl-tabs { padding: 0 12px 10px; }
.fl-tabs .fv-seg { display: flex; }
.fl-tabs .fv-seg button { flex: 1; }
.fl-tabs[hidden], .fl-toc[hidden], .fl-search[hidden], .fl-acts[hidden], .fl-list[hidden] { display: none; }
.fl-toc { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 16px; overscroll-behavior: contain; }
.toc-it.lvl0 { background: rgba(44,44,46,.9); border-radius: 12px; margin-bottom: 6px; overflow: hidden; }
.toc-row { display: flex; align-items: center; }
.toc-tg, .toc-sp { width: 34px; flex: none; align-self: stretch; color: #8e8e93; font-size: 20px; display: grid; place-items: center; transition: transform .2s; }
.toc-it.open > .toc-row > .toc-tg { transform: rotate(90deg); }
.toc-go { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; padding: 11px 12px 11px 0; color: #fff; text-align: left; font-size: 15px; line-height: 1.3; }
.toc-it.lvl0 > .toc-row .toc-go { font-weight: 600; font-size: 15.5px; }
.toc-go span { flex: 1; min-width: 0; }
.toc-go small { color: #8e8e93; font-size: 13px; flex: none; font-variant-numeric: tabular-nums; }
.toc-go:active { opacity: .6; }
.toc-kids { display: none; padding-left: 14px; border-top: .5px solid rgba(255,255,255,.06); }
.toc-it.open > .toc-kids { display: block; }
.fv-btn[hidden] { display: none; }
.fv-nav b { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.fv-nav b small { font-size: 11px; color: #636366; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-nav .nav-f { font-style: normal; color: #0a84ff; font-weight: 600; margin-right: 5px; }
button.aip-upd { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; color: var(--muted, #8e8e93); background: none; }
button.aip-upd:active { background: rgba(127,127,127,.12); }
.aip-upd-go { display: block; margin-top: 2px; color: #0a84ff; }
.aip-upd.busy { display: flex; align-items: center; gap: 8px; }
.aip-upd .spin { width: 14px; height: 14px; border-width: 2px; border-color: rgba(127,127,127,.25); border-top-color: currentColor; flex: none; }

/* Закреплённое сообщение — плашка под заголовком чата */
.pin-bar { flex: none; display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 14px; max-height: 0; overflow: hidden; opacity: 0;
  background: var(--bar); border-bottom: .5px solid transparent; text-align: left; color: inherit;
  transition: max-height .22s var(--ease), opacity .18s, padding .22s var(--ease); }
.pin-bar.on { max-height: 56px; opacity: 1; padding: 7px 14px; border-bottom-color: var(--sep); }
.pin-bar:active { background: color-mix(in srgb, var(--accent) 8%, var(--bar)); }
.pin-lines { display: flex; flex-direction: column; gap: 2px; align-self: stretch; width: 2.5px; flex: none; }
.pin-lines i { flex: 1; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.pin-lines i.on { background: var(--accent); }
.pin-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pin-txt b { font-size: 13px; font-weight: 600; color: var(--accent); }
.pin-txt b em { font-style: normal; font-weight: 400; color: var(--muted); }
.pin-txt > span { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-go { flex: none; color: var(--muted); display: flex; }
.pin-go svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.meta .pin-ic { width: 11px; height: 11px; margin-right: 3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; vertical-align: -1px; }
.poll-who { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; white-space: normal; }
.msg.out .poll-who { color: rgba(255,255,255,.7); }

/* ================= Комнаты чата: кнопки в заголовке, люди, оффтоп ================= */
.chat-main { position: relative; isolation: isolate; }
.chat-head b, .chat-head small { padding: 0 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-btn { position: absolute; bottom: 7px; width: 42px; height: 38px; display: grid; place-items: center; color: var(--accent); border-radius: 10px; transition: opacity .2s, transform .25s var(--ease); }
.ch-btn:active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ch-btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ch-l { left: 6px; } .ch-r { right: 6px; }
#chatMain.can-back .ch-btn { opacity: 0; pointer-events: none; transform: scale(.8); }
.hb { position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #ff3b30; color: #fff;
  font: 600 11px/17px -apple-system, system-ui, sans-serif; font-style: normal; text-align: center; }
.chat-back .hb { position: static; display: inline-block; margin-left: 5px; vertical-align: 2px; }
.chat-back { white-space: nowrap; }

/* Люди */
.chat-people { position: absolute; inset: 0; z-index: 5; background: var(--bg); display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .32s var(--ease); visibility: hidden; }
.chat-people.on { transform: none; visibility: visible; }
.pp-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--sat) + 10px) 16px 10px; border-bottom: .5px solid var(--sep); background: var(--bar); }
.pp-head b { font-size: 17px; font-weight: 600; }
.pp-head .link { font-size: 17px; }
.pp-hint { margin: 10px 18px 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.pp-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 calc(var(--tabbar-h) + var(--sab) + 10px); }
.pp-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 16px; text-align: left; color: inherit; }
.pp-row:active { background: var(--card); }
.pp-ava { position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; font-weight: 600; color: #fff;
  background: linear-gradient(160deg, hsl(var(--h) 65% 62%), hsl(var(--h) 60% 48%)); }
.pp-on { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #34c759; border: 2px solid var(--bg); }
.pp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 0; border-bottom: .5px solid var(--sep); align-self: stretch; justify-content: center; }
.pp-row:last-child .pp-txt { border-bottom: 0; }
.pp-txt b { font-size: 16px; font-weight: 600; }
.pp-txt small { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-txt small.on { color: var(--accent); }
.pp-end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; align-self: stretch; justify-content: center; }
.pp-end small { font-size: 12.5px; color: var(--muted); }
.pp-end .hb { position: static; }

/* Оффтоп: закат у моря с силуэтами пальм */
.palms { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .5s ease; background: #120626; }
#chatMain.room-off .palms { opacity: 1; }
.palms .scene { width: 100%; height: 100%; stroke: none; display: block; }
.scene .st { fill: #fff; opacity: .7; animation: twinkle 3.2s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .15; } to { opacity: .85; } }
.scene .rf { fill: #ff8a4c; opacity: .55; animation: ripple 3.5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes ripple { from { transform: scaleX(.75); opacity: .3; } to { transform: scaleX(1.08); opacity: .65; } }
.scene .isl { fill: #170722; }
.scene .sil { fill: #0a0310; }
.scene .sil path:not(.trunk) { fill: none; stroke: #0a0310; stroke-width: 4.5; stroke-linecap: round; }
.scene .crown { animation: sway 7s ease-in-out infinite alternate; }
.scene .crown:nth-of-type(2) { animation-delay: -2.5s; }
@keyframes sway { from { transform: rotate(-2.5deg); } to { transform: rotate(2.5deg); } }
.palms .scene { transform: translateY(24px) scale(1.04); transition: transform .9s cubic-bezier(.2,.9,.3,1); }
#chatMain.room-off .palms .scene { transform: none; }
#chatMain:not(.room-off) .scene * { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .scene * { animation: none !important; } }
/* Заголовок, подписи и поле ввода — в тон закату */
#chatMain.room-off .chat-head { background: rgba(18, 6, 38, .82); border-bottom-color: rgba(255,255,255,.08); }
#chatMain.room-off .chat-head b { color: #fff; }
#chatMain.room-off .chat-head small { color: rgba(255,255,255,.6); }
#chatMain.room-off .chat-back { color: #ffb36b; }
#chatMain.room-off .chat-day span { background: rgba(0,0,0,.35); color: rgba(255,255,255,.85); }
#chatMain.room-off .chat-empty { color: rgba(255,255,255,.8); }
#chatMain.room-off .msg.in .bubble { background: rgba(30, 12, 48, .78); color: #fff; }
#chatMain.room-off .msg.in .bubble .meta { color: rgba(255,255,255,.55); }
#chatMain.room-off .msg.out .bubble { background: linear-gradient(135deg, #ff6a3d, #d6336c); }
#chatMain.room-off .bubble .nick { color: #ffb36b; }
#chatMain.room-off .composer, #chatMain.room-off .compose-bar { background: rgba(12, 4, 24, .9); border-top-color: rgba(255,255,255,.08); }
#chatMain.room-off .c-input { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.12); }
#chatMain.room-off .c-send { background: #ff6a3d; }
#chatMain.room-off .pin-bar { background: rgba(18, 6, 38, .82); color: #fff; border-bottom-color: rgba(255,255,255,.08); }
#chatMain.room-off .pin-txt b { color: #ffb36b; }
/* Нижняя панель схем — крупнее */
.fv-nav { padding: 8px 6px 7px; border-radius: 22px; left: 8px; right: 8px; }
.fv-nav-t { font-size: 17px; line-height: 1.28; padding: 4px 12px 6px; }
.fv-nav button { font-size: 16px; padding: 11px 8px; min-height: 48px; border-radius: 15px; }
.fv-nav svg { width: 26px; height: 26px; stroke-width: 2.6; }
.fv-nav b { font-size: 16px; }
.fv-nav b small { font-size: 13px; max-width: 110px; color: #8e8e93; }
.fv-nav .nav-f { font-size: 16px; }
.fv.has-nav .fv-pages { bottom: calc(var(--sab) + 150px); font-size: 15px; }
.fv-nav button span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.22; font-size: 15px; word-break: break-word; }
.fv-nav b { max-width: 96px; }
.fv-nav-t { -webkit-line-clamp: unset; display: block; }
/* Номер страницы — всегда над панелью, какой бы высоты она ни была */
.fv.has-nav .fv-pages { bottom: calc(var(--sab) + 12px + var(--navh, 130px) + 10px); }
.fv.zoomed .fv-nav { transform: translateY(calc(100% + 40px)); opacity: 0; pointer-events: none; }
.fv.zoomed.has-nav .fv-pages { bottom: calc(var(--sab) + 16px); }
.fv.zoomed.nav-peek .fv-nav { transform: none; opacity: 1; pointer-events: auto; }
.fv.zoomed.nav-peek.has-nav .fv-pages { bottom: calc(var(--sab) + 12px + var(--navh, 130px) + 10px); }
.fv.has-nav .fv-name { cursor: pointer; }
.fv.has-nav .fv-name:active { opacity: .6; }
