:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --fg: #16181d;
  --muted: #6b7280;
  --accent: #2f6bff;
  --accent-fg: #ffffff;
  --ok: #12855a;
  --err: #c4314b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --border: #262d38;
    --fg: #e6edf3;
    --muted: #8b949e;
    --accent: #4d82ff;
    --ok: #3fb950;
    --err: #ff7b72;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding: 40px 16px 64px;
}

.shell { width: 100%; max-width: 780px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: -0.01em; }
.sub { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login h1 { font-size: 19px; }

.code-input {
  width: 100%;
  margin: 20px 0 12px;
  padding: 14px 16px;
  font: 600 26px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.55em;
  text-align: center;
  text-transform: uppercase;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.code-input::placeholder { letter-spacing: 0.55em; color: var(--muted); opacity: 0.5; }
.code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

button:disabled { opacity: 0.55; cursor: progress; }

.primary {
  width: 100%;
  padding: 11px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.primary:hover:not(:disabled) { filter: brightness(1.07); }

.ghost {
  padding: 7px 12px;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-size: 13px;
}
.ghost:hover { color: var(--fg); border-color: var(--fg); }

.error { color: var(--err); font-size: 13px; margin: 4px 0 0; min-height: 18px; }

/* ---------- uploader ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.dropzone:hover { border-color: var(--accent); color: var(--fg); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--fg);
}
.dropzone svg { color: var(--accent); }
.dz-title { margin: 10px 0 2px; font-weight: 600; color: var(--fg); }
.dz-hint { margin: 0; font-size: 13px; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.summary { margin-top: 20px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 7px; }
.muted { color: var(--muted); }

.bar { height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.18s linear; }

.queue { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  background: color-mix(in srgb, var(--fg) 1.5%, var(--surface));
}

.item-head { display: flex; align-items: baseline; gap: 10px; }
.item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 550;
}
.item-meta { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.item[data-status="checking"] .badge { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.item[data-status="uploading"] .badge { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.item[data-status="done"] .badge { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.item[data-status="duplicate"] .badge { color: var(--muted); border-color: color-mix(in srgb, var(--muted) 45%, transparent); }
.item[data-status="error"] .badge { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }

.item .bar { margin-top: 9px; height: 5px; }
.item[data-status="done"] .bar-fill { background: var(--ok); }
.item[data-status="error"] .bar-fill { background: var(--err); }

.item-error { margin: 7px 0 0; font-size: 12.5px; color: var(--err); }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.tag {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retry {
  margin-top: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.retry:hover { border-color: var(--accent); color: var(--accent); }

.empty { margin: 16px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.22s ease-out;
}
.toast.error { border-left-color: var(--err); }
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
.toast-icon { color: var(--ok); font-weight: 700; line-height: 1.3; }
.toast.error .toast-icon { color: var(--err); }
.toast-body { min-width: 0; }
.toast-title { font-weight: 600; }
.toast-detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.leaving { animation: none; }
  .bar-fill { transition: none; }
}

.item[data-status="duplicate"] .bar-fill { background: var(--muted); }
