:root {
  --bg: #0b0f17;
  --bg-2: #0f1520;
  --surface: #131a27;
  --surface-2: #192234;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e7eaf1;
  --muted: #8d95a8;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --c-folder: #fbbf24;
  --c-video: #f472b6;
  --c-audio: #34d399;
  --c-image: #38bdf8;
  --c-pdf: #f87171;
  --c-doc: #60a5fa;
  --c-text: #a3b1c6;
  --c-archive: #c084fc;
  --c-file: #94a3b8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --sidebar-w: 256px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(125, 211, 252, 0.08), transparent 60%),
              radial-gradient(900px 500px at 100% 0%, rgba(167, 139, 250, 0.08), transparent 55%),
              var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(125, 211, 252, 0.3); }

.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent 30%), var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.logo { width: 38px; height: 38px; display: inline-flex; }
.logo svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: -0.01em; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); transition: background .15s, color .15s;
}
.nav a .icon { width: 19px; height: 19px; }
.nav a:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(125,211,252,0.16), rgba(167,139,250,0.10)); color: var(--text); }

.storage { margin-top: auto; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.storage-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.storage-head span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.bar span.warn { background: linear-gradient(90deg, #fbbf24, #f87171); }
.storage-text { margin-top: 10px; font-size: 13px; }
.storage-sub { font-size: 12px; color: var(--muted); }
.sidebar-foot { font-size: 12px; color: var(--muted); padding: 0 4px; }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border-radius: 6px; background: rgba(255,255,255,0.08); border: 1px solid var(--border-strong); }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; flex: 1; font-size: 14px; }
.crumbs a { color: var(--muted); padding: 4px 6px; border-radius: 6px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.crumbs .cur { padding: 4px 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.crumbs .sep { color: rgba(255,255,255,0.22); }

.search { display: flex; align-items: center; gap: 8px; width: min(340px, 40vw); padding: 8px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: rgba(125,211,252,0.5); box-shadow: 0 0 0 3px rgba(125,211,252,0.12); color: var(--text); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: invert(0.7); }

.controls { display: flex; align-items: center; gap: 8px; }
select { padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); outline: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.seg button { display: inline-flex; padding: 6px 9px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.seg button.active { background: rgba(255,255,255,0.09); color: var(--text); }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; border: 1px solid transparent; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #0b0f17; font-weight: 600; font-size: 14px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn:hover { filter: brightness(1.08); }

/* ---------- content ---------- */
.content { padding: 22px 24px 60px; flex: 1; }
.content.loading { opacity: .55; pointer-events: none; transition: opacity .2s; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 4px 0 18px; }
.head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.head p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; outline: none;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.thumb { position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.thumb .icon { width: 42px; height: 42px; stroke-width: 1.5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; right: 10px; bottom: 10px; padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,0.55); font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #fff; }
.thumb .playhint { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .15s; }
.thumb .playhint .icon { width: 44px; height: 44px; color: #fff; stroke: none; }
.card:hover .playhint { opacity: 1; }

.kind-folder .thumb { color: var(--c-folder); background: linear-gradient(160deg, rgba(251,191,36,0.16), rgba(251,191,36,0.03)); }
.kind-video .thumb { color: var(--c-video); background: linear-gradient(160deg, rgba(244,114,182,0.22), rgba(167,139,250,0.08)); }
.kind-audio .thumb { color: var(--c-audio); background: linear-gradient(160deg, rgba(52,211,153,0.18), rgba(52,211,153,0.03)); }
.kind-image .thumb { color: var(--c-image); background: linear-gradient(160deg, rgba(56,189,248,0.18), rgba(56,189,248,0.03)); }
.kind-pdf .thumb { color: var(--c-pdf); background: linear-gradient(160deg, rgba(248,113,113,0.18), rgba(248,113,113,0.03)); }
.kind-doc .thumb { color: var(--c-doc); background: linear-gradient(160deg, rgba(96,165,250,0.18), rgba(96,165,250,0.03)); }
.kind-text .thumb { color: var(--c-text); }
.kind-archive .thumb { color: var(--c-archive); background: linear-gradient(160deg, rgba(192,132,252,0.18), rgba(192,132,252,0.03)); }
.kind-file .thumb { color: var(--c-file); }

.meta { padding: 11px 12px 12px; min-width: 0; }
.name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where { color: var(--accent); font-size: 11px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.card:hover .actions, .card:focus-within .actions { opacity: 1; }
.actions .icon-btn { width: 30px; height: 30px; background: rgba(0,0,0,0.5); color: #fff; backdrop-filter: blur(6px); }
.actions .icon-btn:hover { background: rgba(0,0,0,0.75); }

/* list view */
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 12px; border-bottom: 1px solid var(--border); }
.list td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.list td.n { white-space: normal; min-width: 240px; }
.list tr.row { cursor: pointer; outline: none; }
.list tr.row:hover, .list tr.row:focus-visible { background: rgba(255,255,255,0.04); }
.list .nwrap { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.list .nwrap .icon { width: 22px; height: 22px; }
.list .nwrap small { display: block; color: var(--accent); font-weight: 400; font-size: 11px; opacity: .85; }
.list .muted { color: var(--muted); }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .act { text-align: right; }
.list .act .icon-btn { width: 30px; height: 30px; }
.kind-folder .n .icon { color: var(--c-folder); } .kind-video .n .icon { color: var(--c-video); }
.kind-audio .n .icon { color: var(--c-audio); } .kind-image .n .icon { color: var(--c-image); }
.kind-pdf .n .icon { color: var(--c-pdf); } .kind-doc .n .icon { color: var(--c-doc); }
.kind-archive .n .icon { color: var(--c-archive); } .kind-text .n .icon, .kind-file .n .icon { color: var(--c-file); }

.state { display: grid; place-items: center; text-align: center; padding: 80px 20px; color: var(--muted); gap: 10px; }
.state .icon { width: 44px; height: 44px; opacity: .5; }
.state strong { color: var(--text); font-size: 16px; }
.state a { color: var(--accent); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.12); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: rgba(6, 9, 14, 0.96); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.viewer-title { flex: 1; min-width: 0; }
.v-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-actions { display: flex; align-items: center; gap: 6px; }
.vsep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 6px; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; }
.viewer-stage video { max-width: 100%; max-height: 100%; width: min(100%, 1400px); border-radius: 10px; background: #000; box-shadow: var(--shadow); outline: none; }
.viewer-stage img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow); }
.viewer-stage iframe { width: min(100%, 1100px); height: 100%; border: 0; border-radius: 10px; background: #fff; }
.audio-wrap { display: flex; flex-direction: column; align-items: center; gap: 26px; width: min(100%, 560px); padding: 40px 28px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.audio-wrap .disc { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; color: var(--c-audio); background: radial-gradient(circle at 35% 35%, rgba(52,211,153,0.35), rgba(52,211,153,0.05) 70%); }
.audio-wrap .disc .icon { width: 52px; height: 52px; stroke-width: 1.5; }
.audio-wrap audio { width: 100%; }
.text-view { width: min(100%, 1000px); height: 100%; margin: 0; padding: 18px 22px; overflow: auto; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.unsupported { text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; }
.unsupported .icon { width: 60px; height: 60px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; padding: 10px 16px; border-radius: 10px; background: #1f2937; border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 14px; animation: rise .2s ease; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .crumbs { order: 3; flex-basis: 100%; }
  .search { width: auto; flex: 1; }
  .content { padding: 14px 12px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .head p { display: none; }
  .btn span { display: none; }
  .btn { padding: 8px 10px; }
  .viewer-stage { padding: 8px; }
  .list th:nth-child(2), .list td:nth-child(2), .list th:nth-child(4), .list td:nth-child(4) { display: none; }
}
