:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8fa3bc;
  --accent: #e8a54b;
  --accent-dim: #c4882f;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --vk: #4a76a8;
  --tg: #2aabee;
  /* Рубрики: бежевый (всё кроме видео и эфира), голубой — видео, розовый — эфир */
  --tone-beige: #c9b896;
  --tone-beige-bg: rgba(201, 184, 150, 0.2);
  --tone-beige-text: #ede4d4;
  --tone-video: #2ec8ff;
  --tone-video-bg: rgba(46, 200, 255, 0.22);
  --tone-video-text: #dff6ff;
  --tone-efir: #e879a9;
  --tone-efir-bg: rgba(232, 121, 169, 0.24);
  --tone-efir-text: #fdd8e8;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

header .main-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  flex-shrink: 0;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
}

.nav-link.active {
  background: var(--accent);
  color: #1a1208;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}

button:hover,
.btn:hover {
  opacity: 0.9;
}

button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #1a1208;
  font-weight: 600;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: #7f1d1d;
  color: #fecaca;
}

.btn-vk {
  background: var(--vk);
  color: #fff;
  font-weight: 600;
}

.btn-tg {
  background: var(--tg);
  color: #fff;
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

select,
input[type="datetime-local"],
input[type="text"],
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

select:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.posts-grid {
  display: grid;
  gap: 12px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  transition: border-color 0.15s;
}

.post-card:hover {
  border-color: var(--accent-dim);
}

.post-card.published {
  opacity: 0.75;
}

.post-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-type {
  border: 1px solid transparent;
}

.badge-type.tone-beige {
  background: var(--tone-beige-bg);
  border-color: var(--tone-beige);
  color: var(--tone-beige-text);
}

.badge-type.tone-video {
  background: var(--tone-video-bg);
  border-color: var(--tone-video);
  color: var(--tone-video-text);
}

.badge-type.tone-efir {
  background: var(--tone-efir-bg);
  border-color: var(--tone-efir);
  color: var(--tone-efir-text);
}

.post-card.tone-beige { border-left: 3px solid var(--tone-beige); }
.post-card.tone-video { border-left: 3px solid var(--tone-video); }
.post-card.tone-efir { border-left: 3px solid var(--tone-efir); }

#post-type.tone-beige {
  color: var(--tone-beige);
  font-weight: 700;
}

#post-type.tone-video {
  color: var(--tone-video);
  font-weight: 700;
}

#post-type.tone-efir {
  color: var(--tone-efir);
  font-weight: 700;
}

.badge-status-draft { background: #374151; color: #d1d5db; }
.badge-status-scheduled { background: #1e3a5f; color: #93c5fd; }
.badge-status-published { background: #14532d; color: #86efac; }
.badge-status-failed { background: #7f1d1d; color: #fca5a5; }
.badge-status-manual { background: #713f12; color: #fde68a; }
.badge-status-skipped { background: #44403c; color: #d6d3d1; }

.platforms {
  display: flex;
  gap: 6px;
}

.platform {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
}

.platform.vk { background: var(--vk); }
.platform.tg { background: var(--tg); }
.platform.off { background: var(--border); opacity: 0.4; }

.post-thesis {
  font-size: 1rem;
  margin: 0 0 6px;
}

.post-date {
  color: var(--muted);
  font-size: 0.85rem;
}

.post-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.field-label-row label {
  margin-bottom: 0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.field textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
}

.field input[type="text"],
.field input[type="datetime-local"] {
  width: 100%;
}

.check-row {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.photo-preview {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  max-height: 280px;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: none;
}

.photo-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.photo-thumb img {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
}

.photo-thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.photo-thumb-delete:hover {
  background: var(--danger);
}

.photo-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.photo-preview img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.theme-hint {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.theme-hint strong {
  color: var(--text);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
  animation: slideIn 0.25s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 100px;
}

.stat .num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.stat .label {
  font-size: 0.8rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}

.grok-panel {
  margin-bottom: 16px;
  border-color: #3d4f6a;
  background: linear-gradient(135deg, #1a2332 0%, #1e2a3d 100%);
}

.grok-panel h2 {
  color: var(--accent);
}

.grok-theses {
  width: 100%;
  min-height: 140px;
  resize: vertical;
}

.btn-grok {
  background: linear-gradient(135deg, #6b4fcf 0%, #4a76a8 100%);
  color: #fff;
  font-weight: 600;
}

.btn-grok:disabled {
  opacity: 0.6;
  cursor: wait;
}

.grok-hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.photo-panel:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.photo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.photo-file-label {
  cursor: pointer;
  margin: 0;
}

.photo-paste-hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.photo-paste-hint kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.7rem;
}

.photo-paste-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px 12px;
  text-align: center;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.photo-paste-zone:hover,
.photo-paste-zone.active,
.photo-paste-zone.waiting {
  border-color: var(--accent);
  background: rgba(232, 165, 75, 0.08);
}

.photo-paste-zone.waiting {
  animation: paste-pulse 1.2s ease-in-out infinite;
}

.photo-paste-zone-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.photo-paste-zone.waiting .photo-paste-zone-label {
  color: var(--accent);
  font-weight: 600;
}

.photo-paste-capture {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  outline: none;
}

.photo-panel.drag-over {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent-dim);
}

@keyframes paste-pulse {
  50% { border-color: var(--accent-dim); }
}

/* Модальные окна */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-card .field {
  margin-bottom: 14px;
}

.modal-card label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.modal-card input,
.modal-card select,
.modal-card textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.editor-danger-zone {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.editor-danger-zone h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--danger);
}

.editor-danger-zone p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.video-status-radios {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-status-radio {
  display: block;
  cursor: pointer;
}

.video-status-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.video-status-radio-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.video-status-radio-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: rgba(46, 200, 255, 0.12);
  color: var(--tone-video);
  flex-shrink: 0;
}

.video-status-radio-icon .status-svg {
  width: 21px;
  height: 21px;
  display: block;
}

.video-status-radio-icon .status-svg-wide {
  width: 24px;
  height: 18px;
}

.video-status-radio-label {
  font-size: 0.9rem;
  color: var(--text);
}

.video-status-radio input:checked + .video-status-radio-card {
  border-color: var(--tone-video);
  background: rgba(46, 200, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(46, 200, 255, 0.35);
}

.video-status-radio input:focus-visible + .video-status-radio-card {
  outline: 2px solid var(--tone-video);
  outline-offset: 2px;
}

.video-status-radio:hover .video-status-radio-card {
  border-color: rgba(46, 200, 255, 0.55);
}

/* Публикация недели */
.modal-card-wide {
  width: min(560px, 100%);
}

.publish-week-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.publish-platform-block {
  margin-bottom: 18px;
}

.publish-platform-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.publish-platform-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.publish-platform-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.9rem;
}

.publish-progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.publish-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.publish-progress-vk {
  background: linear-gradient(90deg, #4a76a8, #5181b8);
}

.publish-progress-tg {
  background: linear-gradient(90deg, #2aabee, #229ed9);
}

.publish-platform-meta {
  margin-top: 6px;
  min-height: 1.1em;
  font-size: 0.8rem;
  color: var(--muted);
}

.publish-week-log {
  margin-top: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.8rem;
  line-height: 1.45;
}

.publish-log-line + .publish-log-line {
  margin-top: 6px;
}

.publish-log-ok {
  color: var(--success);
}

.publish-log-error {
  color: var(--danger);
}

/* --- Poll-needed banner --- */
.poll-needed-banner {
  background: color-mix(in srgb, #f5a623 12%, var(--surface));
  border: 1px solid #f5a623;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  color: var(--text);
}

.poll-needed-banner strong {
  display: block;
  color: #f5a623;
  font-size: 1rem;
  margin-bottom: 4px;
}

.poll-needed-banner p {
  margin: 0 0 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* --- TG-очередь --- */
.tg-queue-panel {
  background: var(--surface);
  border: 1px solid var(--tg);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}

.tg-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tg-queue-title {
  font-weight: 600;
  color: var(--tg);
  font-size: 0.95rem;
}

.tg-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.tg-queue-row {
  display: grid;
  grid-template-columns: 120px 1fr 80px;
  gap: 10px;
  font-size: 0.82rem;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  align-items: center;
}

.tg-queue-date {
  color: var(--muted);
  white-space: nowrap;
}

.tg-queue-thesis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-queue-time {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  text-align: right;
  white-space: nowrap;
}
