@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --card: #141a2b;
  --card-border: rgba(255, 255, 255, 0.06);
  --accent: #2f6fed;
  --accent-glow: rgba(47, 111, 237, 0.35);
  --accent-2: #4f8cff;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --danger: #f0426a;
  --danger-bg: rgba(240, 66, 106, 0.12);
  --warning: #e0a100;
  --warning-bg: rgba(224, 161, 0, 0.12);
  --text: #f5f7fb;
  --hint: #8a92a6;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top, #131b2e 0%, #0a0e1a 60%);
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 92px;
}

.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 20px 16px;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px var(--accent-glow);
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-subtitle { font-size: 13px; color: var(--hint); font-weight: 500; }

.content { padding: 4px 20px 20px; flex: 1; }

.tab-screen { display: none; animation: fadeIn 0.25s ease; }
.tab-screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-card { text-align: center; padding: 28px 0 8px; }
.stat-label {
  font-size: 13px; color: var(--hint); margin-bottom: 8px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.stat-value {
  font-size: 48px; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #b8c2d9 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-card-wide {
  text-align: left; padding: 18px 20px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(47, 111, 237, 0.12) 0%, rgba(124, 92, 255, 0.12) 100%);
  border: 1px solid rgba(79, 140, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.08), 0 8px 30px rgba(47, 111, 237, 0.15);
}
.stat-card-row { display: flex; align-items: center; gap: 24px; }
.stat-card-wide .stat-label { margin-bottom: 4px; }
.stat-card-wide .stat-value { font-size: 30px; }
.stat-card-row .info-icon-btn { margin-left: auto; width: 26px; height: 26px; }
.stat-card-row .info-icon-btn svg { width: 16px; height: 16px; }

.segmented-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 16px;
  background: none; border: none; -ms-overflow-style: none; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth; touch-action: pan-x;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 22px), transparent 100%);
}
.segmented-scroll::-webkit-scrollbar { display: none; }
.segmented-scroll .segment {
  flex-shrink: 0; border-radius: 999px; padding: 8px 15px; font-size: 12.5px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--hint); font-weight: 600; white-space: nowrap; transition: all 0.15s ease;
}
.segmented-scroll .segment.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.segmented-scroll .segment.add-folder { border-style: dashed; color: var(--accent-2); }

/* --- Хрестик видалення категорії: :hover на десктопі, .show-delete (довге
   натискання) на тач-пристроях. "Всі" і "+ Додати категорію" такого не мають —
   хрестик додається лише для реальних, видалюваних папок. --- */
.segment-wrap { position: relative; flex-shrink: 0; display: inline-flex; }
.segment-delete-x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 2px solid var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  opacity: 0; transform: scale(0.6); pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease; z-index: 2;
}
.segment-delete-x svg { width: 11px; height: 11px; }
.segment-wrap:hover .segment-delete-x,
.segment-wrap.show-delete .segment-delete-x {
  opacity: 1; transform: scale(1); pointer-events: auto;
}

.folder-accordion { margin-top: 0; }
.channel-group-label {
  padding: 22px 16px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--hint);
}
.channel-group-label:first-child { padding-top: 6px; }
.channel-subs-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.62); margin-top: 3px; }
.channel-subs-meta svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.75; }

.queue-time-row {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12px; font-weight: 600; color: var(--hint);
}
.pin-indicator { display: inline-flex; color: var(--accent-2); margin-left: 2px; }
.pin-indicator svg { width: 13px; height: 13px; }

.hint-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(47, 111, 237, 0.14) 0%, rgba(124, 92, 255, 0.14) 100%);
  border: 1px solid rgba(47, 111, 237, 0.25);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 20px;
  color: #c7d2f5;
}
.hint-banner .icon { flex-shrink: 0; margin-top: 1px; color: var(--accent-2); }

.section-label {
  font-size: 12.5px; color: var(--hint); margin: 24px 0 10px;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
}

.card-list {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.card-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 16px; border-bottom: 1px solid var(--card-border);
  font-size: 14.5px; font-weight: 500;
}
.card-row:last-child { border-bottom: none; }

.channel-card, .source-card {
  padding: 20px 18px; border-bottom: 1px solid var(--card-border);
  transition: background 0.15s ease; overflow: hidden;
}
.channel-card:active, .source-card:active { background: rgba(255, 255, 255, 0.02); }
.channel-card:last-child, .source-card:last-child { border-bottom: none; }
.swipe-wrap:last-child .channel-card { border-bottom: none; }

.channel-title, .source-title {
  font-size: 16px; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.channel-avatar {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; aspect-ratio: 1 / 1;
  border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; overflow: hidden;
}
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; border-radius: 50%; }

.badge-inactive {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--danger); font-size: 11.5px; font-weight: 700;
  background: var(--danger-bg); padding: 3px 8px; border-radius: 999px;
}

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.role-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap; line-height: 1.4;
}
.role-badge.editor { color: var(--accent-2); background: rgba(79, 140, 255, 0.12); }
.role-badge.moderator { color: var(--warning); background: var(--warning-bg); }

.modal-divider {
  border-top: 1px solid var(--card-border);
  margin: 20px 0 4px;
}

.danger-zone {
  margin-top: 22px;
  padding: 14px;
  background: rgba(240, 66, 106, 0.08);
  border: 1px solid rgba(240, 66, 106, 0.3);
  border-radius: var(--radius-lg);
}
.danger-zone .section-label { color: var(--danger); margin-top: 0; }

.file-upload-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--card-border);
  color: var(--text); font-size: 13px; font-weight: 600; text-align: center;
}
.file-upload-btn:active { background: rgba(255, 255, 255, 0.1); }

.pill {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  transition: transform 0.15s ease, background 0.2s ease;
  font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
}
.pill:active { transform: scale(0.96); }
.pill.on { background: var(--success-bg); color: var(--success); border-color: rgba(34, 197, 94, 0.25); }
.pill.off { background: rgba(255, 255, 255, 0.05); color: var(--hint); }
.pill.danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(240, 66, 106, 0.25); }

.keywords-row { display: flex; gap: 6px; margin-top: 10px; }

input[type="text"] {
  width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  padding: 12px 14px; font-size: 14px; background: rgba(255, 255, 255, 0.04);
  color: var(--text); margin-bottom: 10px; font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); background: rgba(47, 111, 237, 0.06); }
input[type="text"]::placeholder { color: var(--hint); }

.schedule-datetime-row { margin: 0 0 14px; }
.schedule-datetime-input {
  width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  padding: 12px 14px; font-size: 14px; background: rgba(255, 255, 255, 0.04);
  color: var(--text); font-family: inherit; color-scheme: dark;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.schedule-datetime-input:focus { outline: none; border-color: var(--accent); background: rgba(47, 111, 237, 0.06); }

.primary-btn {
  width: 100%; padding: 15px; border: none; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 24px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.primary-btn:active { transform: scale(0.98); box-shadow: 0 4px 14px var(--accent-glow); }
.primary-btn-glow {
  background: #3B82F6;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}
.primary-btn-glow:active { box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35); }

.muted { color: var(--hint); font-size: 12.5px; margin-top: 8px; font-weight: 500; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: rgba(15, 19, 32, 0.85);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--card-border); padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  gap: 6px;
}

.nav-btn {
  flex: 1; background: none; border: none; color: var(--hint);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 8px 4px;
  border-radius: var(--radius-sm); transition: background 0.2s ease, color 0.2s ease;
  font-family: inherit;
}
.nav-btn.active { color: var(--accent-2); }

.segmented {
  display: flex; background: var(--card); border-radius: var(--radius-md);
  padding: 4px; gap: 4px; border: 1px solid var(--card-border);
}
.segment {
  flex: 1; background: none; border: none; color: var(--hint);
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 9px 4px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease;
}
.segment.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow); }

.submission-card { padding: 18px; border-bottom: 1px solid var(--card-border); }
.submission-card:last-child { border-bottom: none; }

.card-relative { position: relative; }

.status-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .2px;
}
.status-badge.draft { color: var(--hint); background: rgba(255, 255, 255, 0.08); }
.status-badge.pending { color: var(--warning); background: var(--warning-bg); }
.status-badge.approved { color: var(--success); background: var(--success-bg); }

.swipe-wrap { position: relative; }

.swipe-delete-bg {
  position: absolute; inset: 0; background: var(--danger); border-radius: var(--radius-md, 14px);
  display: flex; align-items: center; justify-content: flex-end; padding-right: 24px;
  color: #fff; opacity: 0;
}

.swipe-content {
  position: relative; background: var(--card);
  transition: transform .25s ease;
  touch-action: pan-y;
  user-select: none;
}
.swipe-content.swiping { transition: none; }
.swipe-content.category-dragging {
  transition: none; position: relative; z-index: 50;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35); border-radius: var(--radius-md, 14px);
}

#channels-folder-tabs.drop-armed {
  box-shadow: 0 0 0 2px var(--accent-2) inset;
  border-radius: var(--radius-md);
}
#channels-folder-tabs .segment.drop-target-active {
  background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow);
  transform: scale(1.06);
}

.submission-title-clip {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.avatar-stack { display: flex; align-items: center; margin: 5px 0 4px; }
.avatar-stack-item {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex; align-items: center; justify-content: center; color: #fff;
  margin-left: -8px; box-sizing: border-box; border: 2px solid var(--card);
}
.avatar-stack-item:first-child { margin-left: 0; }
.avatar-stack-item.delivered { border-color: #22C55E; }
.avatar-stack-item.error { border-color: #EF4444; }
.avatar-stack-item.pending { border-color: #EAB308; }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.card-actions .btn-primary, .card-actions .btn-secondary { min-width: 110px; }
.card-actions .btn-primary {
  flex: 1; border: none; border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.card-actions .btn-primary:active { transform: scale(0.98); }
.card-actions .btn-secondary {
  flex: 1; border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--hint); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.card-actions .btn-secondary:active { transform: scale(0.98); }

/* "Виставити терміново" — той самий вигляд, що й інші кнопки меню редагування
   («Редагувати» / «Опублікувати зараз»), без окремого виділення кольором
   (п.3.2 ТЗ: жодного яскравого/контрастного акценту, єдиний стиль). */
.btn-urgent {
  flex: 1; border-radius: 12px; padding: 10px 14px; font-size: 13.5px; font-weight: 600;
  color: var(--hint); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  font-family: inherit; min-width: 110px; transition: transform 0.15s ease;
}
.btn-urgent:active { transform: scale(0.98); }

.submission-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.submission-author { font-size: 13.5px; font-weight: 700; }
.submission-meta { font-size: 11.5px; color: var(--hint); }

.submission-body { font-size: 14px; line-height: 1.5; margin-bottom: 10px; white-space: pre-wrap; }
.submission-media { width: 100%; border-radius: var(--radius-sm); margin-bottom: 10px; display: block; max-height: 260px; object-fit: cover; }

.submission-edit-area {
  width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  padding: 12px 14px; font-size: 14px; background: rgba(255,255,255,0.04); color: var(--text);
  font-family: inherit; margin-bottom: 10px; resize: vertical; min-height: 80px;
}

/* Справжній WYSIWYG (contenteditable) для редактора поста — жирний/курсив/спойлер
   і т.д. видно одразу як реальне форматування, а не як сирі <b>/<i> теги. */
.rich-editor {
  line-height: 1.5; white-space: pre-wrap; word-break: break-word; outline: none; cursor: text;
}
.rich-editor:empty::before { content: attr(data-placeholder); color: var(--hint); pointer-events: none; }
.rich-editor tg-spoiler {
  background: rgba(255, 255, 255, 0.16); color: transparent; border-radius: 4px; cursor: pointer;
}
.rich-editor tg-spoiler:hover { background: rgba(255, 255, 255, 0.24); }

.submission-summary { display: flex; gap: 20px; align-items: center; cursor: pointer; }
.submission-thumb {
  width: 52px; height: 52px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: rgba(255,255,255,0.06); display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: var(--hint);
}
.submission-thumb img, .submission-thumb video { width: 100%; height: 100%; object-fit: cover; }
.submission-summary-body { flex: 1; min-width: 0; }
.submission-title { font-size: 14.5px; font-weight: 700; margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.submission-chevron { color: var(--hint); flex-shrink: 0; opacity: 0.55; width: 18px; height: 18px; }

/* Модальный редактор */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6, 8, 14, 0.7);
  backdrop-filter: blur(6px); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--card-border); border-bottom: none;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 16px; font-weight: 700; margin-bottom: 16px;
}
.modal-close { background: rgba(255,255,255,0.06); border: none; border-radius: 10px;
  padding: 6px; cursor: pointer; color: var(--text); display: flex; }

.editor-media { width: 100%; border-radius: var(--radius-md); margin-bottom: 14px; max-height: 240px; object-fit: cover; display: block; }

.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.editor-flat-toolbar {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 8px;
}
.tb-divider { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--card-border); flex-shrink: 0; }
.tb-btn {
  background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; color: var(--text);
  border-radius: var(--radius-sm); width: 36px; height: 36px; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: background 0.15s ease, border-color 0.15s ease;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tb-btn:active { background: var(--accent); border-color: var(--accent); }

.loading svg { animation: tb-spin 0.8s linear infinite; }
button:disabled { opacity: 0.6; cursor: default; }
@keyframes tb-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.ai-rewrite-pill {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.16) 0%, rgba(79, 140, 255, 0.16) 100%);
  border: 1px solid rgba(124, 92, 255, 0.35); color: var(--accent-2); font-weight: 700;
}
.ai-rewrite-pill:active { background: linear-gradient(135deg, rgba(124, 92, 255, 0.3) 0%, rgba(79, 140, 255, 0.3) 100%); }

.templates-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}
.template-chip {
  flex-shrink: 0; background: rgba(47, 111, 237, 0.12); color: var(--accent-2);
  border: 1px solid rgba(47, 111, 237, 0.25); border-radius: 999px;
  padding: 8px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap; font-family: inherit;
}

.template-row {
  display: flex; justify-content: space-between; align-items: center; padding: 13px 14px;
  border-bottom: 1px solid var(--card-border);
}
.template-row:last-child { border-bottom: none; }
.template-row-title { font-size: 14px; font-weight: 600; }

.dev-channel-row { padding: 14px; border-bottom: 1px solid var(--card-border); }
.dev-channel-row:last-child { border-bottom: none; }
.dev-channel-title { font-size: 14.5px; font-weight: 700; margin-bottom: 4px; }
.dev-channel-meta { font-size: 12px; color: var(--hint); margin-bottom: 8px; line-height: 1.5; }

.album-gallery {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.album-thumb {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  position: relative;
}
.album-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

.channel-multiselect {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.channel-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.channel-checkbox-row.checked {
  border-color: var(--accent);
  background: rgba(47, 111, 237, 0.1);
}
.channel-checkbox-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--hint);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.channel-checkbox-row.checked .channel-checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.channel-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--card-border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.channel-chip.checked {
  border-color: var(--accent);
  background: rgba(47, 111, 237, 0.12);
}
.channel-chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.channel-chip-check svg { width: 14px; height: 14px; display: block; stroke: var(--accent); }

/* ---------- Компактний вибір областей/типів тривог (менше візуального навантаження) ---------- */
.oblast-summary-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 12px 14px; border-radius: var(--radius-sm); background: var(--card);
  border: 1px solid var(--card-border); color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; margin-bottom: 8px;
}
.oblast-summary-chevron { color: var(--hint); transition: transform 0.2s ease; font-size: 12px; }
.chip-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px; margin-bottom: 10px;
}
.chip-compact {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 8px 10px; border-radius: 10px; background: var(--card);
  border: 1px solid var(--card-border); cursor: pointer;
  font-size: 12.5px; font-weight: 600; line-height: 1.25;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chip-compact.checked { border-color: var(--accent); background: rgba(47, 111, 237, 0.12); }
.chip-compact .channel-chip-check svg { width: 12px; height: 12px; flex-shrink: 0; }
.chip-compact svg.icon-sm { width: 15px; height: 15px; flex-shrink: 0; stroke: var(--text); fill: none; stroke-width: 2; }
.chip-compact span { flex: 1; }

/* ---------- Вкладки всередині модалки каналу (п.2 ТЗ) ---------- */
.modal-tab-bar {
  display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: var(--radius-md); border: 1px solid var(--card-border);
  padding: 4px; margin-bottom: 16px; scrollbar-width: none;
}
.modal-tab-bar::-webkit-scrollbar { display: none; }
.modal-tab-btn {
  flex: 1 1 0; background: none; border: none; color: var(--hint);
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 9px 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s ease; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.modal-tab-btn svg { opacity: 0.75; }
.modal-tab-btn.active svg { opacity: 1; }
.modal-tab-btn.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px var(--accent-glow); }
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; animation: modalTabIn 0.22s ease; }
@keyframes modalTabIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }

/* ==================== Редизайн модалки налаштувань каналу ==================== */

/* --- Hero: аватар + назва + статус, замість плоского рядка з дрібним текстом --- */
.modal-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.modal-hero-avatar {
  width: 56px; height: 56px; min-width: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex; align-items: center; justify-content: center; color: #fff; overflow: hidden;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.modal-hero-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }

.modal-hero-info { min-width: 0; flex: 1; }
.modal-hero-title {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-hero-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--hint); }
.modal-hero-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hint); flex-shrink: 0; }
.modal-hero-dot.active { background: var(--success); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
.modal-hero-dot.inactive { background: var(--danger); box-shadow: 0 0 0 3px rgba(240, 66, 106, 0.18); }

/* --- Карточка групи налаштувань: іконка + назва + опис + перемикач в шапці --- */
.settings-card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  padding: 14px; margin-bottom: 10px;
}
.settings-card-header { display: flex; align-items: center; gap: 12px; }
.settings-card-header.clickable { cursor: pointer; }
.settings-card-icon {
  width: 36px; height: 36px; min-width: 36px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(79, 140, 255, 0.12); color: var(--accent-2);
}
.settings-card-icon svg { width: 18px; height: 18px; }
.settings-card-body { flex: 1; min-width: 0; }
.settings-card-title { font-size: 14px; font-weight: 700; }
.settings-card-desc { font-size: 12px; color: var(--hint); margin-top: 2px; line-height: 1.35; }
.settings-card-extra { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--card-border); }
.settings-card-extra.collapsed { display: none; }

.position-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 6px; margin: 10px 0; max-width: 180px; }

.wm-live-preview-wrap {
  border-radius: var(--radius-md); border: 1px solid var(--card-border); overflow: hidden;
  display: flex; justify-content: center; background: var(--card);
}
.wm-live-preview-wrap canvas { display: block; max-width: 100%; height: auto; }
.position-btn {
  aspect-ratio: 1; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center;
}
.position-btn.active { border-color: var(--accent); background: rgba(47, 111, 237, 0.12); }
.position-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hint); }
.position-btn.active .dot { background: var(--accent-2); }


.album-thumb img, .album-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.album-thumb-error {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--danger);
  text-align: center;
  background: var(--danger-bg);
}

.media-lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.92);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.media-lightbox img, .media-lightbox video {
  max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain;
}
.album-thumb { cursor: zoom-in; }

.media-preview-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); overflow: hidden; margin-bottom: 8px;
}
#editor-media-preview { margin-top: 0; }
.media-preview-canvas-wrap { position: relative; width: 100%; background: #000; }
.media-preview-canvas-wrap canvas,
.media-preview-canvas-wrap video { width: 100%; display: block; max-height: 200px; object-fit: contain; }
.media-preview-controls {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; gap: 10px;
}
.watermark-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text); user-select: none;
}
.watermark-switch {
  width: 40px; height: 24px; border-radius: 999px; background: rgba(255,255,255,0.12);
  position: relative; transition: background 0.2s ease; flex-shrink: 0;
}
.watermark-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.watermark-switch.on { background: var(--accent); }
.watermark-switch.on::after { transform: translateX(16px); }

/* ---------- Профіль: Telegram theme-aware компоненти ---------- */
.profile-header-card {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px;
  margin-bottom: 18px;
}
.profile-header-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, #7c5cff 100%);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 18px;
}
.profile-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-header-info { min-width: 0; flex: 1; }
.profile-header-title {
  font-size: 15px; font-weight: 700; color: var(--tg-theme-text-color, var(--text));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-header-id { font-size: 12.5px; color: var(--tg-theme-hint-color, var(--hint)); margin-top: 2px; }
.profile-header-counters {
  display: flex; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--tg-theme-hint-color, var(--hint));
}
.profile-header-counters b { color: var(--tg-theme-text-color, var(--text)); font-weight: 700; }

.list-group {
  background: var(--tg-theme-secondary-bg-color, var(--card));
  border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 18px;
}
.list-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  border-bottom: 1px solid var(--card-border); min-height: 24px;
}
.list-row:last-child { border-bottom: none; }
.list-row-label {
  font-size: 14px; font-weight: 600; color: var(--tg-theme-text-color, var(--text));
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
}
.list-row-value { font-size: 13px; color: var(--tg-theme-hint-color, var(--hint)); flex-shrink: 0; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:active { background: rgba(255, 255, 255, 0.03); }
.list-row-chevron { color: var(--tg-theme-hint-color, var(--hint)); flex-shrink: 0; width: 18px; height: 18px; }

.info-icon-btn {
  width: 18px; height: 18px; border-radius: 50%; border: none; padding: 0;
  background: rgba(255, 255, 255, 0.08); color: var(--tg-theme-hint-color, var(--hint));
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.info-icon-btn svg { width: 12px; height: 12px; }

.channels-header-row { display: flex; align-items: center; gap: 10px; }
.channels-header-row .primary-btn { flex: 1; }
.channels-header-row .info-icon-btn { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--card); border: 1px solid var(--card-border); }
.channels-header-row .info-icon-btn svg { width: 18px; height: 18px; }

.switch {
  width: 40px; height: 24px; border-radius: 999px; background: rgba(255, 255, 255, 0.12);
  position: relative; transition: background 0.2s ease; flex-shrink: 0; cursor: pointer; border: none; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.switch.on { background: var(--tg-theme-button-color, var(--accent)); }
.switch.on::after { transform: translateX(16px); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper-btn {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05); color: var(--tg-theme-text-color, var(--text));
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px; font-weight: 700;
}
.stepper-btn:active { background: rgba(255, 255, 255, 0.12); }
.stepper-value {
  font-size: 13px; font-weight: 700; min-width: 44px; text-align: center;
  color: var(--tg-theme-text-color, var(--text));
}

.bottom-sheet-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.bottom-sheet {
  background: var(--tg-theme-bg-color, var(--bg)); border-radius: 18px 18px 0 0;
  padding: 20px; width: 100%; max-width: 480px; box-sizing: border-box;
  font-size: 14px; line-height: 1.5; color: var(--tg-theme-text-color, var(--text));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.bottom-sheet-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--card-border); margin: 0 auto 14px; }

.modal-sheet-flex {
  display: flex; flex-direction: column; max-height: 92vh; overflow: hidden;
}
.modal-scroll-area { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; }
.modal-sticky-footer {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--card-border);
}
.modal-sticky-footer .primary-btn { flex: 1; margin: 0; }
.icon-action-btn {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: var(--radius-md);
  background: var(--card); border: 1px solid var(--card-border); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-action-btn.icon-action-danger { color: var(--danger); border-color: rgba(240, 66, 106, 0.3); background: var(--danger-bg); }
.icon-action-btn:active { transform: scale(0.96); }

.textarea-wrap { position: relative; }
.char-counter {
  position: absolute; right: 10px; bottom: 8px; font-size: 11px; font-weight: 600;
  color: var(--hint); background: rgba(10, 14, 26, 0.7); padding: 2px 6px; border-radius: 6px;
  pointer-events: none;
}
.char-counter.over-limit { color: var(--danger); }

.editor-flat-toolbar { margin-bottom: 8px; }
.editor-quick-actions { display: flex; gap: 8px; margin: 10px 0; }
.editor-quick-actions .pill { font-size: 13px; }
.editor-quick-actions #editor-preview-btn { border: 1px solid var(--card-border); color: var(--hint); background: rgba(255,255,255,0.03); }
.editor-quick-actions #editor-preview-btn:active { background: rgba(255,255,255,0.08); }

.editor-section { margin-top: 4px; }
.editor-section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.editor-section-label { font-size: 12px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: .3px; }
.editor-inline-toggles {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--card-border);
}
.editor-inline-toggles .watermark-toggle { margin-bottom: 0; }

.chip-actions-row { display: flex; gap: 8px; margin-bottom: 8px; }
.chip-action-btn {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border); color: var(--hint);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}

.watermark-toggle.disabled { opacity: 0.5; cursor: not-allowed; }
.watermark-toggle.disabled .watermark-switch { pointer-events: none; }
.soon-badge {
  font-size: 10px; font-weight: 700; color: var(--hint); background: rgba(255, 255, 255, 0.08);
  border-radius: 999px; padding: 2px 7px; margin-left: auto;
}

.tg-bubble {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-md);
  padding: 0; font-size: 14.5px; line-height: 1.5; word-break: break-word; overflow: hidden;
}
.tg-bubble tg-spoiler { background: rgba(255,255,255,0.15); color: transparent; border-radius: 4px; }
.tg-bubble a { color: var(--accent-2); }
.tg-preview-text { padding: 14px; white-space: pre-wrap; }
.tg-preview-footer { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--card-border); font-size: 12.5px; opacity: 0.75; }

.tg-preview-gallery { display: grid; gap: 2px; }
.tg-preview-item { overflow: hidden; background: #000; position: relative; }
.tg-preview-item img, .tg-preview-item video { width: 100%; height: 100%; object-fit: cover; display: block; }

.tg-preview-gallery-1 { grid-template-columns: 1fr; }
.tg-preview-gallery-1 .tg-preview-item { aspect-ratio: 4 / 3; }

.tg-preview-gallery-2 { grid-template-columns: 1fr 1fr; }
.tg-preview-gallery-2 .tg-preview-item { aspect-ratio: 1 / 1; }

.tg-preview-gallery-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.tg-preview-gallery-3 .tg-preview-item:first-child { grid-row: 1 / 3; aspect-ratio: auto; height: 100%; }
.tg-preview-gallery-3 .tg-preview-item:not(:first-child) { aspect-ratio: 1 / 1; }

.tg-preview-gallery-grid { grid-template-columns: 1fr 1fr; }
.tg-preview-gallery-grid .tg-preview-item { aspect-ratio: 1 / 1; }

.album-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}
.album-type-badge {
  position: absolute; bottom: 4px; left: 4px; z-index: 2;
  background: rgba(0,0,0,0.6); color: #fff; border-radius: 6px;
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
}
.album-type-badge svg { width: 11px; height: 11px; }

.emoji-quickbar-card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  padding: 10px 12px 12px; margin-top: 8px; animation: fadeInDown 0.2s ease;
}
.emoji-quickbar-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--hint); margin-bottom: 8px;
}
.emoji-quickbar-close {
  width: 22px; height: 22px; border-radius: 50%; border: none; padding: 0;
  background: rgba(255,255,255,0.06); color: var(--hint);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.emoji-quickbar-close svg { width: 12px; height: 12px; }
.emoji-quickbar { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-quickbar-btn {
  background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; border-radius: 999px;
  width: 40px; height: 40px; font-size: 19px; cursor: pointer; flex-shrink: 0; font-family: inherit;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s ease, transform 0.1s ease;
}
.emoji-quickbar-btn:active { background: var(--card-border); transform: scale(0.9); }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.custom-emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px;
  max-height: 220px; overflow-y: auto; padding-right: 2px;
}
.custom-emoji-btn {
  background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; font-family: inherit; font-size: 19px;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s ease, transform 0.1s ease;
  padding: 0; overflow: hidden;
}
.custom-emoji-btn img { width: 26px; height: 26px; object-fit: contain; display: block; }
.custom-emoji-btn:active { background: var(--card-border); transform: scale(0.9); }

select.submission-edit-area {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a92a6' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
select.submission-edit-area,
select.submission-edit-area option {
  background-color: #1a2138;
  color: var(--text);
}