:root {
  --bg-color: #0f0f12;
  --card-bg: #16161c;
  --primary: #53fc18;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --border-color: rgba(255, 255, 255, 0.08);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text);
  user-select: none;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  padding-bottom: 120px;
}

.nav-bar {
  display: flex;
  background: rgba(20, 20, 26, 0.95);
  backdrop-filter: blur(10px);
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  left: 16px;
  right: 16px;
  z-index: 100;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  justify-content: space-around;
  align-items: center;
  box-sizing: border-box;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn svg {
  stroke: var(--text-muted);
  transition: stroke 0.2s ease;
}

.nav-btn.active {
  color: var(--primary);
  background: rgba(83, 252, 24, 0.12);
}

.nav-btn.active svg {
  stroke: var(--primary);
}

.tab-content { display: none; padding: 20px; box-sizing: border-box; }
.tab-content.active { display: block; }

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 15px 0;
  letter-spacing: -0.5px;
}

.action-btn {
  background: var(--primary);
  color: #0b0b0e;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.action-btn:active { opacity: 0.8; }

.secondary-btn, .cancel-btn {
  background: #23232f;
  color: var(--text);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.sub-tab-btn {
  background: #16161c;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  flex: 1;
  transition: all 0.2s ease;
}
.sub-tab-btn.active {
  background: var(--primary);
  color: #0b0b0e;
  border-color: var(--primary);
}
.sub-tab-content { display: none; }
.sub-tab-content.active { display: block; }

.items-list { display: flex; flex-direction: column; gap: 12px; }
.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.badge { padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge.queued { background: rgba(255, 235, 59, 0.15); color: #ffeb3b; }
.badge.processing { background: rgba(13, 71, 161, 0.25); color: #90caf9; }
.badge.done { background: rgba(27, 94, 32, 0.25); color: #a5d6a7; }

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #2b2b36;
  transition: .3s;
  border-radius: 26px;
  border: 1px solid var(--border-color);
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); border-color: var(--primary); }
input:checked + .slider:before { background-color: #0f0f12; transform: translateX(22px); }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(5px);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal.active { display: flex; }
.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 20px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-card input, .modal-card select {
  width: 100%;
  padding: 12px;
  margin: 8px 0 16px;
  background: #111116;
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 10px;
  box-sizing: border-box;
  font-size: 14px;
}

.editor-mode { display: none; position: fixed; inset: 0; background: #000; z-index: 200; flex-direction: column; }
.editor-mode.active { display: flex; }

.editor-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  box-sizing: border-box;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-shrink: 0;
}
.editor-header input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  outline: none;
  text-align: center;
}

.editor-main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.canvas-wrapper {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  overflow: visible;
  background: #000;
  position: relative;
  padding: 8px 8px 14px;
  min-height: calc(clamp(400px, 56vh, 620px) + 118px);
}

.template-preview-picker {
  position: relative; z-index: 150; width: min(100%, 420px); box-sizing: border-box; flex-shrink: 0;
  display: flex; align-items: center; gap: 7px; padding: 7px 8px;
  background: rgba(15,15,18,.9); border: 1px solid #30303a; border-radius: 10px;
  backdrop-filter: blur(8px);
}
.template-preview-picker label { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.template-preview-picker select {
  min-width: 0; flex: 1; padding: 6px; color: #fff; background: #1b1b24;
  border: 1px solid #383844; border-radius: 7px; font-size: 11px;
}
.template-preview-options { display: flex; gap: 7px; align-items: center; width: min(100%, 420px); flex-shrink: 0; }
.template-preview-options > input { flex: 1; min-width: 0; padding: 7px; background: #1b1b24; color: #fff; border: 1px solid #383844; border-radius: 7px; font-size: 11px; }
.template-preview-options label { display: none; color: #fff; border: 1px solid #383844; border-radius: 7px; padding: 7px; font-size: 11px; cursor: pointer; }
.template-preview-options label.visible { display: block; }
.template-preview-options input[type=file] { display: none; }

.canvas {
  width: auto;
  height: clamp(400px, 56vh, 620px);
  max-width: calc(100vw - 16px);
  max-height: none;
  flex: 0 0 auto;
  aspect-ratio: 9 / 16;
  background: #14141a;
  position: relative;
  border: 2px dashed #333;
  overflow: hidden;
  box-sizing: border-box;
}

.inspector {
  width: 100%;
  height: auto;
  min-height: 280px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: visible;
}
.inspector h4 { margin-top: 0; font-size: 13px; margin-bottom: 8px; color: var(--text-muted); }
.field-group { margin-bottom: 10px; }
.field-group label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.field-group input, .field-group select {
  width: 100%;
  padding: 8px;
  background: #111116;
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 13px;
}

.element {
  position: absolute;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.7);
  font-size: 11px;
  cursor: move;
  border-radius: 6px;
  box-sizing: border-box;
}
.element .preview-media { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; border-radius: inherit; pointer-events: none; z-index: 0; }
.element .preview-media video, .element .preview-media img { position: absolute; max-width: none; object-fit: cover; }
.element .element-caption { position: relative; z-index: 2; padding: 2px 4px; border-radius: 4px; background: rgba(0,0,0,.6); pointer-events: none; }
.element.has-preview { background: transparent; }
.element[data-type="title"], .element[data-type="subtitles"] {
  width: auto !important;
  height: auto !important;
  white-space: normal !important;
  word-break: break-word;
}
.element.selected { border-color: var(--primary); box-shadow: 0 0 10px rgba(83,252,24,0.4); }
.element.locked {
  border-color: var(--primary);
  background: rgba(0, 0, 0, 0.9);
  cursor: not-allowed;
}

/* Маркеры изменения размера (ресайза) для элементов геймплея, фото, моментов */
.resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: 2px solid #000;
  border-radius: 50%;
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
  display: none;
  z-index: 10;
}
.element.selected .resize-handle {
  display: block;
}

.editor-toolbar {
  width: 100%;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom, 16px)) 16px;
  border-top: 1px solid var(--border-color);
  box-sizing: border-box;
  flex-shrink: 0;
}
.tool-btn { background: #22222d; color: #fff; border: none; padding: 8px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; }

.live-preview-block { display: flex; flex-direction: column; align-items: center; gap: 7px; margin: 10px 0 4px; }
#render-modal .modal-card { max-height: 94vh; overflow-y: auto; box-sizing: border-box; }
.live-preview {
  position: relative; height: min(32vh, 300px); aspect-ratio: 9 / 16; overflow: hidden;
  background: #08080b; border: 1px solid #32323d; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.final-preview-image { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.final-preview-image.active { display: block; }
.preview-scrub { width: min(100%, 300px); accent-color: var(--primary); margin: 2px 0; }
#tpl-preview-time { flex-shrink: 0; }
#tpl-preview-play { flex-shrink: 0; }
.preview-status { flex-shrink: 0; min-height: 0; color: #bbb; font-size: 12px; text-align: center; }
#render-live-preview .final-preview-image { z-index: 110; }
#canvas-9-16.preview-active > .element.selected { z-index: 120 !important; background: transparent; }
#canvas-9-16.preview-active > .element.selected .preview-media,
#canvas-9-16.preview-active > .element.selected .element-caption { visibility: hidden; }
#canvas-9-16.preview-active > .element.selected .resize-handle { visibility: visible; }
#tpl-final-preview { z-index: 110; }
.mv-stage.final-active > video, .mv-stage.final-active > .mv-sub-overlay { visibility: hidden; }
.mv-stage.final-active > .final-preview-image { z-index: 5; }
.preview-layer { position: absolute; overflow: hidden; box-sizing: border-box; pointer-events: none; }
.preview-layer video, .preview-layer img { position: absolute; max-width: none; }
.preview-text { display: flex; align-items: center; justify-content: center; width: max-content; max-width: calc(100% - 12px); text-align: center; font-weight: 800; line-height: 1.05; text-shadow: 0 2px 5px #000, 0 0 2px #000; white-space: normal; }
.preview-kick { color: #fff; font-weight: 900; white-space: nowrap; text-shadow: 0 2px 4px #000; }
.preview-kick b { color: #53fc18; }
.preview-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 15px; color: #777; font-size: 11px; text-align: center; }
.preview-toggle { border: 1px solid #3a3a45; background: #202029; color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 11px; cursor: pointer; }
.preview-toggle.playing { color: var(--primary); border-color: rgba(83,252,24,.55); }


/* ═════════════ v3.0 ═════════════ */
.modal { z-index: 300; }
.badge.failed { background: rgba(211, 47, 47, 0.2); color: #ff8a80; }

/* Иконка-кнопка обновления */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #23232f;
  border: 1px solid var(--border-color);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.1s ease;
}
.icon-btn:active { transform: scale(0.94); background: #2d2d3b; }
.icon-btn .ic { width: 24px; height: 24px; }
.icon-btn.spinning .ic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Пояснения на страницах */
.page-hint {
  background: rgba(83, 252, 24, 0.07);
  border: 1px solid rgba(83, 252, 24, 0.18);
  color: #c9d1c4;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 14px;
}
.page-hint b { color: var(--primary); font-weight: 600; }
.page-hint.compact { font-size: 12px; padding: 10px 12px; margin: 10px 0; }

.howto-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.howto-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.howto-step { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.4; color: #cfcfd6; margin-bottom: 8px; }
.howto-step:last-child { margin-bottom: 0; }
.howto-step .num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #0b0b0e; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.howto-step b { color: #fff; }

/* Кнопка-ссылка на канал с футажами */
.channel-btn {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(83,252,24,0.16), rgba(83,252,24,0.05));
  border: 1px solid rgba(83,252,24,0.4);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 14px;
  color: #fff; text-decoration: none;
}
.channel-btn:active { opacity: 0.8; }
.channel-ico { font-size: 26px; }
.channel-text { flex: 1; display: flex; flex-direction: column; }
.channel-text b { font-size: 15px; }
.channel-text small { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.channel-arrow { color: var(--primary); font-size: 26px; line-height: 1; }

.clip-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.clip-actions .action-btn, .clip-actions .secondary-btn { padding: 7px 12px; font-size: 12px; }

/* Моменты */
.moment-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.moment-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.moment-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.moment-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.moment-actions { display: flex; gap: 8px; margin-top: 12px; }
.moment-actions .action-btn, .moment-actions .secondary-btn { flex: 1; padding: 10px 8px; font-size: 13px; }
.moment-actions .cancel-btn { padding: 10px 14px; font-size: 13px; flex: 0 0 auto; }

.chip { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.chip.none { background: rgba(255,235,59,0.14); color: #ffeb3b; }
.chip.processing { background: rgba(13,71,161,0.3); color: #90caf9; animation: pulse 1.4s ease-in-out infinite; }
.chip.done { background: rgba(27,94,32,0.3); color: #a5d6a7; }
.chip.failed { background: rgba(211,47,47,0.22); color: #ff8a80; }
@keyframes pulse { 50% { opacity: 0.55; } }

.tpl-badge { display:inline-block; padding: 2px 7px; border-radius: 6px; font-size: 10px; background: rgba(83,252,24,0.15); color: var(--primary); margin-left: 6px; font-weight: 600; vertical-align: middle; }

.warn-box {
  background: rgba(255, 235, 59, 0.1);
  border: 1px solid rgba(255, 235, 59, 0.35);
  color: #ffe98a; border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.4;
}

/* ═════════════ Редактор момента ═════════════ */
.mv-editor { display: none; position: fixed; inset: 0; background: var(--bg-color); z-index: 250; flex-direction: column; }
.mv-editor.active { display: flex; }
.mv-header {
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top, 10px)) 12px 10px;
  background: var(--card-bg); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.mv-title {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: #fff; font-size: 15px; font-weight: 700; text-align: center;
}
.mv-save-state { font-size: 11px; color: var(--text-muted); width: 62px; text-align: right; flex-shrink: 0; }
.mv-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 14px; }
.mv-footer {
  flex-shrink: 0; padding: 10px 14px max(14px, env(safe-area-inset-bottom, 14px));
  background: rgba(15,15,18,0.96); border-top: 1px solid var(--border-color);
}
.mv-create { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }

.mv-stage-wrap { display: flex; justify-content: center; }
.mv-stage {
  position: relative; width: 100%; max-width: 420px; aspect-ratio: 9 / 8;
  background: #000; overflow: hidden; border-radius: 14px; border: 1px solid var(--border-color);
  touch-action: pan-y;
}
.mv-stage.pannable { touch-action: none; cursor: grab; }
.mv-stage video { position: absolute; max-width: none; max-height: none; left: 0; top: 0; pointer-events: none; }
.mv-sub-overlay {
  position: absolute; left: 0; right: 0; bottom: 10%; text-align: center; pointer-events: none;
  color: #fff; font-weight: 800; font-size: 26px; letter-spacing: 0.5px;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000, 0 3px 6px rgba(0,0,0,.6);
}
.mv-stage-hint {
  position: absolute; z-index: 10; top: 8px; left: 8px; right: 8px; text-align: center; font-size: 11px; color: #fff;
  background: rgba(0,0,0,0.55); padding: 4px 8px; border-radius: 8px; pointer-events: none; display: none;
}
.mv-stage.pannable .mv-stage-hint { display: block; animation: fadeout 4s forwards; }
@keyframes fadeout { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

.mv-tplrow { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 12px; color: var(--text-muted); }
.mv-tplrow select {
  flex: 1; min-width: 0; padding: 8px; background: #111116; border: 1px solid var(--border-color);
  color: #fff; border-radius: 8px; font-size: 13px;
}

.mv-transport { display: flex; align-items: center; gap: 12px; margin: 6px 0 2px; }
.mv-play {
  width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--primary); color: #0b0b0e;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.mv-time { font-variant-numeric: tabular-nums; font-size: 13px; color: #ddd; }
.mv-result { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.mv-result b { color: var(--primary); }

/* Таймлайн */
.tl { margin: 6px 0 12px; }
.tl-track {
  position: relative; height: 56px; background: #1b1b24; border-radius: 10px;
  touch-action: none; user-select: none; margin: 0; width: 100%;
}
.tl-sel { position: absolute; top: 0; bottom: 0; border-top: 3px solid var(--primary); border-bottom: 3px solid var(--primary); background: rgba(83,252,24,0.10); pointer-events: none; }
.tl-dim { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,0.55); pointer-events: none; }
.tl-dim.l { left: 0; border-radius: 10px 0 0 10px; }
.tl-dim.r { right: 0; border-radius: 0 10px 10px 0; }
.tl-handle {
  position: absolute; top: -4px; bottom: -4px; width: 22px; margin-left: -11px;
  background: var(--primary); border-radius: 7px; cursor: ew-resize; z-index: 3;
  display: flex; align-items: center; justify-content: center;
}
.tl-handle::after { content: ""; width: 3px; height: 20px; background: #0b0b0e; border-radius: 2px; }
.tl-handle::before { content: ""; position: absolute; inset: -10px -8px; } /* увеличенная зона касания */
.tl-playhead { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; z-index: 4; box-shadow: 0 0 6px rgba(255,255,255,.6); }
.tl-subs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 10px; }
.tl-subs i { position: absolute; top: 40%; height: 20%; background: rgba(144,202,249,0.55); border-radius: 2px; min-width: 2px; }
.tl-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 8px; }

.subs-banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 13px; line-height: 1.4;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.subs-banner.none { background: rgba(255,235,59,0.1); border: 1px solid rgba(255,235,59,0.35); color: #ffe98a; }
.subs-banner.processing { background: rgba(13,71,161,0.2); border: 1px solid rgba(144,202,249,0.4); color: #bcdcfb; }
.subs-banner.done { background: rgba(27,94,32,0.2); border: 1px solid rgba(165,214,167,0.35); color: #b9e0bb; }
.subs-banner.failed { background: rgba(211,47,47,0.16); border: 1px solid rgba(255,138,128,0.4); color: #ffb3ab; }
.subs-banner .action-btn, .subs-banner .secondary-btn { padding: 8px 12px; font-size: 12px; white-space: nowrap; }
.spinner { display:inline-block; width:14px; height:14px; border:2px solid rgba(144,202,249,.35); border-top-color:#90caf9; border-radius:50%; animation: spin .8s linear infinite; vertical-align:-2px; margin-right:6px; }

.mv-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.mv-tabs::-webkit-scrollbar { display: none; }
.mv-tab {
  flex: 0 0 auto; background: #1b1b24; color: var(--text-muted); border: 1px solid var(--border-color);
  padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.mv-tab.active { background: var(--primary); color: #0b0b0e; border-color: var(--primary); }
.mv-panel { display: none; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 14px; padding: 14px; }
.mv-panel.active { display: block; }
.panel-hint { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin: 0 0 12px; }
.btn-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.btn-row .secondary-btn { flex: 1; padding: 10px 8px; font-size: 13px; }
.shift-row span { font-size: 12px; color: var(--text-muted); flex: 0 0 auto; }
.shift-row .secondary-btn { flex: 1; }
.num-row { display: flex; gap: 10px; margin-bottom: 8px; }
.num-row label { flex: 1; font-size: 11px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }
.num-row input, .sub-row input[type="number"], .sub-row input[type="text"] {
  width: 100%; box-sizing: border-box; padding: 9px; background: #111116; border: 1px solid var(--border-color);
  color: #fff; border-radius: 8px; font-size: 14px; user-select: text;
}
.link-btn { background: none; border: none; color: var(--text-muted); text-decoration: underline; font-size: 12px; cursor: pointer; padding: 6px 0; }
.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); }
.slider-row span { width: 96px; flex-shrink: 0; }
.slider-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--primary); }
.slider-row b { width: 48px; text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip-btn { background: #1b1b24; color: #fff; border: 1px solid var(--border-color); padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip-btn.active { background: var(--primary); color: #0b0b0e; border-color: var(--primary); }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 14px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary); }

.sub-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.sub-row { background: #111116; border: 1px solid var(--border-color); border-radius: 10px; padding: 8px; }
.sub-row.active { border-color: var(--primary); box-shadow: 0 0 0 1px rgba(83,252,24,0.4); }
.sub-row.out { opacity: 0.45; }
.sub-row-top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.sub-row-top input[type="text"] { flex: 1; font-weight: 600; text-transform: uppercase; }
.sub-del { background: rgba(211,47,47,0.18); color: #ff8a80; border: none; border-radius: 8px; width: 38px; height: 38px; font-size: 16px; cursor: pointer; flex-shrink: 0; }
.sub-times { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--text-muted); }
.sub-times label { flex: 1; display: flex; align-items: center; gap: 6px; }
.sub-times input { padding: 7px; font-size: 13px; }

.list-sub { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 10px 2px 0; text-transform: uppercase; letter-spacing: 0.5px; }


/* ═════════════ v3.1 ═════════════ */
/* Нижнее меню: кнопки делят ширину поровну и не вылезают за край */
html, body { overflow-x: hidden; max-width: 100%; }
.nav-bar { padding: 8px 6px; left: 12px; right: 12px; gap: 2px; justify-content: space-between; }
.nav-btn { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: 10.5px; }
.nav-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-btn svg { flex-shrink: 0; }
@media (min-width: 420px) { .nav-bar { padding: 10px 12px; left: 16px; right: 16px; } .nav-btn { font-size: 11px; } }

/* Нарезка: фрагменты на таймлайне */
.tl-segs { position: absolute; inset: 0; pointer-events: none; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: rgba(83,252,24,0.16); border-top: 3px solid rgba(83,252,24,0.55); border-bottom: 3px solid rgba(83,252,24,0.55); box-sizing: border-box; border-right: 2px solid #0f0f12; }
.tl-seg.sel { background: rgba(83,252,24,0.30); border-color: var(--primary); }
.seg-info { font-size: 12px; color: var(--text-muted); margin: 2px 0 10px; }
.btn-row .action-btn, .btn-row .cancel-btn { flex: 1; padding: 10px 8px; font-size: 13px; }

/* Рамка кадрирования (как в CapCut) */
.crop-ui { position: absolute; inset: 0; display: none; touch-action: none; }
.crop-box {
  position: absolute; border: 2px solid #fff; box-sizing: border-box;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6); cursor: move; touch-action: none;
  background-image:
    linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255,255,255,.55) calc(33.33% - 0.5px), rgba(255,255,255,.55) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255,255,255,.55) calc(66.66% - 0.5px), rgba(255,255,255,.55) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255,255,255,.55) calc(33.33% - 0.5px), rgba(255,255,255,.55) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255,255,255,.55) calc(66.66% - 0.5px), rgba(255,255,255,.55) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
}
.ch { position: absolute; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.6); touch-action: none; }
.ch::before { content: ""; position: absolute; inset: -14px; } /* большая зона касания */
.ch.nw, .ch.ne, .ch.se, .ch.sw { width: 18px; height: 18px; border-radius: 50%; margin: -9px 0 0 -9px; }
.ch.nw { left: 0; top: 0; cursor: nwse-resize; } .ch.ne { left: 100%; top: 0; cursor: nesw-resize; }
.ch.se { left: 100%; top: 100%; cursor: nwse-resize; } .ch.sw { left: 0; top: 100%; cursor: nesw-resize; }
.ch.n, .ch.s { width: 30px; height: 8px; border-radius: 4px; margin-left: -15px; left: 50%; }
.ch.n { top: -4px; cursor: ns-resize; } .ch.s { top: calc(100% - 4px); cursor: ns-resize; }
.ch.e, .ch.w { width: 8px; height: 30px; border-radius: 4px; margin-top: -15px; top: 50%; }
.ch.w { left: -4px; cursor: ew-resize; } .ch.e { left: calc(100% - 4px); cursor: ew-resize; }
.mv-stage.crop-mode { touch-action: none; }
.mv-stage.crop-mode .mv-sub-overlay { display: none; }

.mv-stage.crop-mode .crop-ui { inset: 14px; }

/* Предпросмотр остаётся на экране при прокрутке панелей инструментов */
.mv-pin { position: sticky; top: 0; z-index: 6; background: var(--bg-color); padding: 6px 0 2px; box-shadow: 0 8px 12px -8px rgba(0,0,0,.8); }
@media (hover: hover) and (pointer: fine) { .mv-pin { position: relative; top: auto; } }
.mv-stage-wrap { padding: 0 0 2px; }
.mv-stage video { object-fit: fill; } /* растягиваем точно по заданным размерам (иначе — чёрные полосы) */

/* Более тонкие ручки: меньше шанс промахнуться и зацепить не то */
.tl-handle { width: 10px; margin-left: -5px; top: -3px; bottom: -3px; border-radius: 5px; }
.tl-handle::after { width: 2px; height: 16px; }
.tl-handle::before { inset: 0 -6px; }
.ch.nw, .ch.ne, .ch.se, .ch.sw { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.ch.n, .ch.s { width: 24px; height: 6px; margin-left: -12px; border-radius: 3px; }
.ch.n { top: -3px; } .ch.s { top: calc(100% - 3px); }
.ch.e, .ch.w { width: 6px; height: 24px; margin-top: -12px; border-radius: 3px; }
.ch.w { left: -3px; } .ch.e { left: calc(100% - 3px); }
.ch::before { inset: -8px; }


/* Компактная карточка нарезки: сверху название и статус, под ними кнопки в ряд */
.cut-card { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
.cut-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cut-title { min-width: 0; flex: 1; font-size: 15px; word-break: break-word; }
.cut-top .badge { flex-shrink: 0; padding: 4px 8px; font-size: 10px; }
.cut-actions { display: flex; flex-direction: row; gap: 8px; }
.cut-actions button { flex: 1; width: auto; padding: 8px 6px; font-size: 13px; }

/* Уведомления внутри приложения */
.toast-box { position: fixed; left: 12px; right: 12px; top: max(10px, env(safe-area-inset-top, 10px)); z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: center; }
.toast { pointer-events: auto; max-width: 440px; width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; background: rgba(28,28,36,0.97); border: 1px solid var(--border-color); box-shadow: 0 8px 28px rgba(0,0,0,.5); font-size: 13px; line-height: 1.35; opacity: 0; transform: translateY(-12px); transition: opacity .2s ease, transform .2s ease; cursor: pointer; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ic { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: #2b2b36; }
.toast.ok { border-color: rgba(83,252,24,.45); } .toast.ok .toast-ic { background: var(--primary); color: #0b0b0e; }
.toast.error { border-color: rgba(255,138,128,.5); } .toast.error .toast-ic { background: #d32f2f; color: #fff; }
.toast.warn { border-color: rgba(255,235,59,.45); } .toast.warn .toast-ic { background: #ffeb3b; color: #0b0b0e; }
.toast-msg { flex: 1; min-width: 0; }
.toast-act { flex-shrink: 0; background: var(--primary); color: #0b0b0e; border: none; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 12px; cursor: pointer; }

/* Таймлайн с масштабом */
.tl-scroll { overflow-x: auto; overflow-y: hidden; padding: 9px 10px; margin: 0 -2px; scrollbar-width: thin; }
.tl-tools { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 2px 0 4px; font-size: 12px; color: var(--text-muted); }
.tl-tools .secondary-btn { padding: 6px 12px; font-size: 13px; }
.tl-tools #tl-zoom-seg { flex: 1; max-width: 220px; font-size: 12px; }
#tl-zoom-val { min-width: 36px; text-align: center; }

/* Список фрагментов */
.seg-list { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto; margin-bottom: 12px; }
.seg-row { display: flex; align-items: center; gap: 10px; background: #111116; border: 1px solid var(--border-color); border-radius: 10px; padding: 6px 6px 6px 10px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.seg-row.sel { border-color: var(--primary); background: rgba(83,252,24,0.08); }
.seg-row.tiny .seg-l { color: #ffeb3b; }
.seg-n { width: 20px; height: 20px; border-radius: 50%; background: #2b2b36; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }
.seg-row.sel .seg-n { background: var(--primary); color: #0b0b0e; font-weight: 700; }
.seg-t { flex: 1; min-width: 0; }
.seg-l { color: var(--text-muted); }
.seg-del { background: rgba(211,47,47,0.18); color: #ff8a80; border: none; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; flex-shrink: 0; }
.seg-del:disabled { opacity: 0.3; cursor: default; }
.hotkeys-hint { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin: 10px 0 0; }
@media (hover: none) { .hotkeys-hint { display: none; } }

/* Компактная закреплённая зона редактора — больше места под инструменты */
.mv-pin { padding: 4px 0 0; }
.mv-stage-wrap { padding: 0; }
.mv-transport { margin: 4px 0 0; gap: 10px; }
.mv-play { width: 34px; height: 34px; }
.mv-play svg { width: 16px; height: 16px; }
.mv-time { font-size: 12px; }
.mv-result { font-size: 11px; }
.tl { margin: 2px 0 4px; }
.tl-track { height: 38px; }
.tl-scroll { padding: 7px 10px; }
.tl-handle::after { height: 12px; }
.tl-tools { margin: 0 0 4px; gap: 6px; }
.tl-tools .secondary-btn { padding: 4px 10px; font-size: 12px; }
.tl-hint { display: none; }
.mv-tplrow { margin: 6px 0 2px; }
.mv-header { padding-top: max(6px, env(safe-area-inset-top, 6px)); padding-bottom: 6px; }

/* Кнопки отмены/возврата: квадратные, одной высоты с соседними */
.btn-row .action-btn, .btn-row .cancel-btn, .btn-row .secondary-btn { height: 42px; box-sizing: border-box; }
.btn-row .sq-btn { flex: 0 0 42px; width: 42px; padding: 0; display: flex; align-items: center; justify-content: center; }
.sq-btn .ic { width: 22px; height: 22px; }
.sq-btn.flip .ic { transform: scaleX(-1); }

/* Кнопки под таймлайном чуть крупнее */
.tl-tools { gap: 8px; margin: 2px 0 6px; }
.tl-tools .secondary-btn { height: 38px; padding: 0 14px; font-size: 14px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.tl-tools #tl-zoom-out, .tl-tools #tl-zoom-in { flex: 0 0 42px; width: 42px; padding: 0; font-size: 18px; }
.tl-tools #tl-zoom-seg { font-size: 13px; max-width: 240px; }
#tl-zoom-val { font-size: 13px; }

/* ═════════ v3.2: новый флоу и больше воздуха ═════════ */
.tab-content { padding: 22px 18px; }
.header-row { margin-bottom: 18px; }
.page-hint { padding: 10px 14px; font-size: 12.5px; margin-bottom: 18px; }
.items-list { gap: 14px; }

/* Главная: приветствие + кнопка */
.hero {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
  padding: 28px 20px 24px; margin-bottom: 24px;
  background: linear-gradient(160deg, rgba(83,252,24,0.14), rgba(83,252,24,0.03) 60%);
  border: 1px solid rgba(83,252,24,0.3); border-radius: 22px;
}
.hero-ico {
  width: 64px; height: 64px; border-radius: 20px; display: flex; align-items: center; justify-content: center;
  background: rgba(83,252,24,0.14); color: var(--primary); border: 1px solid rgba(83,252,24,0.35);
}
.hero-title { font-size: 19px; font-weight: 700; line-height: 1.25; max-width: 260px; }
.hero-btn { width: 100%; max-width: 280px; padding: 15px; font-size: 16px; border-radius: 14px; }

/* Моменты: крупная кнопка загрузки и секции */
.upload-big {
  display: flex; align-items: center; gap: 14px; cursor: pointer; margin-bottom: 18px;
  padding: 16px; border-radius: 18px; border: 1.5px dashed rgba(83,252,24,0.55);
  background: rgba(83,252,24,0.06);
}
.upload-big:active { opacity: .8; }
.upload-plus {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; background: var(--primary); color: #0b0b0e;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
}
.upload-plus svg { display:block; width:22px; height:22px; }
.upload-text { display: flex; flex-direction: column; gap: 3px; }
.upload-text b { font-size: 16px; }
.upload-text small { color: var(--text-muted); font-size: 12px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: 0.06em; margin: 30px 0 14px; }
.empty-hint { margin: 6px 0; }
.channel-btn { margin-bottom: 18px; }
.moment-card { padding: 16px; }
.moment-actions { margin-top: 14px; }

/* Выбор шаблона */
.tpl-pick-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.tpl-pick-head label { margin: 0; }
.tpl-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.tpl-strip::-webkit-scrollbar { display: none; }
.tpl-tile {
  flex: 0 0 74px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px 7px;
  background: #1b1b24; border: 1.5px solid var(--border-color); border-radius: 12px; color: #ddd;
  font-size: 11px; line-height: 1.2; cursor: pointer; text-align: center;
}
.tpl-tile span { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-tile.sel { border-color: var(--primary); background: rgba(83,252,24,0.1); color: #fff; }
.tpl-mini { position: relative; width: 38px; aspect-ratio: 9 / 16; background: #0b0b0e; border-radius: 5px; overflow: hidden; border: 1px solid #2b2b36; flex-shrink: 0; }
.tpl-mini i { position: absolute; box-sizing: border-box; border-radius: 2px; }
.tpl-more { justify-content: center; color: var(--primary); }
.tpl-more-ico { font-size: 26px; line-height: 38px; height: 68px; display: flex; align-items: center; }
/* Окно «Все шаблоны» */
.tpl-all-card {
  display: flex; flex-direction: column; max-height: 82vh; overflow: hidden;
  padding: 18px 16px 16px; box-sizing: border-box;
}
.tpl-all-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-shrink: 0; }
.tpl-all-card .tpl-all-head h3 { margin: 0; font-size: 18px; }
.tpl-all-x {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-color);
  background: #1b1b24; color: #aaa; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0;
}
.tpl-all-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 2px 2px 4px; margin: 0 -2px;
  scrollbar-width: thin; scrollbar-color: #33333f transparent;
  overscroll-behavior: contain;
}
.tpl-all-grid::-webkit-scrollbar { width: 4px; }
.tpl-all-grid::-webkit-scrollbar-thumb { background: #33333f; border-radius: 4px; }
.tpl-all-grid .tpl-tile {
  position: relative; flex: none; min-width: 0; width: 100%; box-sizing: border-box;
  padding: 10px 6px 9px; gap: 8px; border-radius: 14px;
  transition: border-color .15s, background .15s, transform .1s;
}
.tpl-all-grid .tpl-tile:active { transform: scale(0.97); }
.tpl-all-grid .tpl-mini { width: 100%; max-width: 54px; border-radius: 6px; }
.tpl-all-grid .tpl-tile span {
  white-space: normal; overflow: hidden; text-overflow: clip;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  font-size: 11px; line-height: 1.25; min-height: 2.5em; word-break: break-word;
}
.tpl-all-grid .tpl-tile.sel::after {
  content: '✓'; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #0f0f12; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.tpl-all-foot { flex-shrink: 0; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border-color); }
.tpl-all-foot .cancel-btn { width: 100%; }
.modal-card h3 { margin: 0 0 4px; letter-spacing: 0.03em; }
.modal-card label { display: block; margin: 14px 0 6px; }

/* Редактор: больше воздуха */
.mv-body { padding: 0 16px; }
.mv-pin { padding: 8px 0 6px; }
.mv-transport { margin: 10px 0 4px; gap: 12px; }
.mv-play { width: 38px; height: 38px; }
.tl { margin: 6px 0 8px; }
.tl-tools { margin: 4px 0 8px; gap: 10px; }
.mv-tplrow { margin: 12px 0 8px; }
.subs-banner { padding: 8px 12px; margin: 10px 0 14px; font-size: 12px; border-radius: 10px; gap: 8px; }
.subs-banner .action-btn, .subs-banner .secondary-btn { padding: 6px 12px; font-size: 12px; height: 32px; }
.mv-tabs { gap: 8px; margin-bottom: 14px; padding-bottom: 4px; }
.mv-tab { padding: 10px 14px; }
.mv-panel { padding: 18px 16px; border-radius: 16px; }
.panel-hint { font-size: 12px; margin: 0 0 16px; }
.btn-row { gap: 10px; margin-bottom: 16px; }
.num-row { gap: 12px; margin-bottom: 14px; }
.seg-list { gap: 8px; margin-bottom: 16px; }
.seg-info { margin-bottom: 12px; }
.check-row { margin: 4px 0 14px; }
.slider-row { margin: 14px 0; }
.chips { gap: 8px; margin-bottom: 14px; }
.link-btn { margin-top: 6px; }
.mv-footer { padding-top: 12px; }
.modal-card .tpl-pick-head label { margin: 0; }
.modal-card .tpl-pick-head { margin: 16px 0 8px; }
.hero-title { max-width: 300px; }
.tpl-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; overflow: visible; padding: 2px 0 8px; }
.tpl-strip .tpl-tile { flex: none; min-width: 0; padding: 8px 2px 7px; }
.tpl-strip .tpl-tile span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 10.5px; min-height: 2.4em; }
.tpl-strip .tpl-mini { width: 100%; max-width: 40px; }
.tpl-strip .tpl-more-ico { height: auto; line-height: 1; margin-top: 14px; flex: 1; }

/* Создание нарезки: крупный кадр и последовательные настройки */
#render-modal .render-card {
  width: min(100%, 480px); max-width: 480px; max-height: min(96dvh, 1000px);
  padding: 18px; border-radius: 22px; overscroll-behavior: contain;
}
.render-header { display:flex; align-items:center; gap:10px; margin-bottom:4px; }
#render-modal .render-header h3 { flex:1; margin:0; font-size:21px; letter-spacing:0; }
.render-header-btn { display:grid; place-items:center; width:30px; height:30px; flex-shrink:0; padding:0; border:0; background:transparent; color:#ddd; font-size:24px; cursor:pointer; }
#modal-moment-title { margin:0 0 12px 40px; font-size:12px; overflow-wrap:anywhere; }
#render-modal .render-preview-card { align-items:stretch; gap:8px; margin:0 0 20px; padding:10px; border:1px solid #2d2d38; border-radius:16px; background:#202029; }
.render-preview-stage { display:flex; align-items:center; justify-content:center; width:min(100%, 235px, 29vh); min-width:0; aspect-ratio:9 / 16; height:auto; align-self:center; overflow:hidden; border:1px solid #36363f; border-radius:12px; background:#08080b; box-shadow:0 8px 24px rgba(0,0,0,.28); }
#render-modal .live-preview { width:100%; height:100%; aspect-ratio:9 / 16; max-width:none; border:0; border-radius:0; box-shadow:none; }
.render-preview-caption { display:flex; align-items:center; justify-content:center; gap:7px; color:#e1e1e5; font-size:12px; font-weight:600; }
.render-preview-caption span { padding:2px 5px; border-radius:5px; background:#30303a; color:#a9a9b1; font-size:10px; }
.render-time-row { display:flex; justify-content:space-between; color:#a9a9b1; font-size:12px; font-variant-numeric:tabular-nums; }
#render-modal .render-preview-card .preview-scrub { width:100%; max-width:none; height:20px; padding:0; margin:0; background:transparent; border:0; accent-color:var(--primary); }
#render-preview-status { min-height:16px; text-align:left; line-height:1.3; color:#aaaab3; }
#render-preview-update { align-self:stretch; min-height:40px; padding:9px 11px; }
.render-field-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
#render-modal .render-field-heading label, #render-modal .tpl-pick-head label { margin:0; color:#f4f4f5; font-size:16px; font-weight:700; }
#render-title-count { font-size:12px; color:#93939d; }
#render-modal #render-title-input { margin:10px 0 0; padding:13px; font-size:14px; background:#202029; }
#render-modal .tpl-pick-head { margin:20px 0 10px; }
#render-modal .tpl-strip { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; padding:0; }
#render-modal .tpl-strip .tpl-tile { min-height:132px; padding:10px 5px; justify-content:center; gap:8px; }
#render-modal .tpl-strip .tpl-mini { width:auto; height:78px; max-width:100%; }
#render-modal .tpl-strip .tpl-tile span { font-size:11px; min-height:2.4em; }
#render-modal .render-all-templates { padding:4px 0; margin:8px 0 0; color:#aaaab3; text-align:left; }
#render-modal .render-actions { margin-top:16px; }
#render-modal #start-render-btn { width:100%; min-height:50px; font-size:16px; border-radius:12px; }
@media (max-height: 650px) { #render-modal .render-card { padding:14px; } .render-preview-stage { width:min(100%, 180px); height:auto; } }

/* Общие мобильные состояния и доступные элементы управления. */
button:focus-visible, input:focus-visible, select:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
button:disabled { cursor:not-allowed; opacity:.5; }
.editor-toolbar { justify-content:flex-start; gap:8px; overflow-x:auto; overscroll-behavior-x:contain; scrollbar-width:thin; }
.editor-toolbar .tool-btn { flex:0 0 auto; min-height:40px; white-space:nowrap; }
.template-preview-picker, .template-preview-options { max-width:100%; }
.mv-tabs, .tl-tools { overscroll-behavior-x:contain; }
.admin-user > span, .admin-item > span { min-width:0; overflow-wrap:anywhere; }
@media (max-width:370px) {
  .tab-content { padding-left:14px; padding-right:14px; }
  .nav-btn { min-width:0; padding-left:5px; padding-right:5px; }
  .editor-header { padding-left:8px; padding-right:8px; }
  .editor-header .action-btn, .editor-header .cancel-btn { padding-left:10px; padding-right:10px; }
  .template-preview-picker label { display:none; }
}
@media (max-height:700px) { .mv-pin { position:relative; top:auto; } }


/* ═════════════ Горячие клавиши (ПК) ═════════════ */
/* Кнопки шапки редактора: «Назад» и «Горячие клавиши» — одинаковые квадраты с белой иконкой */
.mv-icon-btn { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.mv-icon-btn svg { display: block; }
#hk-tip {
  position: fixed; z-index: 1000; display: none; pointer-events: none;
  background: #1f1f29; color: #fff; border: 1px solid var(--border-color); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; line-height: 1.5; max-width: 300px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
#hk-tip kbd, .hk-card kbd {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 5px; text-align: center;
  border: 1px solid #555; border-bottom-width: 2px; background: #2b2b36; color: var(--primary);
  font: 600 11px/1.6 ui-monospace, Menlo, Consolas, monospace;
}
#hk-tip kbd + i, .hk-card kbd + i, .hk-card i + kbd { margin: 0 2px; }
#hk-tip i, .hk-card i { font-style: normal; color: var(--text-muted); font-size: 11px; }
.hk-or { color: var(--text-muted); }
.hk-card { max-width: 480px; max-height: 82vh; overflow-y: auto; }
.hk-group h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.hk-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.hk-keys { flex-shrink: 0; white-space: nowrap; }


/* ═════════════ v3.5: шапка экранов и карточки с превью ═════════════ */
.ic-s { width: 18px; height: 18px; flex-shrink: 0; display: block; }

/* Шапка: логотип + действие справа, крупный заголовок и подзаголовок */
.screen-head { margin-bottom: 20px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; flex-shrink: 0; border-radius: 11px; background: var(--primary); color: #0b0b0e; display: flex; align-items: center; justify-content: center; }
.brand-logo svg { width: 23px; height: 23px; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: 0.04em; }
.screen-title { font-size: 32px; font-weight: 800; letter-spacing: 0.04em; line-height: 1.1; margin: 0 0 6px; }
.screen-sub { margin: 0; color: var(--text-muted); font-size: 15px; line-height: 1.35; }
.pill-create { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 18px; border-radius: 999px; font-size: 15px; font-weight: 700; }
.pill-create svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Карточка списка: превью слева, справа название, статус и кнопки */
.pcard { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px; box-sizing: border-box; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 20px; }
.pcard.stack { flex-direction: column; align-items: stretch; gap: 12px; }
.pcard-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.pcard-thumb { position: relative; width: 92px; height: 92px; flex-shrink: 0; border-radius: 16px; overflow: hidden; background: #0d0d11; border: 1px solid var(--border-color); cursor: pointer; }
.pcard-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.2); }
.pcard-ph .ic-s { width: 34px; height: 34px; }
.pcard-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pcard-dur { position: absolute; right: 6px; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 8px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.45; }
.pcard-dur.left { right: auto; left: 6px; }
.pcard-dur .ic-s { width: 10px; height: 10px; }
.pcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pcard-title { max-width: 100%; font-size: 17px; font-weight: 700; line-height: 1.2; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard.has-del .pcard-title { padding-right: 26px; }

/* Статус-чипы */
.pchip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 700; line-height: 1.3; border: 1px solid transparent; }
.pchip .ic-s { width: 14px; height: 14px; }
.pchip.done { color: var(--primary); background: rgba(83, 252, 24, 0.1); border-color: rgba(83, 252, 24, 0.38); }
.pchip.none, .pchip.queued { color: #ffd84a; background: rgba(255, 216, 74, 0.12); border-color: rgba(255, 216, 74, 0.22); }
.pchip.processing { color: #8fc2ff; background: rgba(79, 152, 255, 0.14); border-color: rgba(79, 152, 255, 0.3); animation: pulse 1.4s ease-in-out infinite; }
.pchip.failed { color: #ff8a80; background: rgba(255, 82, 82, 0.13); border-color: rgba(255, 82, 82, 0.3); }
.pchip.soft { color: #c9c9d1; background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); font-variant-numeric: tabular-nums; }

/* Кнопки в карточках */
.pcard-actions { display: flex; align-self: stretch; gap: 8px; }
.pbtn { flex: 1; min-width: 0; height: 38px; padding: 0 10px; box-sizing: border-box; border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.pbtn:active { opacity: 0.8; transform: scale(0.97); }
.pbtn:disabled { opacity: 0.5; cursor: default; }
.pbtn.primary { background: var(--primary); color: #0b0b0e; }
.pbtn.ghost { background: #1d1d26; color: #fff; border-color: rgba(255, 255, 255, 0.12); }
.pbtn.icon { flex: 0 0 44px; padding: 0; }
.pcard-del { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; padding: 0; border: none; border-radius: 10px; background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.pcard-del:active { background: rgba(255, 255, 255, 0.08); color: #fff; }
.pcard-del:disabled { opacity: 0.35; cursor: default; }

/* Шаблоны */
.pcard-thumb.tpl { width: 76px; height: 76px; cursor: default; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, rgba(83, 252, 24, 0.16), rgba(83, 252, 24, 0.02) 70%), #0d0d11; }
.pcard-thumb.tpl .tpl-mini { width: auto; height: calc(100% - 14px); aspect-ratio: 9 / 16; }
.pcopy { flex: 0 0 auto; width: 64px; padding: 9px 4px; box-sizing: border-box; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.14); background: #1d1d26; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 5px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; }
.pcopy:active { opacity: 0.8; }
.pcopy .ic-s { width: 18px; height: 20px; }
.pcard-side { display: flex; gap: 8px; flex-shrink: 0; }
.tplcard .pcard-title { font-size: 16px; }

/* Профиль */
.profile-card { align-items: center; margin-bottom: 12px; }
.profile-avatar {
  width: 84px; height: 84px; flex-shrink: 0; border-radius: 20px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(83, 252, 24, 0.18), rgba(83, 252, 24, 0.02) 70%), #0d0d11;
  border: 1px solid rgba(83, 252, 24, 0.25);
  font-size: 34px; line-height: 1;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-card .pcard-main { gap: 6px; }
.profile-name { font-size: 20px; font-weight: 800; line-height: 1.15; letter-spacing: 0.02em; word-break: break-word; }
.profile-username { font-size: 13.5px; color: var(--text-muted); }
.profile-pref { align-items: center; gap: 12px; }
.profile-pref .pcard-main { gap: 4px; }
.profile-pref-title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.profile-hint { font-size: 12.5px; line-height: 1.35; color: var(--text-muted); }
.profile-pref .switch { flex-shrink: 0; }
.profile-page-hint { margin: 18px 0 0; }
.promo-profile { display:grid; gap:8px; margin-top:12px; }
.promo-profile label { font-weight:700; }
.promo-profile-row { display:flex; gap:8px; }
.promo-profile-row input { flex:1; min-width:0; border:1px solid var(--border-color); border-radius:8px; background:#111116; color:inherit; padding:8px; font-size:16px; }
.element[data-type="promo_banner"] { padding:0; touch-action:none; }
.element[data-type="promo_banner"] img { display:block; width:100%; height:100%; pointer-events:none; }
.admin-body { flex:1; min-height:0; overflow-y:auto; padding:16px; }
.admin-stats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-bottom:16px; }
.admin-stat, .admin-user, .admin-detail-card { background:var(--card-bg); border:1px solid var(--border-color); border-radius:12px; padding:12px; margin-bottom:8px; }
.admin-stat b { display:block; color:var(--primary); font-size:21px; }
.admin-search { display:flex; gap:8px; margin-bottom:12px; }
.admin-search input { flex:1; min-width:0; padding:10px; background:#1b1b24; color:white; border:1px solid var(--border-color); border-radius:8px; }
.admin-user { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.admin-detail-card h3 { margin:0 0 12px; }
.admin-actions { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0; }
.admin-item { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:8px 0; border-bottom:1px solid #30303a; }
.admin-item span { overflow-wrap:anywhere; }
.admin-video { width:100%; max-height:55vh; background:#000; }

/* Узкие экраны (≤370px): чуть компактнее, чтобы подписи кнопок не обрезались */
@media (max-width: 370px) {
  .pcard { gap: 10px; padding: 10px; }
  .pcard-row { gap: 10px; }
  .pcard-thumb { width: 78px; height: 78px; border-radius: 14px; }
  .pcard-thumb.tpl { width: 68px; height: 68px; }
  .pcard-title { font-size: 15.5px; }
  .pbtn { height: 38px; padding: 0 6px; gap: 5px; font-size: 11.5px; }
  .pbtn .ic-s { width: 16px; height: 16px; }
  .pbtn.icon { flex-basis: 40px; }
  .pcopy { width: 56px; }
  .screen-title { font-size: 28px; }
  .profile-avatar { width: 72px; height: 72px; border-radius: 18px; font-size: 28px; }
  .profile-name { font-size: 18px; }
}
