/* ===== Токены ============================================== */
:root {
  --bg:        #0e1013;
  --surface:   #161a20;
  --surface-2: #1c222a;
  --border:    #272d37;
  --border-hi: #3a4351;
  --text:      #e6e9ee;
  --muted:     #8b95a5;
  --accent:    #e8a33d;
  --accent-dim:#8a6224;
  --ok:        #4ade80;
  --err:       #f87171;
  --info:      #60a5fa;
  --pause:     #64748b;
  --radius:    10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== Каркас ============================================== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; letter-spacing: -0.01em; color: var(--text);
  background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; font-size: inherit;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(232,163,61,.15);
}
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a { color: var(--muted); padding: 6px 12px; border-radius: 7px; font-size: 14px; }
.topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--surface-2); }

.wrap { max-width: 1060px; margin: 0 auto; padding: 28px 24px 80px; }
.wrap.narrow, .wrap.reader { max-width: 820px; }

h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

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

.backlink { color: var(--muted); font-size: 13.5px; display: inline-block; margin-bottom: 18px; }
.backlink:hover { color: var(--text); text-decoration: none; }

/* ===== Зона загрузки ======================================= */
.dropzone {
  border: 1.5px dashed var(--border-hi); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; background: var(--surface);
}
.dropzone:hover { border-color: var(--accent-dim); background: var(--surface-2); }
.dropzone.drag { border-color: var(--accent); background: rgba(232,163,61,.06); }
.dropzone .icon { font-size: 26px; opacity: .75; margin-bottom: 8px; }
.dropzone .big { font-weight: 550; margin-bottom: 4px; }
.dropzone .small { color: var(--muted); font-size: 13px; }
.dropzone input[type=file] { display: none; }

/* ===== Форма =============================================== */
label.field { display: block; margin-bottom: 18px; }
label.field > .lbl {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
label.field > .lbl .spacer { margin-left: auto; }

textarea, input[type=text] {
  width: 100%; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 14px;
  line-height: 1.5; padding: 11px 13px; resize: vertical;
}
textarea:focus, input[type=text]:focus {
  outline: none; border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(232,163,61,.08);
}
textarea { min-height: 108px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-hi); background: var(--surface-2);
  color: var(--text); border-radius: 8px; padding: 9px 16px;
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, opacity .13s;
}
.btn:hover { background: #232a34; border-color: #4a5566; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #21170a; font-weight: 600; }
.btn.primary:hover { background: #f2b055; border-color: #f2b055; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 5px 9px; font-size: 13px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.danger:hover { border-color: #7f3535; color: var(--err); background: rgba(248,113,113,.08); }

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

/* ===== Прогресс ============================================ */
.bar { position: relative; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: var(--accent); border-radius: 99px; transition: width .4s ease;
}
.bar.ok > i { background: var(--ok); }
.bar.err > i { background: var(--err); }
.bar.idle > i { background: var(--border-hi); }
.bar.paused > i { background: var(--pause); }
.bar.pulse > i {
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.28) 50%, rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  animation: slide 1.3s linear infinite;
}
@keyframes slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- карточка «идёт обработка» --- */
.progress-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 24px 20px;
}
.stepper {
  display: flex; gap: 0; margin-bottom: 22px;
  border-bottom: 1px solid var(--border); padding-bottom: 16px;
}
.stepper .step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); position: relative;
}
.stepper .step + .step::before {
  content: ''; position: absolute; left: -50%; right: calc(100% - 2px);
  top: 5px; height: 1px; background: var(--border);
}
.stepper .step .pip {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-hi); background: var(--bg); z-index: 1;
}
.stepper .step.past { color: #b9c1cd; }
.stepper .step.past .pip { background: var(--ok); border-color: var(--ok); }
.stepper .step.now { color: var(--text); font-weight: 600; }
.stepper .step.now .pip {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(232,163,61,.16);
  animation: breathe 1.6s ease-in-out infinite;
}
.stepper .step.err .pip { background: var(--err); border-color: var(--err); }
@keyframes breathe { 0%,100% { box-shadow: 0 0 0 3px rgba(232,163,61,.12); } 50% { box-shadow: 0 0 0 7px rgba(232,163,61,.05); } }

.progress-main { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.progress-label { font-size: 15px; font-weight: 550; }
.progress-pct {
  margin-left: auto; font-size: 22px; font-weight: 650;
  letter-spacing: -0.02em; color: var(--accent); font-variant-numeric: tabular-nums;
}
.progress-card.failed .progress-pct { color: var(--err); }
.progress-card.paused .progress-pct { color: var(--pause); }
.progress-card.done .progress-pct { color: var(--ok); }
.progress-note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.progress-note.bad { color: #f3b7b7; }

/* ===== Список файлов ======================================= */
.jobs {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.job {
  background: var(--surface); padding: 14px 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
}
.job .name { font-weight: 550; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .meta { grid-column: 1; color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.job .actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.job .barwrap { grid-column: 1 / -1; margin-top: 7px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.run  { color: var(--accent); border-color: var(--accent-dim); background: rgba(232,163,61,.09); }
.badge.done { color: var(--ok);     border-color: #2c6b45; background: rgba(74,222,128,.09); }
.badge.err  { color: var(--err);    border-color: #7f3535; background: rgba(248,113,113,.09); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

/* ===== Окно чтения ========================================= */
.reader-head { margin-bottom: 20px; }
.reader-head h1 { overflow-wrap: anywhere; margin-bottom: 8px; }
.reader-meta {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  color: var(--muted); font-size: 13px;
}

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 16px;
  position: sticky; top: 68px; z-index: 20;
}
.toolbar .spacer { flex: 1; }
.toolbar .search {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px 6px 2px 10px; min-width: 260px;
}
.toolbar .search:focus-within { border-color: var(--accent-dim); }
.toolbar .search .mag { color: var(--muted); font-size: 15px; }
.toolbar .search input {
  border: none; background: none; padding: 6px 4px; width: 100%;
  font-size: 13.5px; color: var(--text);
}
.toolbar .search input:focus { outline: none; box-shadow: none; border: none; }
.toolbar .search .hits {
  color: var(--muted); font-size: 12px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.fontsize { display: flex; gap: 2px; }

.transcript {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 34px;
  font-size: 15.5px; line-height: 1.8;
}
.transcript[data-size="-1"] { font-size: 14px; }
.transcript[data-size="1"]  { font-size: 17px; }
.transcript[data-size="2"]  { font-size: 19px; }
.transcript p { margin: 0 0 1.15em; overflow-wrap: anywhere; }
.transcript p:last-child { margin-bottom: 0; }
.transcript mark {
  background: rgba(232,163,61,.28); color: var(--text);
  border-radius: 3px; padding: 0 1px;
}
.transcript mark.on { background: var(--accent); color: #21170a; }

.next-up {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 20px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.next-up > div:first-child { flex: 1; min-width: 200px; }
.next-up-t { font-weight: 600; font-size: 14px; }
.next-up-s { color: var(--muted); font-size: 13px; }

/* ===== Статья ============================================== */
.doc-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.doc-head .grow { min-width: 0; flex: 1; }
.doc-head h1 { overflow-wrap: anywhere; }

.article {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 34px 38px;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 17px; line-height: 1.72;
}
.article h1 { font-family: var(--sans); font-size: 27px; line-height: 1.25; margin: 0 0 14px; }
.article h2 { font-family: var(--sans); font-size: 19px; margin: 30px 0 10px; }
.article h3 { font-family: var(--sans); font-size: 16px; margin: 24px 0 8px; }
.article p { margin: 0 0 16px; }
.article blockquote {
  margin: 20px 0; padding: 4px 0 4px 18px;
  border-left: 3px solid var(--accent-dim); color: #cfd5de; font-style: italic;
}
.article ul, .article ol { margin: 0 0 16px; padding-left: 24px; }
.article strong { color: #fff; }

.article table {
  width: 100%; border-collapse: collapse; margin: 0 0 20px;
  font-family: var(--sans); font-size: 14.5px;
}
.article th, .article td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left;
  vertical-align: top;
}
.article th { background: var(--surface-2); font-weight: 600; }
.article tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }

/* ASCII-схемы от ИИ — моноширинным и без переносов, со своей горизонтальной
   прокруткой, чтобы сетка не съезжала и не ломала ширину страницы. */
.article pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin: 0 0 20px; overflow-x: auto;
}
.article pre code {
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 13.5px; line-height: 1.5; white-space: pre; color: var(--text);
}

.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--info);
  background: var(--surface); border-radius: 8px; padding: 12px 14px;
  color: var(--muted); font-size: 13.5px; margin-bottom: 18px;
}
.notice.bad { border-left-color: var(--err); color: #f3b7b7; }

.skeleton { color: var(--muted); padding: 40px 0; text-align: center; }

@media (max-width: 680px) {
  .wrap { padding: 20px 14px 60px; }
  .transcript { padding: 22px 18px; }
  .article { padding: 22px 18px; font-size: 16px; }
  .job .actions { grid-row: auto; grid-column: 1 / -1; margin-top: 8px; }
  .toolbar { position: static; }
  .toolbar .search { min-width: 100%; order: -1; }
  .stepper .step { font-size: 0; gap: 0; justify-content: center; }
  .stepper .step.now { font-size: 12px; gap: 8px; flex: 2; }
}
