:root {
  --bg: #0a0a0a;
  --card: #141414;
  --card-2: #1d1d1d;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #8f8f8f;
  --accent: #1ED760;
  --accent-dim: #169c42;
  --warn: #ff9f0a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: linear-gradient(180deg, #151515, #0a0a0a);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
  text-align: center;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand .logo { width: 36px; height: 36px; border-radius: 8px; }
.topbar h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.sub { margin: 6px 0 0; color: var(--muted); }

main { padding: 28px 0 80px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.form-card { margin-bottom: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 0.85rem; color: var(--muted); }

input, select, textarea {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 48px; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.row { display: flex; gap: 16px; }
/* min-width:0 — иначе min-width:auto у flex-айтема не даёт селектам
   сжаться под длинные опции, и ряд выпирает за карточку. */
.row .field { flex: 1; min-width: 0; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .05s, border-color .15s;
  text-decoration: none;
  display: inline-block;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #052b12; width: 100%; }
.btn.primary:hover { background: #25e96b; }
.btn.ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent-dim); }
.btn.small { padding: 7px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions-grid { display: flex; flex-direction: column; gap: 10px; }
.actions-row { display: flex; gap: 10px; }
.actions-row .btn { flex: 1; }
.hint { margin: 10px 0 0; font-size: 0.8rem; }

.history h2 { font-size: 1.15rem; margin: 0 0 14px; }
.jobs { display: flex; flex-direction: column; gap: 12px; }

.job {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  transition: border-color .15s;
}
.job:hover { border-color: var(--accent-dim); }
.job .thumb {
  width: 96px; height: 54px; border-radius: 8px; object-fit: cover;
  background: var(--card-2); flex-shrink: 0;
}
.job .info { flex: 1; min-width: 0; }
.job .title {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job .meta { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
}
.badge.queued, .badge.downloading, .badge.transcribing { background: #1d3324; color: #7ee2a0; }
.badge.done { background: #14351f; color: var(--accent); }
.badge.error { background: #3a1a1a; color: #ff6b60; }

.progress { height: 6px; background: var(--card-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }

.warn-box {
  background: #3a2e12; color: var(--warn); border: 1px solid #5a4a1a;
  border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 0.9rem;
}
.muted { color: var(--muted); }
.error { color: #ff6b60; font-size: 0.88rem; }
.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1d1d1d; color: var(--text); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 18px; font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 60; max-width: 90vw;
}

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 760px; width: 100%;
  padding: 24px; position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 1.2rem; cursor: pointer;
}
.modal h3 { margin: 0 30px 8px 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }

.transcript {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; max-height: 320px; overflow-y: auto; white-space: pre-wrap;
  font-size: 0.9rem; margin-top: 8px;
}
.llm-box { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.llm-box textarea {
  width: 100%; background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 12px; font-size: 0.9rem;
  resize: vertical; min-height: 70px;
}
.llm-output {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-top: 12px; white-space: pre-wrap; font-size: 0.92rem;
}
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted);
  border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .row { flex-direction: column; gap: 0; }
  .actions-row { flex-direction: column; }
  .job .thumb { width: 72px; height: 40px; }
}
