/* CSS-переменные и базовые компоненты UI (цвета, размеры, радиусы, тени). */
:root {
  --bg: #f6f7fb;
  --bg-2: #eef2ff;
  --surface: #ffffff;
  --surface-2: rgba(255,255,255,0.78);
  --border: rgba(15, 23, 42, 0.10);
  --border-2: rgba(15, 23, 42, 0.14);
  --accent: #2f7df6;
  --accent-2: #003474;
  --accent-surface: rgba(47, 125, 246, 0.12);
  --text: #0f172a;
  --text-secondary: rgba(15, 23, 42, 0.68);
  --muted: rgba(15, 23, 42, 0.46);
  --header-height: 64px;
  --action-btn-h: 40px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 10px 24px rgba(2,6,23,0.08);
  --focus: 0 0 0 4px rgba(47,125,246,0.22);
  --max: 1240px;
  --gap: 16px;
  --btn-h: 40px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

.edit-mode-banner {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(47, 125, 246, 0.14) 0%, rgba(79, 195, 220, 0.08) 100%);
  border-bottom: 2px solid rgba(47, 125, 246, 0.65);
}

.edit-mode-banner__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.edit-mode-banner__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.edit-mode-banner__icon {
  width: 20px;
  height: 20px;
  color: var(--accent-2);
  flex: 0 0 auto;
}

.edit-mode-banner__text {
  min-width: 0;
}

.edit-mode-banner__title {
  font-weight: 650;
  color: var(--accent-2);
}

.edit-mode-banner__info {
  font-size: 13px;
  color: rgba(0, 52, 116, 0.86);
  margin-top: 2px;
}

.edit-mode-banner__action {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(47, 125, 246, 0.45);
}

.edit-mode-banner__action:hover {
  border-color: var(--accent);
}

.edit-mode-banner__action-icon {
  width: 16px;
  height: 16px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

#buttons {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  background: linear-gradient(to bottom, var(--surface-2), rgba(255,255,255,0.62));
  border-bottom: 1px solid var(--border);
  padding: 0;
  width: 100%;
  box-sizing: border-box;
  max-width: 100vw;
  flex-shrink: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar-inner {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
  text-decoration: none;
}

.pill[data-active="true"] {
  background: var(--accent-surface);
  border-color: rgba(47,125,246,0.26);
  color: var(--text);
  font-weight: 600;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.brand img {
  height: 36px;
  width: auto;
  display: block;
}

.page-title-separator {
  color: var(--border);
  font-size: 24px;
  font-weight: 300;
  margin: 0 4px;
}

.page-title {
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
}

#buttons .toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: var(--radius-md);
  flex-wrap: wrap;
  max-width: 100%;
}

#buttons .action-group { display: contents; }

.nav-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

#toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

#toolbar button {
  background: transparent;
  border: none;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  height: var(--action-btn-h);
  min-height: var(--action-btn-h);
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-weight: 500;
  transition: all 0.2s ease;
}

#toolbar button:hover {
  background: #f8fafc;
  color: var(--text);
}

#copy, #edit-post, #exit-edit, #content-indicator {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--action-btn-h);
  min-height: var(--action-btn-h);
  white-space: nowrap;
  font-size: 14px;
  line-height: 1;
  max-width: 100%;
  font-weight: 500;
  transition: all 0.2s ease;
}

#send {
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,52,116,0.95);
  background: rgba(0,52,116,0.95);
  color: #fff;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--action-btn-h);
  min-height: var(--action-btn-h);
  white-space: nowrap;
  font-size: 14px;
  line-height: 1;
  max-width: 100%;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: none;
}

#send:hover {
  border-color: rgba(0,52,116,1);
  background: rgba(0,52,116,1);
  transform: none;
}

.btn {
  height: var(--btn-h);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 160ms ease, background 160ms ease;
  user-select: none;
  text-decoration: none;
}
.btn:hover { border-color: var(--border-2); transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* SVG иконки в кнопках */
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}
.btn-primary svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}
.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* Кнопка с юзернеймом */
.btn-username {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 400;
}
.btn-username:hover {
  background: #f8fafc;
  border-color: var(--accent);
}

/* Маленькая иконочная кнопка */
.btn.btn-icon {
  padding: 0;
  width: var(--btn-h);
  min-width: var(--btn-h);
  justify-content: center;
  font-size: 16px;
}

/* Toggle-кнопка */
.btn.btn-toggle {
  padding: 0;
  width: var(--action-btn-h);
  min-width: var(--action-btn-h);
  justify-content: center;
  font-size: 16px;
  opacity: 0.5;
  filter: grayscale(1);
  transition: all 0.2s ease;
}
.btn.btn-toggle.active {
  opacity: 1;
  filter: none;
  background: #eaf3ff;
  border-color: var(--accent);
}
.btn.btn-toggle:hover {
  opacity: 0.8;
  filter: grayscale(0.5);
}
.btn.btn-toggle.active:hover {
  opacity: 1;
  filter: none;
}

.btn-primary {
  border-radius: 12px;
  border: 1px solid rgba(0,52,116,0.95);
  background: rgba(0,52,116,0.95);
  color: #fff;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--btn-h);
  min-height: var(--btn-h);
  white-space: nowrap;
  font-size: 13.5px;
  line-height: 1;
  max-width: 100%;
  font-weight: 400;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(0,52,116,0.16);
}
.btn-primary:hover { transform: translateY(-1px); border-color: rgba(0,52,116,1); background: rgba(0,52,116,1); }

.menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.menu-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 30;
}

.menu-pop.menu-pop-up {
  top: auto;
  bottom: calc(100% + 10px);
}

.menu-caption {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px 2px;
}

.menu-item {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
  text-align: left;
}

.menu-item:hover {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.06);
}

.menu-item:focus-visible { outline: none; box-shadow: var(--focus); }

.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; color: rgba(0,52,116,0.95); }

.page {
  padding: 18px 0 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--gap);
  align-items: stretch;
}

.lk-top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lk-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--gap);
  align-items: start;
}

.lk-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 18px);
  max-height: calc(100vh - var(--header-height) - 36px);
  overflow: auto;
}

.lk-nav {
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 4px;
}

.lk-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.lk-nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--text-secondary);
}

.lk-nav-item:hover {
  background: rgba(15,23,42,0.02);
  border-color: var(--border);
}

.lk-nav-item[data-active="true"] {
  background: var(--accent-surface);
  border-color: rgba(47,125,246,0.26);
  font-weight: 650;
}

.lk-nav-item[data-active="true"] svg {
  color: var(--accent-2);
}

.lk-main {
  min-width: 0;
}

.lk-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.lk-card-body {
  padding: 16px;
}

.lk-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.lk-form-row .modal-input {
  flex: 1;
  min-width: 260px;
}

.lk-form-help {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.lk-page .section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

.lk-page .section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.lk-page .stat-title {
  font-weight: 650;
  margin: 4px 0;
}

.lk-page .stat-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.lk-page .stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}

.lk-page .stat-badge .num {
  font-weight: 650;
}

.lk-stats-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.lk-stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.lk-stat-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px;
  min-width: 0;
}

.lk-stat-card .stat-badges {
  margin-top: 8px;
}

.lk-kpi-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.lk-kpi-head .stat-title {
  margin: 0;
  color: var(--text);
}

.lk-kpi-num {
  font-size: 22px;
  line-height: 1;
  font-weight: 750;
  color: var(--text);
}

.lk-kpi-empty {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.lk-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lk-stats-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(to bottom, rgba(15,23,42,0.018), rgba(15,23,42,0.00));
  padding: 12px;
  min-width: 0;
}

.lk-stats-block-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.lk-stats-block-title {
  font-weight: 650;
  font-size: 13px;
  color: var(--text);
}

.lk-stats-block-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 960px) {
  .lk-layout {
    grid-template-columns: 1fr;
  }

  .lk-sidebar {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .lk-stats-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(15,23,42,0.03), rgba(15,23,42,0.00));
}

.card-h .title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.card-h .title strong { font-size: 14px; font-weight: 650; }
.card-h .title span { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.preview-body {
  padding: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  background:
    radial-gradient(1200px 900px at 50% 55%, rgba(47,125,246,0.08) 0%, rgba(47,125,246,0) 65%),
    linear-gradient(to bottom, rgba(15,23,42,0.015), rgba(15,23,42,0));
}

.card-preview {
  position: relative;
}

.preview-toolbar {
  display: flex;
  gap: 8px;
  padding: 0;
  justify-content: center;
}

.card-preview .preview-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 2;
  pointer-events: none;
}

.card-preview .preview-toolbar .preview-toggle {
  pointer-events: auto;
}

.card-preview .preview-body {
  padding: 56px 16px 16px 16px;
}

.preview-toggle {
  padding: 0;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  justify-content: center;
  gap: 0;
  border-radius: var(--radius-sm);
  opacity: 1;
  filter: none;
}

.preview-toggle svg {
  width: 20px;
  height: 20px;
}

.preview-toggle.active {
  background: #eaf3ff;
  border-color: var(--accent);
}

.preview-toggle:hover {
  transform: none;
  border-color: var(--border-2);
  background: rgba(15,23,42,0.02);
}

.preview-toggle.active:hover {
  border-color: var(--accent);
  background: #eaf3ff;
}

.preview-body #preview {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: auto;
  scrollbar-gutter: stable;
  margin-right: 0;
  padding-right: 0;
  padding-bottom: 16px;
}

.preview-body #preview > .tg-message:first-child {
  margin-top: 0;
}

.preview-body #preview > .tg-inline-keyboard:first-child {
  margin-top: 0;
}

#copy:hover, #edit-post:hover, #exit-edit:hover, #content-indicator:hover {
  background: #f8fafc;
  border-color: var(--accent);
}

#content-indicator {
  position: absolute;
  right: 10px;
  top: 48px;
  display: inline-block;
  padding: 6px 10px;
  background: #fff7d6;
  border: 1px solid #ffe8a3;
  border-radius: var(--radius-sm);
  color: #7a5c00;
  font-size: 12px;
  z-index: 12;
}
#content-indicator.warning {
  background: #fde9e5;
  color: #a62929;
  border-color: #f3c8c0;
}

#media-indicator {
  position: absolute;
  right: 10px;
  top: 10px;
  display: inline-block;
  padding: 6px 10px;
  background: #fde9e5;
  border: 1px solid #f3c8c0;
  border-radius: var(--radius-sm);
  color: #a62929;
  font-size: 12px;
  z-index: 12;
  cursor: pointer;
}
#media-indicator:hover { filter: brightness(1.02); }
#media-indicator.hidden { display: none; }

@media (max-width: 420px) {
  #copy, #send {
    white-space: normal;
  }
}

@media (max-width: 640px) {
  #buttons {
    height: auto;
    padding: 8px 0;
  }
  .topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .brand {
    padding: 6px 8px;
  }
  .actions {
    margin-left: auto;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav {
    width: 100%;
    justify-content: flex-start;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
}

#editor-container {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--gap);
  padding: 0;
  box-sizing: border-box;
  max-width: 100vw;
  overflow: visible;
  height: calc(100dvh - var(--header-height) - 42px);
}

#editor {
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
  border: 0;
  border-radius: 0;
}

#preview {
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: auto;
}

#editor .tiptap {
  background: transparent;
  border: 0;
  border-radius: 0;
  flex: 1;
  width: 100%;
  padding: 12px;
  box-sizing: border-box;
  padding-bottom: 120px;
  overflow: auto;
}

#md-fallback {
  background: transparent;
  border: 0;
  border-radius: 0;
  height: 100%;
  padding: 12px;
  font-family: system-ui, Arial, sans-serif;
  font-size: 14px;
  padding-bottom: 120px;
  overflow: auto;
}

#md-fallback:focus,
#md-fallback:focus-visible {
  outline: none;
  box-shadow: none;
}

@media (max-width: 900px) {
  #editor-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    height: calc(100dvh - var(--header-height) - 42px);
  }
  .topbar-inner { grid-template-columns: auto 1fr; }
  .nav { justify-content: flex-end; }
}
#images { max-width: 160px; }
.user-meta {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status { 
  min-width: 0; 
  color: #555; 
  font-size: 13px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#status.status {
  position: fixed;
  left: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100vw - 28px));
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 8px 22px rgba(15,23,42,0.10);
  backdrop-filter: blur(8px);
  z-index: 40;
}
#status.status:empty {
  display: none;
}
#thumbs {
  position: absolute;
  left: 102px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 160px);
  z-index: 11;
}

.thumb {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 160ms ease;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.dragging { opacity: 0.9; transform: scale(1.06); box-shadow: 0 6px 16px rgba(0,0,0,0.18); }
.thumb.over { outline: 2px dashed #2f7df6; }
.thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #dc2626;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.thumb-remove:hover { filter: brightness(1.1); }

/* Video and document thumbnails */
.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  position: relative;
}
.thumb-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-video-overlay {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  color: #fff;
}
.thumb-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: thumb-spin 0.8s linear infinite;
  margin-top: 4px;
}
@keyframes thumb-spin {
  to { transform: rotate(360deg); }
}
.thumb-file-icon {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 2px;
  box-sizing: border-box;
}
.thumb-icon {
  font-size: 16px;
  line-height: 1;
}
.thumb-filename {
  font-size: 6px;
  color: #64748b;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.thumb-filesize {
  font-size: 5px;
  color: #94a3b8;
}
/* File type specific colors */
.thumb-video .thumb-placeholder { background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%); }
.thumb-audio .thumb-file-icon { background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%); }
.thumb-document .thumb-file-icon { background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%); }
.thumb-archive .thumb-file-icon { background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%); }

.thumb-spoiler-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  transition: all 0.2s;
  z-index: 5;
  padding: 0;
}
.thumb-spoiler-btn:hover {
  background: rgba(0,0,0,0.7);
  transform: scale(1.1);
}
.thumb-spoiler-btn.active {
  background: #2f7df6;
  border-color: #2f7df6;
}

.thumb.spoiler-blur img,
.thumb.spoiler-blur .thumb-placeholder canvas,
.thumb.spoiler-blur .thumb-placeholder img {
  filter: blur(4px);
}
.thumb.spoiler-blur::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  z-index: 3;
  pointer-events: none;
  border-radius: 6px;
}


.modal-overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.32);
  -webkit-backdrop-filter: saturate(180%) blur(6px);
  backdrop-filter: saturate(180%) blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-window {
  width: 560px;
  max-width: min(92vw, 640px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  animation: modal-in 160ms ease-out forwards;
}
.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.modal-body { padding: 16px; }
.modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 246, 0.15);
}
.modal-footer button {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 14px;
  height: var(--action-btn-h);
  min-height: var(--action-btn-h);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s ease;
}
.modal-footer button:hover { background: #f8fafc; border-color: var(--accent); }
#use-chat {
  background: rgb(0, 52, 116);
  color: #fff;
  border-color: rgb(0, 52, 116);
}
#use-chat:hover { filter: brightness(1.15); }

@keyframes modal-in {
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.chat-list { max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.chat-item {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.chat-item:last-child { border-bottom: none; }
.chat-item:hover { background: #f8fafc; }
.chat-item.selected { background: #eaf3ff; }
.chat-title { font-weight: 600; }
.chat-sub { color: #666; font-size: 12px; }
.modal-actions button { height: var(--action-btn-h); }

.result-list { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: auto; max-height: 300px; }
.result-item { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.result-item:last-child { border-bottom: none; }
.result-name { font-weight: 600; flex: 1; }
.result-link { color: var(--accent); text-decoration: none; }
.result-link:hover { text-decoration: underline; }
.result-error { color: #d64a4a; }
.result-status { font-size: 12px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); }
.status-ok { background: #eaf6ee; color: #1f6b3a; border-color: #cde7d5; }
.status-fail { background: #fde9e5; color: #a62929; border-color: #f3c8c0; }
.btn, .btn-primary, #toolbar button, #copy, #send, #edit-post, #exit-edit, #content-indicator, .modal-footer button { cursor: pointer; }
