/* Токены */
:root {
  color-scheme: light dark;
  --bg: #f3f5f9;
  --surface: #fff;
  --text: #172437;
  --muted: #596a80;
  --line: #dce2ec;
  --accent: #2457d6;
  --ok: #17734b;
  --warn: #8a5a00;
  --bad: #bd3042;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
/* Общие элементы */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--accent);
  text-underline-offset: 4px;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
.button,
summary,
input,
select {
  min-height: 44px;
}
button,
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1.4;
}
button:hover,
.button:hover {
  border-color: var(--accent);
}
.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.quiet {
  border-color: transparent;
}
.danger {
  color: var(--bad);
  border-color: var(--bad);
}
.danger-text,
.error {
  color: var(--bad);
}
.warning {
  color: var(--warn);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
/* Шапка */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 32px;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.brand {
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 24px;
  text-decoration: none;
}
.brand span {
  font-weight: 500;
}
.company {
  font-weight: 600;
}
.company form {
  display: flex;
  align-items: end;
  gap: 8px;
}
nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
header nav a {
  padding: 12px;
  text-decoration: none;
  color: var(--muted);
  border-radius: 8px;
}
header nav a[aria-current] {
  background: var(--bg);
  color: var(--accent);
  font-weight: 650;
}
.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
/* Содержимое страниц */
main {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
  min-height: 70vh;
}
h1 {
  font-size: 32px;
  letter-spacing: -0.035em;
  margin: 8px 0 24px;
  line-height: 1.2;
}
h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}
h3 {
  font-size: 16px;
}
p {
  line-height: 1.55;
  margin: 8px 0 16px;
}
small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.15em;
  font-weight: 750;
  color: var(--muted);
  margin: 0;
}
.card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.page-heading h2 {
  margin: 0;
}
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.strip p {
  margin-bottom: 0;
}
.banner {
  background: var(--surface);
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--warn);
}
/* Очередь: загрузка */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
  padding: 32px 16px;
  margin: 16px 0 24px;
}
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--bg);
}
.dropzone label {
  cursor: pointer;
  margin: 0;
}
.dropzone span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 16px;
}
.dropzone input.sr-only {
  min-height: 0;
}
.dropzone .file-picker {
  font-size: 16px;
  font-weight: 400;
}
#files:focus-visible + .file-picker {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
/* Формы */
label {
  display: block;
  font-size: 14px;
  font-weight: 550;
  margin-bottom: 16px;
}
input:not([type='checkbox']):not([type='radio']):not([type='file']),
textarea,
select {
  display: block;
  width: 100%;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  margin-top: 8px;
  min-width: 0;
}
textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}
form {
  min-width: 0;
}
form + form {
  margin-top: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 450;
  min-height: 44px;
  margin-bottom: 4px;
}
.check input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
  margin: 8px 0 16px;
}
legend {
  font-size: 14px;
  padding: 0 8px;
}
/* Очередь */
.queue-item {
  display: grid;
  grid-template-columns: 24px 112px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.queue-item:not(:has(.drag-handle)) {
  grid-template-columns: 112px minmax(0, 1fr);
}
.drag-handle {
  padding-top: 8px;
  cursor: grab;
  font-size: 24px;
  color: var(--muted);
}
.thumb {
  position: relative;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  width: 112px;
  height: 184px;
  background: var(--bg);
  display: block;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .preview-label {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  background: #172437dc;
  color: #fff;
  padding: 8px;
  font-size: 12px;
}
.preview-placeholder {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--muted);
}
.preview-placeholder[hidden] {
  display: none;
}
.preview-placeholder::before {
  content: '';
  width: 28px;
  height: 36px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.preview-placeholder::after {
  content: '';
  position: absolute;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
  margin-left: 3px;
}
.item-body {
  min-width: 0;
}
.item-body input[name='title'] {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
  background: transparent;
}
.autosave label {
  margin-bottom: 0;
}
.chips,
.counts,
.item-actions,
.days {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chips {
  margin: 16px 0 8px;
}
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}
.counts {
  font-size: 12px;
  margin-bottom: 16px;
}
.status {
  font-size: 13px;
  font-weight: 650;
}
.ready,
.published {
  color: var(--ok);
}
.failed,
.blocked,
.needs_review,
.attention {
  color: var(--bad);
}
.pending,
.processing,
.publishing {
  color: var(--warn);
}
.paused,
.excluded,
.skipped,
.cancelled {
  color: var(--muted);
}
.item-actions form {
  margin: 0;
}
.item-actions button {
  font-size: 13px;
}
.item-actions {
  align-items: start;
}
.actions-menu {
  flex-basis: 100%;
}
summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 8px 0;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
summary:before {
  content: '▸';
}
details[open] > summary:before {
  content: '▾';
}
.menu-content {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  max-width: 600px;
}
.empty {
  text-align: center;
  padding: 40px 24px;
}
/* Каналы */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr));
  gap: 24px;
  align-items: start;
}
.grid .card {
  margin: 0 0 16px;
}
.login,
.wizard {
  max-width: 560px;
  margin: 64px auto;
}
.preline,
.caption {
  white-space: pre-line;
}
/* Журнал */
.filters {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
}
.filters label {
  margin: 0;
  min-width: 180px;
}
.history-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.history-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.history-result p {
  margin: 0;
}
.history-row time {
  font-size: 14px;
  color: var(--muted);
}
.history-row .item-actions {
  grid-column: 2/-1;
}
.pagination {
  align-items: center;
  justify-content: center;
  margin: 24px;
}
/* Настройки */
.members {
  margin-top: 24px;
}
.member {
  padding: 16px 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.disk-stats {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}
.disk-stats strong {
  display: block;
  font-size: 24px;
  margin-top: 8px;
}
/* Прогресс загрузки */
.upload-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.upload-row progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}
.upload-row p {
  flex: 1;
  margin: 0;
  min-width: 0;
}
.upload-row .upload-detail {
  flex-basis: 100%;
  font-size: 13px;
  color: var(--muted);
}
/* Плеер и обратная связь */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(500px, calc(100% - 32px));
  padding: 16px;
}
dialog::backdrop {
  background: #000a;
}
dialog video {
  display: block;
  max-height: 75vh;
  width: 100%;
  margin-top: 16px;
}
dialog button {
  display: block;
  margin-left: auto;
}
footer {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
#feedback:not(:empty) {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: 16px;
  margin: auto;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  z-index: 10;
}
.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.htmx-indicator {
  opacity: 0;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
.sortable-ghost {
  opacity: 0.4;
}
.recent {
  margin-top: 32px;
}
/* Тёмная тема */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111924;
    --surface: #1a2533;
    --text: #e8edf6;
    --muted: #abb8cc;
    --line: #34445b;
    --accent: #729cff;
    --ok: #72d5a4;
    --warn: #f2c365;
    --bad: #ff8c99;
  }
  .primary {
    color: #111924;
  }
}
/* Адаптив */
@media (max-width: 640px) {
  header {
    padding: 16px;
    gap: 12px;
  }
  .brand {
    font-size: 20px;
  }
  .company {
    font-size: 14px;
  }
  .account {
    margin-left: 0;
    justify-content: space-between;
    width: 100%;
    font-size: 14px;
  }
  header nav {
    width: 100%;
    gap: 0;
    justify-content: space-between;
    order: 3;
  }
  header nav a {
    padding: 12px 8px;
    font-size: 14px;
  }
  main {
    padding: 0 16px;
    margin: 24px auto;
  }
  h1 {
    font-size: 28px;
  }
  .card {
    padding: 16px;
  }
  .queue-item,
  .queue-item:not(:has(.drag-handle)) {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }
  .thumb {
    width: 64px;
    height: 112px;
  }
  .thumb .preview-label {
    font-size: 10px;
    padding: 4px;
  }
  .drag-handle {
    display: none;
  }
  .item-body input[name='title'] {
    font-size: 16px;
  }
  .item-body .item-actions {
    margin-left: -76px;
  }
  .item-body .actions-menu {
    padding-left: 0;
  }
  .grid {
    gap: 16px;
  }
  .history-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .history-row .item-actions {
    grid-column: auto;
  }
  .member {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .login,
  .wizard {
    margin: 24px auto;
  }
  .disk-stats {
    gap: 24px;
  }
  .filters {
    align-items: stretch;
  }
  .filters label {
    min-width: 0;
    width: 100%;
  }
  .page-heading {
    align-items: start;
  }
  .strip {
    gap: 0;
  }
  .days {
    gap: 4px;
  }
  .days .check {
    padding: 0 4px;
  }
  .company form {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button,
  .button {
    transition:
      border-color 0.15s ease,
      background-color 0.15s ease;
  }
}

.history-thumb {
  float: left;
  width: 48px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  margin: 0 12px 8px 0;
}
.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
main a,
.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
