@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --bg:       #0e0e0e;
  --surface:  #161616;
  --surface2: #1e1e1e;
  --border:   #2a2a2a;
  --border2:  #333;

  --text:     #e2e2e2;
  --muted:    #777;
  --dim:      #444;

  --blue:     #4f8ef7;
  --green:    #3fb950;
  --red:      #f85149;
  --yellow:   #d29922;

  --r:        6px;
  --tr:       .15s ease;
}

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

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 16px 64px;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.wordmark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: var(--text);
}

.wordmark span {
  color: var(--blue);
}

.header-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-links a,
.header-links button {
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: color var(--tr);
  padding: 0;
}
.header-links a:hover,
.header-links button:hover { color: var(--text); }

/* ── Input block ─────────────────────────────────────────────────────── */
.input-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-row {
  display: flex;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--tr);
}
.input-row:focus-within { border-color: var(--blue); }

#url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  min-width: 0;
}
#url-input::placeholder { color: var(--dim); }

.btn-paste {
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 0 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: color var(--tr), background var(--tr);
  white-space: nowrap;
}
.btn-paste:hover { color: var(--text); background: var(--surface2); }

.btn-go {
  background: var(--blue);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0 20px;
  cursor: pointer;
  transition: opacity var(--tr);
  border-left: 1px solid rgba(0,0,0,.2);
}
.btn-go:hover { opacity: .88; }
.btn-go:disabled { opacity: .4; cursor: not-allowed; }

.input-hint {
  font-size: 12px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* -- Quota bar ---------------------------------------------------------------- */
.quota-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 11px;
}

.quota-item {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
}

.quota-label {
  color: var(--dim);
  white-space: nowrap;
}

.quota-track {
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
  min-width: 40px;
  max-width: 80px;
}

.quota-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width .4s ease;
  width: 100%;
}
.quota-fill.warn  { background: var(--yellow); }
.quota-fill.empty { background: var(--red); }

.quota-text {
  color: var(--muted);
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quota-sep {
  color: var(--border2);
  flex-shrink: 0;
}

.quota-reset {
  color: var(--yellow);
  font-size: 11px;
  white-space: nowrap;
}

/* -- Format list - server merge badge ----------------------------------------- */
.fmt-merge-badge {
  font-size: 10px;
  color: var(--yellow);
  border: 1px solid rgba(210,153,34,.3);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.toggle-batch {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.toggle-batch:hover { color: var(--text); }

/* ── Batch textarea ──────────────────────────────────────────────────── */
#batch-area {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  padding: 12px 14px;
  resize: vertical;
  min-height: 88px;
  outline: none;
  line-height: 1.6;
}
#batch-area::placeholder { color: var(--dim); }
#batch-area:focus { border-color: var(--blue); }

/* ── Turnstile ───────────────────────────────────────────────────────── */
#turnstile-wrap {
  padding: 4px 0;
}

/* ── Divider ─────────────────────────────────────────────────────────── */
.sep {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

/* ── Result panel ────────────────────────────────────────────────────── */
#result-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.media-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.thumb {
  width: 120px;
  height: 68px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.media-meta { flex: 1; min-width: 0; }

.media-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 1px 6px;
  text-transform: capitalize;
}

.clean-tag {
  font-size: 11px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Format list ─────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.fmt-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.fmt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background var(--tr);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.fmt-row:last-child { border-bottom: none; }
.fmt-row:hover { background: var(--surface2); }
.fmt-row.active { background: rgba(79,142,247,.08); }

.fmt-radio {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--tr);
}
.fmt-row.active .fmt-radio {
  border-color: var(--blue);
}
.fmt-radio::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  display: none;
}
.fmt-row.active .fmt-radio::after { display: block; }

.fmt-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.fmt-detail {
  font-size: 12px;
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ── Download button ─────────────────────────────────────────────────── */
#download-btn {
  width: 100%;
  padding: 11px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--tr), background var(--tr);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#download-btn:hover { border-color: var(--blue); background: rgba(79,142,247,.07); }
#download-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Progress ────────────────────────────────────────────────────────── */
#progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.progress-track {
  height: 3px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--blue);
  border-radius: 99px;
  width: 0%;
  transition: width .3s ease;
}
#progress-bar.indeterminate {
  width: 35%;
  animation: indeterminate 1.2s ease-in-out infinite;
}

@keyframes indeterminate {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(350%); }
}

.status-line {
  font-size: 12px;
  color: var(--muted);
}
.status-line.ok  { color: var(--green); }
.status-line.err { color: var(--red); }

/* ── History panel ───────────────────────────────────────────────────── */
.sep-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 28px 0 12px;
}
.sep-label::before,
.sep-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

#history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  gap: 10px;
}

.hist-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.hist-fmt {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  flex-shrink: 0;
}

.hist-dl {
  font-size: 11px;
  color: var(--blue);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
  flex-shrink: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.hist-dl:hover { color: var(--text); }

/* ── Supported platforms footer ──────────────────────────────────────── */
.platforms {
  margin-top: 40px;
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  line-height: 2;
}
.platforms strong { color: var(--muted); font-weight: 500; }

/* ── Site footer ───────────────────────────────────────────────── */
.site-footer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.site-footer a {
  color: var(--dim);
  text-decoration: none;
}
.site-footer a:hover { color: var(--muted); }

/* ── Legal pages ───────────────────────────────────────────────── */
.legal { max-width: 640px; margin: 0 auto; padding: 48px 16px 80px; }
.legal h1 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.legal .meta { font-size: 12px; color: var(--muted); margin-bottom: 32px; }
.legal h2 { font-size: 13px; font-weight: 600; margin: 28px 0 8px; color: var(--text); }
.legal p, .legal li { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 8px; }
.legal ul { padding-left: 18px; }
.legal a { color: var(--blue); text-decoration: none; }
.legal a:hover { text-decoration: underline; }
.legal-nav { font-size: 12px; margin-bottom: 32px; }
.legal-nav a { color: var(--muted); text-decoration: none; }
.legal-nav a:hover { color: var(--text); }

/* ── Utilities ───────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.slide-in {
  animation: slideIn .2s ease forwards;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .thumb { width: 80px; height: 46px; }
  .btn-go { padding: 0 14px; }
}
