:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-hover: #eaeef2;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --fg: #1f2328;
  --fg-muted: #656d76;
  --accent: #0969da;
  --folder: #54aeff;
  --sel: #ddf4ff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-subtle: #161b22; --bg-hover: #21262d;
    --border: #30363d; --border-muted: #21262d;
    --fg: #e6edf3; --fg-muted: #8d96a0; --accent: #4493f8;
    --folder: #54aeff; --sel: #121d2f;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-subtle: #161b22; --bg-hover: #21262d;
  --border: #30363d; --border-muted: #21262d;
  --fg: #e6edf3; --fg-muted: #8d96a0; --accent: #4493f8;
  --folder: #54aeff; --sel: #121d2f;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--fg); background: var(--bg);
  display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { fill: currentColor; flex: none; }

/* Top bar */
.topbar {
  height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 12px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
}
.burger { display: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--fg); font-size: 15px; }
.brand:hover { text-decoration: none; }
.spacer { flex: 1; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--fg-muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 256px; flex: none; padding: 16px 8px; overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg);
}
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; margin-bottom: 2px;
  border-radius: 6px; color: var(--fg); position: relative;
}
.nav-link:hover { background: var(--bg-hover); text-decoration: none; }
.nav-link svg { color: var(--fg-muted); }
.nav-link.active { background: var(--bg-hover); font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 4px;
  border-radius: 6px; background: #fd8c73;
}
.nav-link.active svg { color: var(--fg); }
.nav-sep { height: 1px; background: var(--border-muted); margin: 8px 8px 12px; }
.main { flex: 1; min-width: 0; overflow-y: auto; }
.page { max-width: 1012px; margin: 0 auto; padding: 24px 32px 48px; }

/* Home */
.home h1 { font-size: 32px; font-weight: 600; margin: 8px 0 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border-muted); }
.home p.lead { color: var(--fg-muted); font-size: 16px; margin: 16px 0 24px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 16px;
  border: 1px solid var(--border); border-radius: 6px; color: var(--fg);
}
.tile:hover { background: var(--bg-subtle); text-decoration: none; border-color: var(--fg-muted); }
.tile .t-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); }
.tile .t-desc { color: var(--fg-muted); font-size: 12px; }

/* Explorer-style address bar */
.explorer-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.nav-btns { display: flex; gap: 2px; }
.address {
  flex: 1; min-width: 0; height: 34px; display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-subtle);
  padding: 0 4px; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.address::-webkit-scrollbar { display: none; }
.address:hover { border-color: var(--fg-muted); }
.crumb {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px;
  border-radius: 4px; background: transparent; border: 0; cursor: pointer; color: var(--fg);
}
.crumb:hover { background: var(--bg-hover); text-decoration: none; }
.crumb.current { font-weight: 600; cursor: default; }
.crumb.current:hover { background: transparent; }
.chev { color: var(--fg-muted); display: inline-grid; place-items: center; padding: 0 1px; }
.search {
  width: 220px; height: 34px; padding: 0 12px 0 32px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-subtle) no-repeat 10px center;
  color: var(--fg); font: inherit;
}
.search::placeholder { color: var(--fg-muted); }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; background-color: var(--bg); }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 10px; color: var(--fg-muted); pointer-events: none; }
.search { background-image: none; }

/* GitHub-style file table */
.box { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.box-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.box-head .count { margin-left: auto; font-weight: 400; color: var(--fg-muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th {
  text-align: left; font-weight: 400; font-size: 12px; color: var(--fg-muted);
  padding: 8px 16px; border-bottom: 1px solid var(--border-muted); background: var(--bg);
}
td { padding: 8px 16px; border-top: 1px solid var(--border-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover { background: var(--bg-subtle); }
.col-name { width: auto; }
.col-size { width: 110px; text-align: right; }
.col-date { width: 160px; text-align: right; color: var(--fg-muted); }
td.col-size { color: var(--fg-muted); font-size: 12px; }
th.col-size, th.col-date { text-align: right; }
.name { display: inline-flex; align-items: center; gap: 12px; color: var(--fg); max-width: 100%; }
.name:hover { color: var(--accent); text-decoration: underline; }
.name .ico-folder { color: var(--folder); }
.name .ico-file { color: var(--fg-muted); }
.empty { padding: 48px 16px; text-align: center; color: var(--fg-muted); }
.empty svg { width: 32px; height: 32px; margin-bottom: 8px; }
.empty .path { font-family: var(--mono); font-size: 12px; background: var(--bg-subtle); padding: 2px 6px; border-radius: 6px; }
.hint { margin-top: 16px; color: var(--fg-muted); font-size: 12px; }

@media (max-width: 800px) {
  .burger { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 10; top: 56px; bottom: 0; left: 0; transform: translateX(-100%);
    transition: transform .15s ease; box-shadow: 0 8px 24px rgba(1,4,9,.3);
  }
  body.menu-open .sidebar { transform: none; }
  .page { padding: 16px; }
  .col-date { display: none; }
  .search-wrap { display: none; }
  .home h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
