:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --card: #fff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #2f6fed;
  --danger: #d63b3b;
  --ok: #2e8b57;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --card: #1c1c1f;
    --fg: #ececf0;
    --muted: #9a9aa3;
    --line: #2c2c31;
    --accent: #5b8cff;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
code { font-size: .9em; background: var(--line); padding: 0 .3em; border-radius: 3px; }
[hidden] { display: none !important; }

header {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; color: var(--fg); }
#crumbs { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.spacer { flex: 1; }

main { max-width: 1000px; margin: 0 auto; padding: 1rem; }

button, header a.ghost {
  font: inherit; cursor: pointer;
  padding: .3rem .7rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent); color: #fff;
}
button.ghost, header a.ghost { background: transparent; color: var(--accent); }
button:hover { filter: brightness(1.1); }

input, textarea, select {
  width: 100%;
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg); color: var(--fg);
}
label { display: block; margin: .6rem 0; color: var(--muted); font-size: .9em; }
label > input, label > textarea, label > select { margin-top: .25rem; color: var(--fg); font-size: 15px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.narrow { max-width: 360px; margin: 15vh auto; display: grid; gap: .75rem; }
.hint { color: var(--muted); font-size: .88em; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.row { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

#status { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
#status dt { color: var(--muted); }
#status dd { margin: 0; word-break: break-all; }

#files, #trash-files { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
#files li, #trash-files li {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .9rem;
  border-bottom: 1px solid var(--line);
}
#files li:last-child, #trash-files li:last-child { border-bottom: 0; }
#files li.empty { color: var(--muted); justify-content: center; }
#files .name, #trash-files .name { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; color: var(--fg); }
#files .name > span:last-child, #trash-files .name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#files img, #files .icon, #trash-files .icon { width: 48px; height: 32px; flex: none; object-fit: cover; border-radius: 4px; text-align: center; font-size: 22px; line-height: 32px; }
#files .meta, #trash-files .meta { color: var(--muted); font-size: .85em; white-space: nowrap; }
#files .actions, #trash-files .actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
#files .actions button, #trash-files .actions button { padding: .15rem .5rem; font-size: .85em; }
#btn-more { display: block; margin: 1rem auto; }

@media (max-width: 640px) {
  #files li, #trash-files li { flex-wrap: wrap; }
  #files .actions, #trash-files .actions { width: 100%; justify-content: flex-start; }
}

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card); color: var(--fg);
  padding: 1rem;
  width: min(560px, 92vw);
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
#player { width: min(1100px, 96vw); padding: .5rem; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0 .25rem .5rem; }
#player-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#video { width: 100%; max-height: 80vh; background: #000; border-radius: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  max-width: 90vw;
  padding: .6rem 1rem;
  border-radius: 8px;
  background: rgb(0 0 0 / .85); color: #fff;
}

button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
#ops { width: min(360px, 92vw); }
#ops h3 { margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-list { display: grid; gap: .5rem; }
.picker-path { color: var(--muted); margin-bottom: .5rem; word-break: break-all; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.picker-list li { padding: .45rem .7rem; border-bottom: 1px solid var(--line); }
.picker-list li:last-child { border-bottom: 0; }
.picker-list li.hint { color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
