/* Тёмная тема канала: те же смыслы, что в дизайн-системе v3.0, но вывернутые.
   Ink стал фоном, paper — текстом, синий остался бренд-акцентом (чуть светлее,
   чтобы держать контраст на тёмном). Unbounded — крупные титулы, Onest — всё остальное. */

:root {
  --paper: #0F1115;
  --surface: #171A20;
  --surface-2: #21252D;
  --line: #2A2F38;
  --line-2: #3A404B;
  --ink: #F2F4F7;
  --muted: #A2A9B4;
  --faint: #6E7581;
  --blue: #4E74FF;
  --blue-700: #6D8BFF;
  --blue-100: #1B2440;
  --coral: #FF6B61;
  --coral-100: #3A1F1E;
  --mark: #FFE04A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --radius: 18px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 92px; }
body.no-tabs { padding-bottom: 24px; }

::selection { background: var(--mark); color: var(--ink); }

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

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

.screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px var(--gutter) 24px;
}

/* ------------------------- типографика ------------------------- */

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--blue);
  margin: 0 0 10px;
}

.kicker.muted { color: var(--faint); }

h1.display {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

h2.section {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 28px 0 12px;
}

.lead {
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 18px;
}

.hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--faint);
  margin: 8px 0 0;
}

/* ------------------------- кнопки ------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  -webkit-tap-highlight-color: transparent;
  /* Подпись не переносится: две строки в кнопке ломают ряд. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-danger { color: var(--coral); }
.btn-primary:active { background: var(--blue-700); }

.btn-ink { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
}

.btn-danger { background: var(--coral-100); color: var(--coral); }

.btn-full { width: 100%; }

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 380px) {
  .btn-row .btn { font-size: 14px; padding: 0 12px; }
}

.btn-sm { min-height: 38px; font-size: 13px; padding: 0 12px; border-radius: 11px; }

/* ------------------------- карточка материала ------------------------- */

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-2) center/cover no-repeat;
  cursor: pointer;
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
}

.card-cover.empty {
  background: linear-gradient(135deg, var(--blue-100), var(--surface-2));
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 17, 21, .78);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card-badge.draft { background: var(--coral); color: #14161A; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }

.card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 6px;
  cursor: pointer;
}

.card-sub {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  margin: 0 0 14px;
}

.card-title:last-of-type { margin-bottom: 14px; }

.card-actions { margin-top: auto; }

/* ------------------------- страница материала ------------------------- */

.hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--surface-2) center/cover no-repeat;
  margin: 0 0 18px;
  border: 1px solid var(--line);
}

.hero.empty { background: linear-gradient(135deg, var(--blue-100), var(--surface-2)); }

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 14px;
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 12px;
}

.item-list { display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
}

.item .icon { font-size: 16px; }
.item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* markdown-превью */
.md { font-size: 15px; line-height: 1.6; }
.md b { font-weight: 700; }
.md a { word-break: break-word; }
.md code {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 13px;
}
.md pre {
  background: #0A0C10;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
}
.md pre code { background: none; color: inherit; padding: 0; }
.md blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--blue);
  color: var(--muted);
}

/* ------------------------- формы админки ------------------------- */

.field { margin: 0 0 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 6px;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.45;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.field textarea { resize: vertical; min-height: 120px; }
.field textarea.tall { min-height: 220px; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.switch input { width: 46px; height: 28px; accent-color: var(--blue); }

.copyable {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  word-break: break-all;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  margin: 0 0 10px;
}

.admin-row .thumb {
  width: 84px;
  aspect-ratio: 16 / 9;
  border-radius: 9px;
  background: var(--surface-2) center/cover no-repeat;
  flex: none;
}

.admin-row .grow { flex: 1; min-width: 0; }

.admin-row .name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

.arrows { display: flex; flex-direction: column; gap: 4px; }

.arrows button {
  width: 30px;
  height: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
}

/* ------------------------- статистика ------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

@media (min-width: 560px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.stat .value {
  font-family: 'Unbounded', sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 8px;
}

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 8px; }

.bars .bar {
  flex: 1 1 0;
  min-width: 4px;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
}

.table-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.table-row:last-child { border-bottom: 0; }
.table-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-row .num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------- нижние вкладки ------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(16px) saturate(170%);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}

.tabbar button {
  flex: 1;
  background: none;
  border: 0;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  cursor: pointer;
  border-radius: 10px;
}

.tabbar button.active { color: var(--blue); background: var(--blue-100); }

/* ------------------------- служебное ------------------------- */

.boot { text-align: center; padding: 80px 0; color: var(--faint); font-size: 14px; }

.boot-spark {
  width: 28px;
  height: 28px;
  margin: 0 auto 14px;
  border: 2px solid var(--line-2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-2);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(20, 22, 26, .25);
  z-index: 60;
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.error { background: var(--coral); color: #14161A; border-color: var(--coral); }

.divider { height: 1px; background: var(--line); margin: 20px 0; border: 0; }
