:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1b1b1a;
  --muted: #6b6a66;
  --line: #e3e1db;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --ok: #1a7f4b;
  --err: #c2341d;
  --warn-bg: #fff6e0;
  --bar-bg: #ebe9e3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --card: #1c1c1b;
    --text: #ecebe8;
    --muted: #9b9a95;
    --line: #2e2e2c;
    --accent: #5b8cff;
    --accent-text: #0b0b0b;
    --ok: #4cc38a;
    --err: #ff7a62;
    --warn-bg: #2b2414;
    --bar-bg: #2a2a28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --card: #1c1c1b; --text: #ecebe8; --muted: #9b9a95; --line: #2e2e2c;
  --accent: #5b8cff; --accent-text: #0b0b0b; --ok: #4cc38a; --err: #ff7a62; --warn-bg: #2b2414; --bar-bg: #2a2a28;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 20px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.notice { background: var(--warn-bg); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input:not([type=file]), textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
input:focus, textarea:focus, button:focus-visible, #drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.error { color: var(--err); margin: 10px 0 0; }

#drop {
  border: 2px dashed var(--line); border-radius: 10px; padding: 26px 16px; text-align: center; margin-top: 4px;
  transition: border-color .15s, background .15s;
}
#drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
#drop p { margin: 0 0 6px; }
#drop .row { margin-top: 12px; }

.bar { height: 8px; background: var(--bar-bg); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#overall { margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.stats div { display: flex; flex-direction: column; }
.stats .label { font-size: 12px; color: var(--muted); }
.stats span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }

#files { list-style: none; margin: 16px 0 0; padding: 0; max-height: 420px; overflow: auto; }
#files li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
#files .name { display: flex; justify-content: space-between; gap: 10px; }
#files .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#files .state { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
#files .state.ok { color: var(--ok); }
#files .state.err { color: var(--err); }
#files .bar { height: 4px; margin-top: 5px; }
#files li.more { color: var(--muted); }

.done h2 { color: var(--ok); }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* ---------------------------------------------------------------- Browse + share pages */
main.wide { max-width: 1080px; }
.narrow { max-width: 420px; }
.card.flush { padding: 0; overflow: hidden; }
.pad { padding: 12px 16px; margin: 0; }
.row.end { justify-content: flex-end; margin-top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { font-size: 12px; }
select { display: block; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
button.small, a.button.small { padding: 4px 10px; font-size: 13px; }
a.button { display: inline-block; text-decoration: none; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--card); }
button.danger { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); border: 1px solid var(--line); font-weight: 600; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { margin: 0; width: 220px; padding: 6px 10px; }
#crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
#crumbs .sep { color: var(--muted); }
#crumbs .crumb[aria-current] { color: var(--text); font-weight: 600; }
.selbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: color-mix(in srgb, var(--accent) 8%, var(--card)); border-bottom: 1px solid var(--line); font-size: 14px; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
table.list th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--line); }
table.list td { padding: 7px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
table.list .check { width: 44px; padding-right: 0; }
table.list .num { width: 100px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .date { width: 190px; white-space: nowrap; color: var(--muted); }
table.list .actions { width: 190px; text-align: right; }
table.list .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; text-align: left; }
table.list td.name { display: table-cell; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 28px 16px; text-align: center; margin: 0; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); padding: 20px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .35); }

@media (max-width: 640px) {
  table.list .date { display: none; }
  table.list .num { width: 76px; }
  table.list .actions { width: 96px; }
  .row-actions { flex-direction: column; align-items: flex-end; }
  .toolbar input[type=search] { width: 100%; }
  .toolbar > .row { width: 100%; flex-wrap: nowrap; }
}
.notice-inline { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
