:root {
  --bg: #0f1216;
  --bg-2: #161b22;
  --bg-3: #1d232c;
  --border: #2a323d;
  --fg: #e6edf3;
  --fg-dim: #8b949e;
  --accent: #4c8dff;
  --accent-dim: #1f3a66;
  --danger: #ff6b6b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand {
  font-weight: 600;
  white-space: nowrap;
}

.search {
  flex: 1 1 auto;
  max-width: 480px;
  padding: 7px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
}

.stats {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 12px;
  white-space: nowrap;
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

/* layout */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 260px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 8px;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

.tree > ul {
  padding-left: 0;
}

.tree .row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree .row:hover {
  background: var(--bg-3);
  color: var(--fg);
}

.tree .row.active {
  background: var(--accent-dim);
  color: var(--fg);
}

.tree .toggle {
  width: 14px;
  text-align: center;
  font-size: 10px;
  color: var(--fg-dim);
  flex: 0 0 auto;
}

.tree .spacer {
  width: 14px;
  flex: 0 0 auto;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  padding: 16px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  color: var(--fg-dim);
  font-size: 13px;
}

.breadcrumb a {
  color: var(--fg);
}

.breadcrumb .sep {
  color: var(--fg-dim);
}

/* file grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 0;
}

.card:hover {
  border-color: var(--accent);
  background: var(--bg-3);
}

.card .icon {
  font-size: 22px;
  flex: 0 0 auto;
}

.card .meta {
  min-width: 0;
}

.card .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card .sub {
  color: var(--fg-dim);
  font-size: 12px;
}

/* list */
.list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list .item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.list .item:last-child {
  border-bottom: none;
}

.list .item:hover {
  background: var(--bg-3);
}

.list .item.playing {
  background: var(--accent-dim);
}

.list .idx {
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
  flex: 0 0 auto;
}

.list .grow {
  flex: 1 1 auto;
  min-width: 0;
}

.list .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list .url {
  color: var(--fg-dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list .dur {
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  flex: 0 0 auto;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  padding: 7px 14px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.btn.ghost {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 400;
}

.btn:hover {
  filter: brightness(1.1);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--fg-dim);
  font-size: 12px;
}

.empty {
  color: var(--fg-dim);
  padding: 40px 0;
  text-align: center;
}

pre.text-view {
  margin: 0;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.6 ui-monospace, Consolas, monospace;
}

img.preview {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--fg-dim);
}

/* player */
.player {
  flex: 0 0 auto;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
}

.player-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--fg-dim);
}

.player-actions {
  display: flex;
  gap: 4px;
}

.player-actions button {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 10px;
  cursor: pointer;
}

.player-actions button:hover {
  border-color: var(--accent);
}

#media {
  width: 100%;
  max-height: 32vh;
  background: #000;
  border-radius: 8px;
}

@media (max-width: 720px) {
  .menu-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 49px;
    bottom: 0;
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .stats {
    display: none;
  }
}
