:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #ff4d4d;
  --accent-hover: #ff6b6b;
  --success: #3fb950;
  --warn: #d29922;
}

* { box-sizing: border-box; }

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

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 2rem;
  background: linear-gradient(90deg, #ff4d4d, #ff8a4d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--muted);
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

code { font-family: ui-monospace, "Cascadia Code", monospace; color: var(--accent); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.card h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.85rem;
  line-height: 1.4;
}

input[type="text"], input[type="url"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.muted-inline { color: var(--muted); font-size: 0.85rem; }

.grid-2, .grid-3 {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.6rem;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

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

.field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.preview-box {
  margin-top: 0.85rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
}
.preview-box img, .preview-box video {
  max-width: 100%;
  max-height: 280px;
  border-radius: 6px;
}

.primary, .ghost {
  border: none;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  font-family: inherit;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 1rem;
}
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:active:not(:disabled) { transform: scale(0.98); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

.status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid var(--warn);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.status.error { background: rgba(255, 77, 77, 0.1); border-color: var(--accent); }
.status.done { background: rgba(63, 185, 80, 0.1); border-color: var(--success); }
.status.warn { background: rgba(210, 153, 34, 0.15); border-color: var(--warn); }

.result {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.result h3 { margin: 0; align-self: flex-start; }
.result video {
  width: 100%;
  max-height: 480px;
  border-radius: 10px;
  background: #000;
}

.download {
  background: var(--success);
  color: white;
  text-decoration: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  align-self: flex-start;
}
.download:hover { opacity: 0.9; }

.raw {
  width: 100%;
  margin-top: 0.5rem;
}
.raw summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}
.raw pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.75rem;
  overflow-x: auto;
  max-height: 300px;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 600px) {
  header h1 { font-size: 1.5rem; }
  .card { padding: 1rem; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}


/* ─── Dropzone & Advanced toggle ────────────────────────────────────────── */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, min-height 0.15s;
  margin-bottom: 0.6rem;
}
.dropzone:hover, .dropzone.dragging {
  border-color: var(--accent);
  background: rgba(255, 77, 77, 0.05);
}
.dropzone.compact {
  min-height: 60px;
}
.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.dz-icon { font-size: 1.75rem; }

.preview-box {
  position: relative;
}
.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.875rem;
  z-index: 2;
}
.remove-btn:hover { background: rgba(255, 77, 77, 0.9); }

.advanced {
  margin-top: 0.5rem;
  padding: 0.5rem 0;
}
.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  user-select: none;
}
.advanced summary:hover { color: var(--accent); }


/* ─── Multi-account ─────────────────────────────────────────────────────── */

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.card-head h2 { margin: 0; }

.account-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.empty-accounts {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.account-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.account-row:hover { border-color: var(--accent); }
.account-row.active {
  border-color: var(--accent);
  background: rgba(255, 77, 77, 0.06);
}
.account-row.expired { opacity: 0.55; }

.acc-radio input { accent-color: var(--accent); cursor: pointer; }
.acc-info { min-width: 0; }
.acc-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.acc-meta .dot { color: var(--border); }
.acc-meta .exp-ok { color: var(--success); }
.acc-meta .exp-bad { color: var(--accent); font-weight: 600; }
.acc-meta code {
  background: var(--card);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--muted);
}

.acc-actions { display: flex; gap: 0.3rem; }
.ghost.small { padding: 0.3rem 0.55rem; font-size: 0.8rem; }
.ghost.danger:hover { border-color: var(--accent); color: var(--accent); }
.primary.small { width: auto; padding: 0.55rem 1rem; font-size: 0.9rem; }


/* ─── Admin stats & banner ──────────────────────────────────────────────── */

.banner {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid var(--warn);
  font-size: 0.9rem;
  text-align: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}
.stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
.stat-num.good { color: var(--success); }
.stat-num.bad { color: var(--accent); }
.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.2rem;
}

@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* Old user-app account list reused by admin: tweak grid to be 2-column */
.account-list .account-row {
  grid-template-columns: 1fr auto;
}
