/* ========== ГЛОБАЛЬНЫЕ ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== ТЁМНАЯ ТЕМА (по умолчанию) ===== */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-input: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --overlay: rgba(0,0,0,0.7);
}
/* ===== СКРОЛЛБАР ДЛЯ СВЕТЛОЙ ===== */
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border); }

/* ===== СВЕТЛАЯ ТЕМА ===== */
[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --border: #d0d7de;
  --text: #1f2328;
  --text-dim: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --orange: #9a6700;
  --red: #cf222e;
  --overlay: rgba(0,0,0,0.4);
}

/* ===== ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ===== */
.theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; cursor: pointer;
  font-size: 1rem; color: var(--text-dim); line-height: 1;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }

html { font-size: 16px; }

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

input, textarea, select, button { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* Скроллбар тёмный */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ========== ЭКРАНЫ ========== */
.screen { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ========== АВТОРИЗАЦИЯ ========== */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px 24px; width: 100%; max-width: 380px;
}
.login-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 4px; }
.subtitle { text-align: center; color: var(--text-dim); font-size: 0.9rem; margin-bottom: 24px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
.error-msg { color: var(--red); font-size: 0.85rem; text-align: center; min-height: 1.2em; }

/* ========== ШАПКА ========== */
.header { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.header h1 { font-size: 1.2rem; }

/* ========== ТАБЫ ========== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px; border: none; border-radius: var(--radius) var(--radius) 0 0;
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 0.95rem; transition: 0.15s;
}
.tab.active { background: var(--bg-card); color: var(--text); }
.tab:hover { color: var(--text); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== ФОРМА ========== */
form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 0.85rem; color: var(--text-dim); font-weight: 500; }
input, textarea, select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; color: var(--text);
  width: 100%; outline: none; transition: border 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

/* ========== ТИПЫ (сетка карточек) ========== */
.type-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.type-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: 0.15s; text-align: center;
}
.type-card:hover { border-color: var(--text-dim); }
.type-card.selected { border-color: var(--accent); background: rgba(88,166,255,0.1); }
.type-icon { font-size: 1.5rem; }
.type-label { font-size: 0.75rem; color: var(--text-dim); }

/* ========== РЯДЫ ========== */
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-group { display: flex; flex-direction: column; gap: 4px; }

/* ========== ЭМОДЗИ ========== */
.emoji-bar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0;
}
.emoji-btn, .emoji-btn-more {
  background: var(--bg-input); border: 1px solid transparent;
  border-radius: 6px; padding: 4px 8px; cursor: pointer;
  font-size: 1.2rem; transition: 0.1s; line-height: 1;
}
.emoji-btn:hover, .emoji-btn-more:hover { background: var(--border); }
.emoji-btn-more { font-size: 0.9rem; color: var(--text-dim); }

.emoji-picker {
  display: flex; flex-wrap: wrap; gap: 4px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; max-height: 200px; overflow-y: auto;
}

/* ========== КНОПКИ ========== */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  border: none; border-radius: var(--radius); padding: 10px 20px;
  font-weight: 600; cursor: pointer; transition: 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); font-size: 1.2rem; }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(248,81,73,0.15); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; }
.form-msg { font-size: 0.85rem; text-align: center; min-height: 1.2em; }

/* ========== ОЧЕРЕДЬ ========== */
.queue-header { margin-bottom: 12px; }
.queue-header h2 { font-size: 1.1rem; margin-bottom: 8px; }
.queue-filters { display: flex; gap: 8px; }
.filter-select { flex: 1; }
.queue-list { display: flex; flex-direction: column; gap: 8px; }
.empty-msg { text-align: center; color: var(--text-dim); padding: 24px; }

/* ========== КАРТОЧКА ПУБЛИКАЦИИ В ОЧЕРЕДИ ========== */
.queue-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  display: flex; align-items: flex-start; gap: 12px;
}
.queue-card .qc-info { flex: 1; min-width: 0; }
.queue-card .qc-type-date {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.queue-card .qc-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-post { background: rgba(88,166,255,0.2); color: var(--accent); }
.badge-stories { background: rgba(210,153,34,0.2); color: var(--orange); }
.badge-story-post { background: rgba(88,166,255,0.2); color: var(--accent); }
.badge-video { background: rgba(63,185,80,0.2); color: var(--green); }
.badge-clip { background: rgba(248,81,73,0.2); color: var(--red); }
.badge-channel { background: rgba(210,153,34,0.2); color: var(--orange); }
.queue-card .qc-date { font-size: 0.8rem; color: var(--text-dim); }
.queue-card .qc-text {
  font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-card .qc-actions { display: flex; gap: 4px; flex-shrink: 0; }
.queue-card .qc-actions button {
  background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px;
  border-radius: 4px; transition: 0.1s;
}
.queue-card .qc-actions button:hover { background: var(--bg-input); }

/* ========== СТАТУС-ИКОНКИ ========== */
.status-icon { font-size: 1.3rem; }
.status-draft { color: var(--text-dim); }
.status-queued { color: var(--orange); }
.status-published { color: var(--green); }
.status-error { color: var(--red); }

/* ========== МОДАЛКА ========== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.3rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.edit-select { padding: 8px 12px; }

/* ========== АДАПТАЦИЯ ПОД ТЕЛЕФОН ========== */
@media (max-width: 480px) {
  .screen { padding: 12px; }
  .type-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .type-card { padding: 8px 2px; }
  .type-icon { font-size: 1.2rem; }
  .type-label { font-size: 0.65rem; }
  .row-fields { grid-template-columns: 1fr; gap: 8px; }
  .queue-card { flex-direction: column; gap: 8px; }
  .queue-card .qc-actions { align-self: flex-end; }
  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; }
  .login-card { padding: 24px 16px; }
  .emoji-bar { gap: 2px; }
  .emoji-btn, .emoji-btn-more { padding: 4px 6px; font-size: 1rem; }
}

/* Анимация появления */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.queue-card { animation: fadeIn 0.2s ease-out; }

/* ========== ЧЕРНОВИКИ ========== */
.drafts-summary {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
.draft-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; flex: 1; min-width: 80px;
  text-align: center;
}
.draft-stat .count { font-size: 1.4rem; font-weight: 700; display: block; }
.draft-stat .label { font-size: 0.75rem; color: var(--text-dim); }
.draft-stat .count-post { color: var(--accent); }
.draft-stat .count-stories { color: var(--orange); }
.draft-stat .count-video { color: var(--green); }
.draft-stat .count-clip { color: var(--red); }

.queue-card.draft-card {
  border-left: 3px solid var(--text-dim);
  opacity: 0.85;
}
.queue-card.draft-card:hover { opacity: 1; }
.queue-card .qc-to-queue {
  background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 4px 10px; font-size: 0.8rem;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.queue-card .qc-to-queue:hover { background: var(--accent-hover); }
