:root {
  --bg: #111216; --panel: #181a20; --panel2: #1f222a; --line: #2a2e38; --text: #e7e9ee; --muted: #8d93a3;
  --accent: #7c5cff; --accent2: #9b84ff; --danger: #ff5c72; --ok: #3ecf8e; --radius: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f8; --panel: #ffffff; --panel2: #f0f1f5; --line: #dfe2ea; --text: #16181d; --muted: #6a7080;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent2); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; }
button.icon { padding: 0 8px; line-height: 22px; }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=search], input[type=email], textarea, select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #2fc3ff); }
img.logo { background: none; object-fit: contain; border-radius: 0; }
#search { max-width: 460px; }
.spacer { flex: 1; }
.me { color: var(--muted); font-size: 12px; white-space: nowrap; }
.layout { flex: 1; display: flex; min-height: 0; }
.side { width: 250px; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; flex-shrink: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tree { padding: 0 6px 20px; }
.node { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.node:hover { background: var(--panel2); }
.node.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.node.dragover { outline: 2px dashed var(--accent); }
.node .tw { width: 14px; color: var(--muted); text-align: center; font-size: 10px; flex-shrink: 0; }
.node .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .ct { color: var(--muted); font-size: 11px; }
.children { margin-left: 12px; }
.main { flex: 1; overflow: auto; position: relative; padding: 0 18px 40px; min-width: 0; }
.toolbar { position: sticky; top: 0; z-index: 2; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 12px 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.crumbs a:hover { background: var(--panel2); }
.crumbs .sep { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.card:hover { border-color: var(--accent); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card .th { aspect-ratio: 1; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 40px; overflow: hidden; }
.card .th img { width: 100%; height: 100%; object-fit: cover; }
.card .meta { padding: 8px 10px; }
.card .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.folder .th { aspect-ratio: auto; height: 70px; font-size: 32px; }
.card.folder.dragover { outline: 2px dashed var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.drop { position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 20%, transparent); border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 20px; z-index: 50; pointer-events: none; }
.drop div { background: var(--panel); padding: 18px 28px; border-radius: 12px; }
.uploads { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.up { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.up .bar { height: 4px; background: var(--panel2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.up .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.up.err { border-color: var(--danger); }
.detail { width: 340px; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; padding: 16px; flex-shrink: 0; }
.detail .th { aspect-ratio: 1; background: var(--panel2); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 60px; cursor: pointer; position: relative; }
.detail .th img { width: 100%; height: 100%; object-fit: contain; }
.detail .th .hint { position: absolute; bottom: 6px; font-size: 11px; background: #000a; color: #fff; padding: 2px 8px; border-radius: 10px; opacity: 0; }
.detail .th:hover .hint { opacity: 1; }
.detail h3 { margin: 14px 0 6px; }
.detail label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.detail .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.kv { color: var(--muted); font-size: 12px; margin-top: 8px; }
.kv b { color: var(--text); font-weight: 500; }
.versions { margin-top: 6px; font-size: 12px; }
.versions div { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.versions a { color: var(--accent2); }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font-size: 11px; margin: 2px 2px 0 0; }
.modal-bg { position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal p { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
code.tok { display: block; word-break: break-all; background: var(--panel2); padding: 10px; border-radius: 8px; user-select: all; }
.menu { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; z-index: 120; min-width: 170px; box-shadow: 0 8px 30px #0006; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; }
.menu button:hover { background: var(--panel2); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 200; }
.toast.err { border-color: var(--danger); }
@media (max-width: 800px) {
  .side { display: none; }
  .detail { position: fixed; inset: 0; width: auto; z-index: 60; }
  #search { max-width: none; }
  .brand, .me { display: none; }
}
