:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2733;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #ff4d4f;
  --accent-hover: #ff6b6d;
  --ok: #2ea043;
  --error: #f85149;
  --radius: 10px;
  --shadow: 0 4px 14px rgba(0,0,0,.35);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #57606a;
  --shadow: 0 4px 14px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

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

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

.muted { color: var(--muted); }
.hidden { display: none !important; }

body.centered {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(360px, 100%);
  text-align: center;
}
.login-card h1 { margin: 8px 0 4px; }
.login-card .hero {
  display: block;
  width: 200px;
  height: 200px;
  max-width: 60vw;
  max-height: 60vw;
  margin: 0 auto 6px;
  border-radius: 16px;
  object-fit: cover;
}
.login-card form { text-align: left; margin-top: 14px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text);
  text-decoration: none;
}
.topbar .brand:hover { color: var(--accent); text-decoration: none; }
.topbar .brand img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}
@media (max-width: 480px) {
  .topbar .brand span { display: none; }
}
.topbar nav { display: flex; gap: 14px; align-items: center; }
.topbar nav button {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.topbar nav button:hover { background: var(--surface-2); }

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h1, .card h2 { margin: 0 0 12px; }

/* ---------- step indicator ---------- */
.steps {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.steps li {
  flex: 1;
  padding: 14px 12px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color .2s, color .2s;
}
.steps li:last-child { border-right: 0; }
.steps li .num {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border);
}
.steps li.done { color: var(--text); }
.steps li.done .num { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps li.active { color: var(--text); background: rgba(255,77,79,.1); }
.steps li.active .num { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- forms ---------- */
form > * + * { margin-top: 12px; }
label { display: block; font-size: 13px; color: var(--muted); }
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }

input[type="text"], input[type="url"], input[type="password"], select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

button, .btn-primary {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: inline-block;
  text-align: center;
}
button:hover { background: var(--border); }
button:disabled { opacity: .55; cursor: progress; }
button.primary, .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover, .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}
button.danger { background: transparent; color: var(--error); border-color: var(--error); }
button.danger:hover { background: var(--error); color: #fff; }

.row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.row > input { flex: 1 1 220px; }
.row > button { white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 540px) { .grid-2 { grid-template-columns: 1fr; } }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248,81,73,.15);
  border: 1px solid var(--error);
  color: var(--text);
  margin-top: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.alert.ok { background: rgba(46,160,67,.15); border-color: var(--ok); }

.warning {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(251, 188, 5, .12);
  border: 1px solid #fbbc05;
  color: var(--text);
  line-height: 1.45;
}
.warning strong { color: #fbbc05; }
.warning .actions { margin-top: 12px; }

/* ---------- step 1: search results ---------- */
.search-results {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}
.search-results li {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.search-results li.loading,
.search-results li.muted,
.search-results li.alert { display: block; }
.search-results img {
  width: 168px;
  height: 94px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.search-results .meta { min-width: 0; }
.search-results .title {
  font-weight: 600;
  word-break: break-word;
  margin-bottom: 4px;
}
.search-results .actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.search-results button { padding: 6px 12px; font-size: 13px; }
.preview-wrap { margin-top: 10px; }
.preview-wrap iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 6px;
  display: block;
  background: #000;
}
@media (max-width: 540px) {
  .search-results li { grid-template-columns: 1fr; }
  .search-results img { width: 100%; height: auto; aspect-ratio: 16/9; }
}

/* ---------- step 2 / 3: selected panel ---------- */
.selected {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.selected img {
  width: 140px;
  height: 79px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg);
}
.selected-meta { min-width: 0; flex: 1; }
.selected .title {
  font-weight: 600;
  word-break: break-word;
  margin-bottom: 4px;
}
@media (max-width: 540px) {
  .selected { flex-direction: column; }
  .selected img { width: 100%; height: auto; aspect-ratio: 16/9; }
}

/* ---------- step 3: progress ---------- */
.bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 6px;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .3s ease;
}
.bar-fill.done { background: var(--ok); }
.bar-fill.error { background: var(--error); }

/* ---------- shared ---------- */
.actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------- admin table ---------- */
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.users input[type="password"] { width: auto; display: inline-block; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline > * + * { margin-top: 0; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: 100%; }
  table.users tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.users td { border: none; padding: 4px 0; }
}
