:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --field: #ffffff;
  --raised: #ffffff;
  --raised-hover: #f0f2f5;
  --text: #16181d;
  --muted: #6a717d;
  --border: #e2e5ea;
  --border-strong: #cdd2d9;
  --hover: #f0f2f5;
  --accent: #3d63f5;
  --accent-hover: #2f54e6;
  --accent-soft: #e8edff;
  --primary-bg: var(--accent);
  --primary-hover: var(--accent-hover);
  --primary-text: #ffffff;
  --btn-highlight: none;
  --ok: #1d8f51;
  --warn: #b7791f;
  --err: #d23f3f;
  --track: #e9ecf0;
  --done-fill: #d0d4db;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 6%);
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

/* Dark: neutral graphite surfaces, depth from surface steps and 8% hairlines.
   The off-white primary button frees the blue for progress, selection and focus. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141415;
    --panel: #19191b;
    --field: #1e1e20;
    --raised: #232325;
    --raised-hover: #2b2b2e;
    --text: #ededed;
    --muted: #a1a1a6;
    --border: rgb(237 237 237 / 8%);
    --border-strong: rgb(237 237 237 / 16%);
    --hover: #202022;
    --accent: #4f76ff;
    --accent-hover: #6688ff;
    --accent-soft: #1d212e;
    --primary-bg: #ededed;
    --primary-hover: #ffffff;
    --primary-text: #141415;
    --btn-highlight: inset 0 1px 0 rgb(255 255 255 / 6%);
    --ok: #4cc38a;
    --warn: #d9a24a;
    --err: #e5484d;
    --track: #262628;
    --done-fill: #3c3c40;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* One icon set (lucide), one size, one stroke, text-role color */
.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}

/* Figures and paths share one mono face */
.tag, .stats, .job-meta, .crumbs, .files td.size, .files td.date, .field.grow input {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--raised); box-shadow: var(--btn-highlight);
  font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 150ms var(--ease);
}
.btn:hover { background: var(--raised-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-text); font-weight: 500; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost, .btn.icon { box-shadow: none; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.small { height: 28px; padding: 0 8px; font-size: 13px; }
.btn.icon { width: 28px; height: 28px; padding: 0; color: var(--muted); background: transparent; border-color: transparent; }
.btn.icon:hover { color: var(--text); background: var(--hover); }
.btn.danger:hover { color: var(--err); }
.btn.icon + .btn.icon { margin-left: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], input:not([type]), input[type=password], select {
  height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--field); font-size: 14px; min-width: 0;
}
input:focus-visible, select:focus-visible { outline-offset: -1px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.card-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.card p { margin: 0; font-size: 14px; }
.card .field input { height: 40px; padding: 0 12px; font-size: 15px; }
.card .btn.primary { height: 40px; margin-top: 4px; font-size: 15px; }
.card .btn.primary:disabled { opacity: .6; cursor: progress; }
.error { color: var(--err); font-size: 14px; }
.error:empty { display: none; }

/* ---------- layout ---------- */
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; line-height: 1; }
.tag {
  font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px;
}
.top {
  max-width: 980px; height: 64px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-right: -8px; }
main { max-width: 980px; margin: 0 auto; padding: 0 16px 64px; display: flex; flex-direction: column; gap: 16px; }

.drop {
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--panel);
  padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; cursor: default;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.drop .drop-icon { width: 24px; height: 24px; color: var(--muted); margin-bottom: 8px; }
.drop strong { font-size: 16px; font-weight: 500; }
.drop .muted { font-size: 14px; }
.drop .row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
body.dragging .drop { border-color: var(--accent); background: var(--accent-soft); }
body.dragging .drop .drop-icon { color: var(--accent); }

.options { display: flex; gap: 12px 16px; align-items: end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { color: var(--text); }
.field.grow { flex: 1 1 240px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline select { height: 28px; padding: 0 8px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; height: 36px; font-size: 14px; cursor: pointer; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; font-weight: 500; margin: 0; }
.panel-head > .btn.ghost:last-child { margin-right: -8px; }
.spacer { flex: 1; }
.stats { font-size: 12px; color: var(--muted); }
.stats b { color: var(--text); font-weight: 500; }

/* ---------- progress ---------- */
.bar { height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.bar .fill {
  height: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform 200ms var(--ease);
}
.bar.total { height: 2px; border-radius: 0; }

.jobs { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.job:last-child { border-bottom: 0; }
.job-text { min-width: 0; }
.job-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.job-meta { font-size: 12px; color: var(--muted); }
.job-actions { display: flex; gap: 4px; align-items: center; margin-right: -6px; }
.job .bar { grid-column: 1 / -1; margin-top: 8px; }
/* Only rows that are still moving carry the accent */
.job[data-status=done] .fill { background: var(--done-fill); }
.job[data-status=error] .fill { background: var(--err); }
.job[data-status=error] .job-meta { color: var(--err); }
.job[data-status=skipped] .job-meta, .job[data-status=canceled] .job-meta { color: var(--warn); }
.job[data-status=skipped] .bar, .job[data-status=canceled] .bar { opacity: .4; }
.job[data-status=queued] .job-name { color: var(--muted); }

/* ---------- file browser ---------- */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 13px; min-width: 0; }
.crumbs a { padding: 2px 4px; border-radius: 4px; color: var(--muted); }
.crumbs a:hover { color: var(--text); text-decoration: none; background: var(--hover); }
.crumbs .sep { color: var(--muted); }
.crumbs .here { padding: 2px 4px; color: var(--text); }

.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files td { height: 44px; padding: 0 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files tr:hover td { background: var(--hover); }
.files td.name { width: 100%; max-width: 0; }
.entry { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.entry:hover { text-decoration: none; }
.entry:hover .nm { text-decoration: underline; }
.entry .i { color: var(--muted); }
.entry .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry.folder .nm { font-weight: 500; }
.files td.size, .files td.date { color: var(--muted); white-space: nowrap; text-align: right; font-size: 12px; }
.files td.acts { white-space: nowrap; text-align: right; padding: 0 10px 0 8px; }
.empty { padding: 12px 16px; margin: 0; font-size: 14px; }
.more { margin: 12px 16px 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease); pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .top { height: 56px; }
  .drop { padding: 24px 16px; }
  .panel-head { padding: 12px 16px; }
  /* Actions drop to their own row, text aligned with the column */
  .panel-head .spacer { flex-basis: 100%; height: 0; }
  .panel-head > .spacer + .btn.ghost:not([hidden]),
  .panel-head > .spacer + [hidden] + .btn.ghost { margin-left: -8px; }
  .files td { padding: 0 12px; }
  .files td.date { display: none; }
  .files td.acts { padding: 0 6px 0 0; }
}
