:root {
  --bg: #0f1115;
  --panel: #191d24;
  --panel-2: #21262f;
  --border: #2b323d;
  --text: #e7ebf0;
  --muted: #8b95a3;
  --accent: #4f8cff;
  --accent-2: #3a6fd6;
  --error: #ff6b6b;
  --ok: #43c07a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view { min-height: 100dvh; }
.center { display: grid; place-items: center; padding: 24px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.brand { font-weight: 600; }

#app-view {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }

input[type="text"],
input[type="password"],
input[type="url"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease;
}
button:hover, .button:hover { background: var(--accent-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 500;
}
button.ghost:hover { background: var(--panel-2); color: var(--text); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--error); margin: 0; font-size: 14px; }

.options {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}
.options legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.options .row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}
.options .row span:first-child { width: 88px; }
.options .row input[type="range"] { flex: 1; accent-color: var(--accent); }
.options .row output { width: 64px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.options .check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.options .check input { width: 18px; height: 18px; accent-color: var(--accent); }

.statusline { display: flex; justify-content: space-between; align-items: baseline; }
.bar { height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
.log {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  white-space: pre-wrap;
}

.videos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.videos figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.videos figcaption { color: var(--muted); font-size: 13px; }
.videos video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}

@media (max-width: 560px) {
  .videos { grid-template-columns: 1fr; }
  .options .row span:first-child { width: 72px; }
}

/* ---- link input row ---- */
.url-row { display: flex; gap: 8px; align-items: stretch; }
.url-row input { flex: 1; }
.url-row .ghost { white-space: nowrap; padding: 11px 12px; }

/* ---- toggle switches ---- */
.options { gap: 4px; }
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 6px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  flex-direction: row;
  font-weight: 500;
}
.toggle:hover { background: var(--panel-2); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #3a4150;
  transition: background 0.15s ease;
}
.toggle .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle .tlabel { flex: 1; }

/* ---- output filename ---- */
.fname-row { display: flex; align-items: center; gap: 8px; }
.fname-row input { flex: 1; }
.fname-row .ext { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- multi-link textarea ---- */
textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  width: 100%;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row-btns { display: flex; align-items: center; gap: 8px; }
.row-btns .ghost { padding: 8px 12px; }
.row-btns #link-count { margin-left: auto; }

/* ---- batch actions + results list ---- */
.batch-actions { display: flex; gap: 8px; }
.batch-actions button { padding: 8px 12px; font-size: 14px; }

#items { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 150px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.item-status { font-size: 13px; white-space: nowrap; }
.item-status.err { color: var(--error); }
.item-status.ok { color: var(--ok); }
.item-name {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  min-width: 0;
}
.item-size { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-dl {
  color: #fff; background: var(--accent); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.item-dl[hidden] { display: none; }
.logwrap { margin-top: 6px; }
.logwrap summary { cursor: pointer; }

@media (max-width: 560px) {
  .item { grid-template-columns: 1fr auto; grid-auto-rows: auto; }
  .item-name { grid-column: 1 / -1; }
}
