:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #14202b;
  --muted: #5d6c7b;
  --line: #dce3ea;
  --hover: #eef2f6;
  --accent: #0b6e8a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f5;
  --ok: #1f7a4d;
  --warn: #8f5b00;
  --err: #b3261e;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141a;
    --panel: #151d25;
    --ink: #e4ebf2;
    --muted: #91a2b2;
    --line: #26323e;
    --hover: #1b2631;
    --accent: #4fb5d0;
    --accent-ink: #062530;
    --accent-soft: #17313b;
    --ok: #5cc28f;
    --warn: #e0a84a;
    --err: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input { font: inherit; color: inherit; }

.muted { color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- bar */
.bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.brand span { font-weight: 400; color: var(--muted); }
.bar .root { font-family: var(--mono); font-size: 13px; }
.bar .spacer { flex: 1; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 550;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); filter: none; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn:focus-visible, .node:focus-visible, .caret:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100% - 57px);
}

.tree {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 8px 24px;
  overflow: auto;
}
.tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree > ul { padding-left: 0; }
.row { display: flex; align-items: center; gap: 2px; }
.caret {
  width: 22px; height: 26px; flex: none;
  border: 0; background: none; color: var(--muted); cursor: pointer;
  border-radius: 4px; font-size: 11px;
}
.caret.leaf { visibility: hidden; }
.node {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px;
  border: 1px solid transparent; border-radius: 6px;
  background: none; cursor: pointer; text-align: left;
}
.node .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.node:hover { background: var(--hover); }
.node.selected { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.node.over { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }

.pane { padding: 20px 28px 48px; min-width: 0; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 14px; }
.crumbs button { border: 0; background: none; padding: 2px 4px; border-radius: 4px; cursor: pointer; color: var(--accent); }
.crumbs button:hover { background: var(--hover); }
.crumbs .sep { color: var(--muted); }
.crumbs .here { font-weight: 650; padding: 2px 4px; }

/* ---------------------------------------------------------------- drop zone */
.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 28px 24px;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-title { font-size: 18px; font-weight: 650; margin: 0 0 4px; }
.drop p { margin: 0; }
.drop .target { font-family: var(--mono); font-size: 14px; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }

.newfolder { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.newfolder[hidden] { display: none; }
.newfolder input {
  width: min(280px, 100%);
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.note { min-height: 20px; margin-top: 8px; font-size: 13px; }
.note.err { color: var(--err); }

/* ---------------------------------------------------------------- queue */
.queue-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 8px; }
.queue-head[hidden] { display: none; }
.queue { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.queue:empty { display: none; }
.job { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.job:first-child { border-top: 0; }
.job .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .where { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .status { font-size: 13px; text-align: right; white-space: nowrap; }
.job .status.ok { color: var(--ok); }
.job .status.warn { color: var(--warn); }
.job .status.err { color: var(--err); }
.job .side { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.meter { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--hover); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.job.done .meter > i { background: var(--ok); }

/* ---------------------------------------------------------------- listing */
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 8px; font-weight: 600; }
.listing { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.listing td { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.listing tr:first-child td { border-top: 0; }
.listing td.name { width: 100%; word-break: break-all; }
.listing td.num { text-align: right; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.listing tr.dir td.name button { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 550; text-align: left; }
.listing tr.dir td.name button::before { content: "▸ "; color: var(--muted); }
.listing tr.fresh td { background: var(--accent-soft); }
.empty { padding: 18px; text-align: center; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------------------------------------------------------------- login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form {
  width: min(360px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 24px;
}
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login input {
  width: 100%; padding: 9px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.login .btn { width: 100%; justify-content: center; padding: 9px 14px; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  .bar { padding: 10px 16px; gap: 10px; }
  .bar .root { display: none; }
  .layout { grid-template-columns: 1fr; }
  .tree { border-right: 0; border-bottom: 1px solid var(--line); max-height: 38vh; }
  .pane { padding: 16px 16px 40px; }
  .listing td.num.date { display: none; }
}
