:root {
  --bg: #f4f5f8;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e3e6ec;
  --soft: #eef1f6;
  --accent: #2f6fed;
  --accent-soft: #e6eefe;
  --accent-ink: #ffffff;
  --danger: #d92d20;
  --ok: #2f7d4f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131c;
    --card: #171c27;
    --ink: #e7eaf0;
    --muted: #98a2b3;
    --line: #283041;
    --soft: #1e2431;
    --accent: #5b8cff;
    --accent-soft: #1d2a47;
    --danger: #f0605a;
    --ok: #4cb27a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
body.viewer-open { overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 650; }
.muted { color: var(--muted); }

/* нажатие на любую кнопку видно сразу */
button { transition: transform .08s ease, background-color .15s ease, border-color .15s ease, color .15s ease; font: inherit; color: inherit; }
button:active { transform: scale(.95); }
.drag-handle:active { transform: none; }

.ico { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico.fill { fill: currentColor; stroke: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  cursor: pointer; font-weight: 600; font-size: .93rem; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
.btn.small .ico { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border: 0; border-radius: 10px; background: transparent; color: inherit;
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0 2px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.link-btn .ico { width: 15px; height: 15px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--soft); color: var(--muted); }
.chip.today { background: var(--accent-soft); color: var(--accent); }
.chip.gpt { background: #e9f7ef; color: #1a7f45; }
@media (prefers-color-scheme: dark) { .chip.gpt { background: #183526; color: #6fd39b; } }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 750; font-size: 1.05rem; }
.brand-ico { width: 30px; height: 30px; color: var(--accent); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.remote-btn.on { background: #e8590c; border-color: #e8590c; color: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, #e8590c 25%, transparent); }
.follow-ind {
  border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  background: #fff1e6; color: #c2410c; font-weight: 650; font-size: .85rem;
}
.follow-ind.off { background: var(--soft); color: var(--muted); }
.follow-ind.small { padding: 5px 10px; font-size: .8rem; margin-right: 2px; white-space: nowrap; }
.viewer .follow-ind.off { background: #222936; color: #9aa4b5; }
.viewer .v-remote.on, .viewer .v-remote.on:hover { background: #e8590c; color: #fff; }
@media (prefers-color-scheme: dark) { .follow-ind { background: #3a2312; color: #fb923c; } }

main { max-width: 980px; margin: 0 auto; padding: 18px 16px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 16px; flex-wrap: wrap; }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty-ico { font-size: 2.6rem; margin-bottom: 8px; }

/* ---------- список мероприятий ---------- */
.events-list { display: flex; flex-direction: column; gap: 10px; }
.event-card {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 8px 10px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; outline: none;
  transition: border-color .15s ease, transform .08s ease;
}
.event-card:hover, .event-card:focus-visible { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.event-card:active { transform: scale(.99); }
.ec-cover {
  width: 88px; height: 56px; border-radius: 9px; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--soft); color: var(--muted);
}
.ec-cover img { width: 100%; height: 100%; object-fit: cover; }
.ec-cover .ico { width: 28px; height: 28px; }
.ec-main { flex: 1; min-width: 0; }
.ec-title { font-weight: 650; font-size: 1.02rem; overflow-wrap: anywhere; }
.ec-meta { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.gpt-link { display: block; text-align: center; margin-top: 18px; font-weight: 600; }
.show-sm { display: none; }

/* ---------- мероприятие ---------- */
.event-head { display: flex; align-items: flex-start; gap: 6px; margin: 2px 0 12px -6px; }
.ev-title { flex: 1; min-width: 0; padding-top: 4px; }
.ev-title h1 { overflow-wrap: anywhere; }
.ev-date { color: var(--muted); margin-top: 3px; }
#eventView.missing #evEditBtn, #eventView.missing .ev-actions { display: none; }
.ev-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.drop-hint { color: var(--muted); font-size: .88rem; margin-left: 4px; }

.uploads { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.upload-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.upload-row.is-error { border-color: var(--danger); }
.up-main { flex: 1; min-width: 0; }
.up-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-bar { height: 5px; border-radius: 3px; background: var(--soft); overflow: hidden; margin: 6px 0 4px; }
.up-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s ease; }
.upload-row.is-done .up-bar i { background: var(--ok); }
.upload-row.is-error .up-bar i { background: var(--danger); }
.up-meta { font-size: .82rem; color: var(--muted); }
.upload-row.is-error .up-meta { color: var(--danger); }

.files-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 7px 6px 7px 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.file-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.file-row.dragging {
  z-index: 30; cursor: grabbing; border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(16, 24, 40, .25);
}
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
body.is-dragging .file-row:not(.dragging) { pointer-events: none; }
.drag-handle {
  touch-action: none; width: 30px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; padding: 0; border-radius: 8px;
  color: var(--muted); cursor: grab;
}
.drag-handle:hover { color: var(--ink); background: var(--soft); }
.file-row.dragging .drag-handle { color: var(--accent); cursor: grabbing; }
.file-thumb {
  position: relative; width: 92px; height: 58px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: var(--soft); display: flex; align-items: center; justify-content: center;
}
.file-thumb img { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; }
.file-thumb .type-ico { position: absolute; left: 4px; bottom: 4px; width: 22px; height: 27px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.file-thumb.no-thumb .type-ico { position: static; width: 34px; height: 42px; filter: none; }
.file-main { flex: 1; min-width: 0; }
.file-name { font-weight: 620; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: .84rem; margin-top: 2px; display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.file-meta .err { color: var(--danger); font-weight: 600; }
.file-actions { display: flex; align-items: center; }
.rename-input {
  width: 100%; font: inherit; font-weight: 600; padding: 6px 9px;
  border: 1.5px solid var(--accent); border-radius: 8px; background: var(--card); color: var(--ink); outline: none;
}
.spin {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- значок типа ---------- */
.type-ico { display: block; }
.type-ico.small { width: 22px; height: 27px; }
.type-ico.big { width: 64px; height: 80px; margin: 0 auto 10px; }

/* ---------- просмотр ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: #0c1017; color: #e6e9ef; outline: none;
}
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .09); }
.vbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  padding-top: max(6px, env(safe-area-inset-top));
  background: #141922; border-bottom: 1px solid #222936;
}
.vtitle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.vname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpager { display: flex; align-items: center; }
.vpage-no { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .92rem; }
.vzoom { display: flex; align-items: center; margin: 0 4px; }
.zoom-val { border: 0; background: none; color: inherit; min-width: 54px; font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 8px; padding: 6px 2px; font-size: .88rem; }
.zoom-val:hover { background: rgba(255, 255, 255, .09); }
.vbody { flex: 1; min-height: 0; display: flex; }
.stage {
  position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; background: #0c1017;
}
.stage.zoomed { cursor: grab; }
.stage.zoomed.panning { cursor: grabbing; }
.stage-content { position: absolute; inset: 0; }
.page-img {
  position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0;
  background: #fff; box-shadow: 0 6px 28px rgba(0, 0, 0, .45); -webkit-user-drag: none; user-select: none;
}
.page-img.is-image { background: transparent; box-shadow: none; }
.page-img.anim { transition: width .22s ease, height .22s ease, transform .22s ease; }
.media-el { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.stage-msg audio { width: min(520px, 90vw); margin-top: 14px; }
.viewer.kind-media .stage, .viewer.kind-none .stage { touch-action: auto; }
.stage-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center; color: #c9d0dc;
}
.stage-msg .muted { color: #8b95a7; }
.stage-msg-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.stage-msg .btn { background: #1d2430; border-color: #2c3544; color: #e6e9ef; }
.stage-msg .btn.primary { background: var(--accent); border-color: var(--accent); }

.nav-arrow {
  position: absolute; top: calc(50% - 26px); z-index: 2;
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 25, 34, .55); color: #fff; cursor: pointer; opacity: 0;
  transition: opacity .2s ease, transform .08s ease;
}
.nav-arrow .ico { width: 26px; height: 26px; }
.nav-arrow.prev { left: 12px; }
.nav-arrow.next { right: 12px; }
.stage:hover .nav-arrow:not(:disabled) { opacity: .85; }
.nav-arrow:disabled { display: none; }
.viewer.single .nav-arrow { display: none; }
@media (hover: none) { .nav-arrow { display: none; } }

/* лента страниц: слева на компьютере, снизу на телефоне */
.vstrip {
  position: relative; order: -1; width: 168px; flex-shrink: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 10px; padding: 12px 10px;
  background: #11161e; border-right: 1px solid #222936; overscroll-behavior: contain;
}
.viewer.single .vstrip { display: none; }
.thumb {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; color: #9aa4b5;
  flex-shrink: 0;
}
.thumb-img {
  display: block; width: 100%; max-height: 220px; border-radius: 6px; overflow: hidden; background: #fff;
  outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s ease;
}
.thumb-img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb-no { display: block; text-align: center; font-size: .78rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.thumb:hover .thumb-img { outline-color: #3b4558; }
.thumb.cur .thumb-img { outline-color: var(--accent); }
.thumb.cur .thumb-no { color: #fff; font-weight: 700; }

/* полный экран: только файл */
.viewer.is-fs .vbar { display: none; }
.viewer.is-fs .vstrip { display: none; }
.viewer.is-fs .stage { background: #000; }
.viewer.is-fs .page-img { box-shadow: none; }
.viewer.is-fs.controls-hidden .stage { cursor: none; }
.fs-bar {
  position: absolute; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 3;
  display: none; align-items: center; gap: 2px; padding: 4px;
  background: rgba(18, 22, 30, .78); border-radius: 12px; color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity .25s ease;
}
.viewer.is-fs .fs-bar { display: flex; }
.fs-page { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
.viewer.single .fs-bar #fsPrev, .viewer.single .fs-bar #fsNext, .viewer.single .fs-page { display: none; }
.viewer.kind-media .fs-bar #fsZoomIn, .viewer.kind-media .fs-bar #fsZoomOut,
.viewer.kind-none .fs-bar #fsZoomIn, .viewer.kind-none .fs-bar #fsZoomOut { display: none; }
.viewer.is-fs.controls-hidden .fs-bar, .viewer.is-fs.controls-hidden .nav-arrow { opacity: 0; pointer-events: none; }
.fs-hint {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 4;
  background: rgba(20, 25, 34, .85); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: .9rem; cursor: pointer;
  white-space: nowrap;
}
.fs-hint.sound { top: auto; bottom: 18px; }

/* полный экран на устройстве-пульте: слайд + лента ближайших слайдов для выбора */
body.remote-ctl .viewer.is-fs .vbody { flex-direction: column; }
body.remote-ctl .viewer.is-fs .vstrip {
  display: flex; order: 1; flex-direction: row; width: auto; height: 124px;
  overflow-x: auto; overflow-y: hidden; padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-right: 0; border-top: 1px solid #222936; background: #0b0e14;
}
body.remote-ctl .viewer.single.is-fs .vstrip { display: none; }
body.remote-ctl .viewer.is-fs .vstrip .thumb { width: auto; height: 100%; }
body.remote-ctl .viewer.is-fs .vstrip .thumb-img { height: calc(100% - 20px); width: auto; max-height: none; }
body.remote-ctl .viewer.is-fs .vstrip .thumb-img img { width: auto; height: 100%; }
/* на пульте панель кнопок — отдельной строкой сверху, не поверх слайда */
body.remote-ctl .viewer.is-fs .vbody { padding-top: calc(58px + env(safe-area-inset-top)); background: #0b0e14; }
body.remote-ctl .viewer.is-fs .fs-bar { position: fixed; opacity: 1 !important; pointer-events: auto !important; top: max(6px, env(safe-area-inset-top)); bottom: auto; }
body.remote-ctl .viewer.is-fs .stage { cursor: default; }
@media (orientation: portrait) {
  body.remote-ctl .viewer.is-fs .stage { flex: 0 0 auto; height: min(58vh, calc(100vw * .72)); }
  body.remote-ctl .viewer.is-fs .vstrip {
    flex: 1; height: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    align-content: start; gap: 12px; overflow-x: hidden; overflow-y: auto;
  }
  body.remote-ctl .viewer.is-fs .vstrip .thumb { width: 100%; height: auto; }
  body.remote-ctl .viewer.is-fs .vstrip .thumb-img { width: 100%; height: auto; }
  body.remote-ctl .viewer.is-fs .vstrip .thumb-img img { width: 100%; height: 100%; }
}

/* ---------- таблицы Excel: живой лист и вкладки листов ---------- */
.viewer.kind-sheet .stage { touch-action: auto; background: #fff; }
.viewer.kind-sheet .vstrip, .viewer.kind-sheet .nav-arrow { display: none !important; }
.sheet-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; }
.sheet-frame { flex: 1; min-height: 0; width: 100%; border: 0; display: block; background: #fff; }
.sheet-tabs {
  flex-shrink: 0; display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden;
  padding: 0 8px max(0px, env(safe-area-inset-bottom)); background: #e8ebf0; border-top: 1px solid #cdd3dc;
  scrollbar-width: thin; transition: opacity .25s ease;
}
.sheet-tab {
  flex-shrink: 0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 0; border-bottom: 3px solid transparent; background: transparent; color: #3b4452;
  padding: 9px 16px 7px; font-size: .86rem; cursor: pointer;
}
.sheet-tab:hover { background: #f4f6f9; }
.sheet-tab.cur { background: #fff; color: #17733e; font-weight: 700; border-bottom-color: #1e8e4e; }
.viewer.kind-sheet .fs-bar { bottom: calc(52px + env(safe-area-inset-bottom)); }
.viewer.is-fs.controls-hidden .sheet-tabs { opacity: 0; pointer-events: none; }
body.remote-ctl .viewer.is-fs .sheet-tabs { opacity: 1; pointer-events: auto; }
body.remote-ctl .viewer.kind-sheet.is-fs .stage { flex: 1; height: auto; }
body.remote-ctl .viewer.kind-sheet.is-fs .fs-bar { bottom: auto; }

/* ---------- QR на весь экран ---------- */
.qr-full { position: fixed; inset: 0; z-index: 60; background: #fff; color: #111; display: flex; align-items: center; justify-content: center; }
.qr-full-inner { text-align: center; padding: 20px; }
.qr-full-title { font-size: clamp(1.1rem, 3vw, 2rem); font-weight: 700; margin-bottom: 14px; }
.qr-full-code svg { width: min(72vh, 86vw); height: auto; display: block; margin: 0 auto; }
.qr-full-url { font-size: clamp(1rem, 2.4vw, 1.6rem); margin-top: 12px; font-weight: 600; color: #333; }
.qr-close { position: absolute; top: 14px; right: 14px; color: #111; }
.qr-close:hover { background: #eee; }

/* ---------- окна ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 14, 22, .5); animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); color: var(--ink); border-radius: 16px; padding: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-card p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions.wrap { flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.field input, .field select {
  font: inherit; font-weight: 500; font-size: 1rem; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.title-pick { display: flex; gap: 6px; align-items: center; }
.title-pick select { flex: 1; min-width: 0; }
.pin-card { text-align: center; }
.pin-wrap { display: flex; justify-content: center; }
#pinInput {
  width: 210px; text-align: center; font-size: 2rem; letter-spacing: .5em; padding: 10px 0 10px .5em;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); outline: none;
}
#pinInput:focus { border-color: var(--accent); }
.pin-card .modal-actions { justify-content: center; }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); color: var(--ink); }
.share-qr { display: flex; justify-content: center; }
.share-qr svg { width: 220px; height: 220px; background: #fff; border-radius: 10px; }

.menu-pop {
  position: fixed; z-index: 80; min-width: 200px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; font-size: .93rem;
}
.menu-item:hover { background: var(--soft); }
.menu-item.danger { color: var(--danger); }

.drop-overlay {
  position: fixed; inset: 10px; z-index: 50; border: 3px dashed var(--accent); border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700; color: var(--accent); pointer-events: none;
}

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translateX(-50%) translateY(16px);
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 10px;
  background: #1d2433; color: #fdf7ee; font-size: .9rem; font-weight: 600; line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.toast-error { background: #8a2f14; }
.toast.toast-success { background: #2f6b39; }
.toast-action { border: 1px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .12); color: #fff; border-radius: 8px; padding: 5px 10px; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* ---------- страница ChatGPT ---------- */
.doc { max-width: 760px; margin: 0 auto; }
.doc-head { display: flex; align-items: center; gap: 6px; margin: 0 0 10px -6px; }
.doc .lead { font-size: 1.02rem; margin: 0 0 16px; }
.card-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-box h2 { margin-bottom: 8px; }
.card-box p { margin: 6px 0 10px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.copy-block { display: flex; align-items: center; gap: 8px; margin: 6px 0; background: var(--soft); border-radius: 10px; padding: 6px 6px 6px 12px; }
.copy-block code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .88rem; }
.copy-block.multi { align-items: flex-start; flex-direction: column; padding: 10px 12px; }
.copy-block pre { margin: 0; white-space: pre-wrap; font: .82rem/1.45 Consolas, "Cascadia Mono", Menlo, monospace; max-height: 240px; overflow: auto; width: 100%; }
.copy-block.multi .btn { align-self: flex-end; }

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  main { padding: 12px 12px 80px; }
  h1 { font-size: 1.28rem; }
  .hide-sm { display: none !important; }
  .show-sm { display: block; }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .brand span { font-size: .98rem; }
  .follow-ind { padding: 5px 9px; font-size: .78rem; }
  .ev-actions .btn { flex: 1 1 auto; }
  .ev-actions .btn.primary { flex-basis: 100%; }
  .file-row { gap: 8px; padding-right: 2px; }
  .drag-handle { width: 34px; height: 50px; }
  .file-thumb { width: 72px; height: 48px; }
  .file-actions .icon-btn { width: 36px; }
  .ec-cover { width: 70px; height: 46px; }
  .vbody { flex-direction: column; }
  .vstrip {
    order: 1; width: auto; height: 92px; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid #222936;
  }
  .vstrip .thumb { width: auto; height: 100%; }
  .vstrip .thumb-img { height: calc(100% - 19px); width: auto; max-height: none; }
  .vstrip .thumb-img img { width: auto; height: 100%; }
  .vpage-no { min-width: 52px; font-size: .86rem; }
  .vbar .icon-btn { width: 38px; }
  .viewer.kind-sheet .vzoom { display: flex !important; margin: 0; }
  .viewer.kind-sheet .vpager { display: none !important; }
  .viewer.kind-sheet .vzoom .icon-btn { width: 34px; }
  .viewer.kind-sheet .zoom-val { min-width: 44px; font-size: .8rem; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .fs-bar { right: 50%; transform: translateX(50%); }
  body.remote-ctl .viewer.is-fs .fs-bar { right: 50%; }
}
