/* Monetro · Видео → текст — палитра и стиль PostTrack:
   белые поверхности, серые границы, синий акцент, Exo 2. */

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #dbeafe;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee2e2;
  --tg: #229ed9;
  --tg-hover: #1c8dc2;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .1);
  --font: "Exo 2", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
}

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

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
  color: var(--text-primary);
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.wordmark:hover { text-decoration: none; color: var(--text-primary); }
.wordmark .dot { color: var(--accent); }
.wordmark-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.wordmark-big { font-size: 26px; }

.topnav { display: flex; align-items: center; gap: 16px; }
.navlink {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.navlink:hover { color: var(--accent); text-decoration: none; }
.as-button { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.inline-form { display: inline; }

/* ---------- Контейнеры ---------- */

.container { max-width: 960px; margin: 0 auto; padding: 32px 24px 80px; }
/* Страница записи шире: в неё влезают две колонки. */
.container-wide { max-width: 1240px; padding-top: 24px; padding-bottom: 48px; }

.hero { margin: 8px 0 24px; }
.hero h1 {
  font-weight: 700;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -.02em;
  line-height: 1.15;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub { color: var(--text-secondary); margin-top: 8px; max-width: 560px; }

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 4px 0 18px;
}

.crumbs { margin-bottom: 10px; font-size: 13px; }
.crumbs a { color: var(--text-secondary); font-weight: 500; }
.crumbs a:hover { color: var(--accent); }

/* ---------- Карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 { margin-bottom: 0; }
.card-actions { display: flex; gap: 8px; }

.summary-card { border-left: 3px solid var(--accent); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 500 14px var(--font);
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-ghost:hover { background: var(--surface-hover); }

.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger.armed { background: var(--danger); color: #fff; }

.btn-tg { background: var(--tg); color: #fff; }
.btn-tg:hover { background: var(--tg-hover); color: #fff; }

.btn-wide { width: 100%; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }

/* ---------- Формы ---------- */

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-narrow { max-width: 380px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.field small { color: var(--text-muted); font-weight: 400; }
.field input {
  font: 14px var(--font);
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  height: 36px;
  padding: 0 12px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--success-soft); color: var(--success); }

/* ---------- Авторизация ---------- */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  position: relative;
  background:
    radial-gradient(circle at 80% 12%, rgba(34, 211, 238, .3), transparent 30%),
    radial-gradient(circle at 18% 82%, rgba(59, 130, 246, .3), transparent 34%),
    linear-gradient(145deg, #07152f 0%, #102e63 50%, #0b4a70 100%);
}
.auth-layout::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .18;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .15) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom right, black, transparent 82%);
  -webkit-mask-image: linear-gradient(to bottom right, black, transparent 82%);
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px 26px;
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-tag {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 6px;
}
.auth-alt { text-align: center; font-size: 13.5px; color: var(--text-secondary); margin-top: 18px; }
.auth-note {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}
.auth-note-top { margin-top: 0; margin-bottom: 18px; text-align: left; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Дропзона ---------- */

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 38px 24px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color .15s, background .15s, color .15s;
  margin-bottom: 16px;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: #f8fbff;
  color: var(--accent);
  outline: none;
}
.dz-icon { color: var(--accent); margin-bottom: 10px; }
.dz-title { color: var(--text-primary); font-weight: 600; font-size: 16px; }
.dz-title span { color: var(--text-secondary); font-weight: 400; }
.dz-note { font-size: 12.5px; margin-top: 6px; color: var(--text-muted); }

/* ---------- Загрузки ---------- */

.upload-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.upload-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
}
.upload-row .upload-name { font-weight: 600; margin-bottom: 6px; }
.upload-row.upload-error { border-color: var(--danger); color: var(--danger); }
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .2s ease;
}

/* ---------- История ---------- */

.history { margin-top: 30px; }
.history-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.history-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.history-count { color: var(--text-muted); font-size: 13px; }

.jobs-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.jobs-empty { padding: 28px; text-align: center; color: var(--text-secondary); }
.jobs-empty b { display: block; color: var(--text-primary); font-size: 14.5px; margin-bottom: 6px; }
.jobs-empty p { max-width: 460px; margin: 0 auto; font-size: 13px; line-height: 1.55; }

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  transition: background .12s;
}
.job-row:last-child { border-bottom: 0; }
.job-row:hover { background: var(--surface-hover); text-decoration: none; color: inherit; }
.job-row-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.job-row-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-row-sub {
  color: var(--text-muted);
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.job-row-side { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; }
.job-row-summary {
  grid-column: 1;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- Бейджи статусов ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-queued { background: var(--surface-hover); color: var(--text-secondary); }
.badge-processing { background: var(--accent-soft); color: var(--accent-hover); }
.badge-processing::before { animation: pulse 1.1s ease-in-out infinite; }
.badge-done { background: var(--success-soft); color: var(--success); }
.badge-error { background: var(--danger-soft); color: var(--danger); }

@keyframes pulse {
  50% { opacity: .25; transform: scale(.7); }
}

.source-tag {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  align-self: center;
}

/* ---------- Страница задачи ---------- */

.job-head { margin: 0 0 14px; }
.back-link { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.back-link:hover { color: var(--accent); text-decoration: none; }
.job-title {
  font-weight: 700;
  font-size: clamp(17px, 2.2vw, 21px);
  letter-spacing: -.01em;
  line-height: 1.25;
  margin-top: 2px;
  word-break: break-word;
}
.job-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.meta-item { color: var(--text-secondary); font-size: 12.5px; }
.job-delete { margin-left: auto; }

/* Две колонки: слева видео + саммари, справа тексты во вкладках. */
.job-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.job-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 72px; }
.job-side .card, .text-card { margin-bottom: 0; }

.media-card { padding: 12px; }
.media-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.media-note { margin-top: 8px; line-height: 1.5; }
.panel-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.text-card { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; }
.tab {
  font: 600 13px var(--font);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.tab:hover { background: var(--surface-hover); color: var(--text-primary); }
.tab.is-active { background: var(--accent-soft); color: var(--accent-hover); }

.scroll-text {
  max-height: calc(100vh - 260px);
  min-height: 220px;
  overflow-y: auto;
  padding-right: 8px;
}
.scroll-text::-webkit-scrollbar { width: 8px; }
.scroll-text::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.prose {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-primary);
}
.collapsible.clamped {
  max-height: 320px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
  mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.expand-toggle {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--accent);
  font: 600 13.5px var(--font);
  cursor: pointer;
  padding: 0;
}
.expand-toggle:hover { color: var(--accent-hover); }

.media-player {
  display: block;
  width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  background: #000;
  outline: none;
}
.media-audio { background: transparent; }

.processing-card { text-align: center; padding: 40px 24px; }
.processing-card p { margin-top: 12px; font-weight: 500; }
.error-card { border-left: 3px solid var(--danger); }
.error-card h2 { color: var(--danger); }

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Настройки ---------- */

.settings-row { display: flex; align-items: center; gap: 10px; }
.ok-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* ---------- Модалка Telegram ---------- */

.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 24, 39, .5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.modal h3 { font-size: 17px; font-weight: 700; }
.tg-lead { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.tg-steps { text-align: left; padding-left: 20px; color: var(--text-secondary); font-size: 13.5px; }
.tg-steps li { margin: 4px 0; }
.tg-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  user-select: all;
}
.tg-hint { font-size: 12.5px; color: var(--text-secondary); }
.tg-hint code {
  font-size: 12.5px;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 5px;
  user-select: all;
}
.tg-status { font-size: 13.5px; font-weight: 500; color: var(--warning); min-height: 20px; }
.tg-status.ok { color: var(--success); }
.tg-status.err { color: var(--danger); }

/* ---------- Разное ---------- */

.muted { color: var(--text-secondary); }
.small { font-size: 12.5px; }

.reveal { animation: rise .4s ease backwards; }
.reveal:nth-child(2) { animation-delay: .05s; }
.reveal:nth-child(3) { animation-delay: .1s; }
.reveal:nth-child(4) { animation-delay: .15s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 900px) {
  .job-grid { grid-template-columns: 1fr; }
  .job-side { position: static; }
  .scroll-text { max-height: 60vh; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 16px; }
  .wordmark-sub { display: none; }
  .container { padding: 22px 16px 60px; }
  .card { padding: 16px; }
  .job-row { grid-template-columns: 1fr; }
  .job-row-side { grid-row: auto; grid-column: 1; margin-top: 4px; }
  .job-delete { margin-left: 0; }
  .card-head { align-items: flex-start; }
}
