:root {
  --bg: #f1f5f9; --panel: #ffffff; --panel2: #f1f5f9; --line: #e2e8f0;
  --text: #1e293b; --muted: #64748b; --accent: #2563eb; --accent-soft: #eff6ff;
  --danger: #ef4444; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-hover: 0 8px 22px rgba(15, 23, 42, .12);
  --folder: #3b82f6; --c-pdf: #ef4444; --c-image: #a855f7; --c-video: #f97316; --c-audio: #ec4899;
  --c-text: #64748b; --c-swf: #14b8a6; --c-file: #94a3b8; --c-doc: #2563eb;
  color-scheme: light;
}
:root[data-theme=dark] {
  --bg: #0b1020; --panel: #131a2e; --panel2: #1a2340; --line: #243049;
  --text: #e5e9f5; --muted: #8a96b3; --accent: #3b82f6; --accent-soft: #172554;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-hover: 0 8px 22px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { height: 100%; }
body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button:disabled { opacity: .4; cursor: default; }
button.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }
svg { display: block; }
input[type=text], input[type=password], input[type=search] { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; height: 38px; }

.shell { display: grid; grid-template-columns: 264px 1fr; height: 100%; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; padding: 0 8px 18px; }
.brand b { color: var(--accent); }
.brand svg { color: #7c3aed; }
.menu-label { font-size: 11px; letter-spacing: .08em; color: var(--muted); padding: 6px 10px; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); cursor: pointer; border: 1px solid transparent; background: none; width: 100%; text-align: left; font-weight: 500; }
.nav-item:hover { background: var(--panel2); color: var(--text); border-color: transparent; }
.nav-item.on { background: var(--panel); color: var(--text); font-weight: 600; border-color: var(--line); box-shadow: var(--shadow); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.usage { margin-top: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.usage h4 { margin: 0 0 4px; display: flex; justify-content: space-between; font-size: 14px; }
.usage .sub { font-size: 12px; }
.seg { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--panel2); margin: 10px 0 8px; gap: 2px; }
.seg i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: var(--c); }

.content { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.burger { display: none; }
.title { font-weight: 600; font-size: 15px; min-width: 0; flex: 1 1 200px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--panel2); color: var(--text); }
.crumbs a:last-child { color: var(--text); font-weight: 600; }
.crumbs span { color: var(--line); }
.search { position: relative; flex: 0 1 340px; }
.search input { width: 100%; padding-left: 36px; border-radius: 99px; background: var(--panel2); border-color: transparent; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.seg-toggle { display: flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-toggle button { border: 0; background: none; border-radius: 8px; width: 34px; height: 32px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.seg-toggle button.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.sep { width: 1px; height: 26px; background: var(--line); }

.admin-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 24px; background: var(--accent-soft); border-bottom: 1px solid var(--line); align-items: center; }
.admin-bar .count { color: var(--muted); margin-right: 6px; font-weight: 500; }

main { padding: 24px; overflow-y: auto; flex: 1; }
h2.sec { margin: 0 0 14px; font-size: 20px; }
.block { margin-bottom: 28px; }
.empty { color: var(--muted); text-align: center; padding: 70px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; }
.grid.quick { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { position: relative; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; border: 1px solid transparent; overflow: hidden; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card.sel { border-color: var(--accent); background: var(--accent-soft); }
.thumb { height: 112px; display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { padding: 4px 12px 14px; min-width: 0; text-align: center; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.sub { color: var(--muted); font-size: 12px; }
.badge { position: absolute; top: 8px; right: 8px; background: var(--panel); box-shadow: var(--shadow); border-radius: 8px; padding: 3px; display: grid; place-items: center; color: var(--muted); }
.fav { position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; padding: 0; border: 0; background: var(--panel); box-shadow: var(--shadow); border-radius: 8px; display: none; place-items: center; color: var(--muted); }
.card:hover .fav, .fav.on { display: grid; }
.fav.on { color: #f59e0b; }
.pick { position: absolute; bottom: 10px; left: 10px; width: 18px; height: 18px; accent-color: var(--accent); z-index: 2; }
.card.row { flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; }
.card.row .thumb { height: 40px; width: 40px; flex: none; }
.card.row .thumb svg { width: 36px; height: 36px; }
.nav-item { justify-content: flex-start; }
.sec-ops { display: flex; gap: 6px; }
.card.row .meta { padding: 0; text-align: left; flex: 1; }

.grid.list { grid-template-columns: 1fr; gap: 6px; }
.list .card { flex-direction: row; align-items: center; border-radius: 12px; }
.list .thumb { height: 52px; width: 52px; flex: none; margin: 4px 4px 4px 10px; border-radius: 10px; }
.list .thumb svg { width: 34px; height: 34px; }
.list .meta { flex: 1; display: grid; grid-template-columns: 1fr 100px 130px; gap: 12px; align-items: center; text-align: left; padding: 8px 12px; }
.list .badge { position: static; margin-right: 12px; box-shadow: none; }
.list .fav { position: static; margin-right: 8px; display: grid; background: none; box-shadow: none; }
.list .pick { bottom: auto; top: 50%; left: 6px; transform: translateY(-50%); }

.sentinel { height: 1px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 100; max-width: 90vw; }
.toast.bad { background: var(--danger); color: #fff; }
.dropzone { position: fixed; inset: 0; background: rgba(37, 99, 235, .18); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 22px; z-index: 90; pointer-events: none; }
.progress { position: fixed; right: 16px; bottom: 16px; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; z-index: 95; box-shadow: var(--shadow-hover); }
.progress .bar2 { height: 6px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin-top: 6px; }
.progress .bar2 i { display: block; height: 100%; background: var(--accent); width: 0; }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 80; padding: 16px; }
.dialog { background: var(--panel); border-radius: 16px; padding: 22px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-hover); }
.dialog h3 { margin: 0; }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
.dialog input { width: 100%; }
.err { color: var(--danger); min-height: 1em; }

.lb { position: fixed; inset: 0; background: rgba(8, 10, 18, .96); color: #e5e9f5; z-index: 70; display: flex; flex-direction: column; }
.lb button, .lb select { background: #1b2238; border-color: #2b3556; color: #e5e9f5; }
.lb-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #1c2236; }
.lb-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.lb-body { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; overflow: auto; }
.lb-body img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.lb-body img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
.lb-body video { max-width: 100%; max-height: 100%; background: #000; }
.lb-body audio { width: min(640px, 90vw); }
.lb-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.lb-body pre { margin: 0; padding: 20px; width: 100%; height: 100%; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 26px; border-radius: 50%; width: 46px; height: 46px; padding: 0; z-index: 3; opacity: .85; }
.nav.prev { left: 12px; } .nav.next { right: 12px; }
.lb-foot { padding: 8px 16px; color: #9aa6c4; font-size: 12.5px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lb-foot a { color: #7aa7ff; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: fixed; z-index: 60; inset: 0 auto 0 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-hover); }
  .shell.open aside { transform: none; }
  .burger { display: grid; }
  .topbar { padding: 10px 14px; }
  main { padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .list .meta { grid-template-columns: 1fr; gap: 0; }
  .list .meta .sub:nth-child(n+3) { display: none; }
}
