:root {
  color-scheme: light;
  --page: #f6f2fa;
  --surface: #fffbff;
  --surface-raised: #f0ebf5;
  --surface-accent: #eaddff;
  --text: #1c1b1f;
  --muted: #625d68;
  --line: #cbc5d2;
  --accent: #6750a4;
  --accent-hover: #503b8a;
  --on-accent: #21005d;
  --focus: #7b5daa;
  --shadow: 0 1rem 2.5rem rgb(48 36 64 / 9%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141218;
  --surface: #1c1b21;
  --surface-raised: #292630;
  --surface-accent: #4f378b;
  --text: #e7e0eb;
  --muted: #cbc4d0;
  --line: #49454f;
  --accent: #d0bcff;
  --accent-hover: #eaddff;
  --on-accent: #eaddff;
  --focus: #d0bcff;
  --shadow: 0 1rem 2.5rem rgb(0 0 0 / 24%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #141218;
    --surface: #1c1b21;
    --surface-raised: #292630;
    --surface-accent: #4f378b;
    --text: #e7e0eb;
    --muted: #cbc4d0;
    --line: #49454f;
    --accent: #d0bcff;
    --accent-hover: #eaddff;
    --on-accent: #eaddff;
    --focus: #d0bcff;
    --shadow: 0 1rem 2.5rem rgb(0 0 0 / 24%);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse at 8% 0%, rgb(103 80 164 / 12%), transparent 34rem),
    radial-gradient(ellipse at 94% 18%, rgb(125 82 96 / 7%), transparent 28rem),
    var(--page);
  font: 16px/1.55 system-ui, sans-serif;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.page {
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--line);
  border: 0;
  border-radius: 0.7rem 0.7rem 1rem 0.5rem;
  background: var(--surface-accent);
  color: var(--on-accent);
  box-shadow: var(--shadow);
}

.current-directory {
  min-width: 0;
  overflow: hidden;
  flex: 1;
  color: var(--muted);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-toggle {
  display: grid;
  width: 2.85rem;
  height: 2.85rem;
  place-items: center;
  border: 0;
  border-radius: 1.15rem;
  background: var(--surface-accent);
  color: var(--on-accent);
  cursor: pointer;
  transition:
    border-radius 220ms cubic-bezier(0.2, 0, 0, 1.35),
    transform 220ms cubic-bezier(0.2, 0, 0, 1.35),
    background-color 180ms ease;
}

.theme-toggle:hover {
  border-radius: 50%;
  transform: rotate(-8deg);
  background: var(--accent);
}

.theme-icon {
  display: none;
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-toggle[data-next-theme="dark"] .theme-icon--moon,
.theme-toggle[data-next-theme="light"] .theme-icon--sun {
  display: block;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0.75rem;
}

.search {
  width: min(100%, 28rem);
  min-height: 2.9rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  border-color: transparent;
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.search::placeholder {
  color: var(--muted);
}

.results-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.65rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

#list {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

#list th,
#list td {
  padding: 0.9rem 1rem;
  text-align: left;
  vertical-align: middle;
}

#list thead {
  background: var(--surface-accent);
  color: var(--on-accent);
}

#list th {
  border-bottom: 1px solid var(--line);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

#list th a {
  color: inherit;
  white-space: nowrap;
}

#list tbody tr + tr td {
  border-top: 1px solid var(--line);
}

#list tbody tr:hover {
  background: var(--surface-raised);
}

#list tbody tr.parent-directory {
  background: var(--surface-raised);
}

#list tbody tr.parent-directory td {
  color: var(--muted);
}

#list tbody tr.parent-directory a {
  font-weight: 600;
  letter-spacing: 0.04em;
}

#list td.link {
  overflow-wrap: anywhere;
  font-weight: 580;
}

#list td.link a {
  display: inline-block;
  min-height: 2rem;
  align-content: center;
}

#list td.size,
#list td.date {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

#list tr[hidden] {
  display: none;
}

.empty-state {
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: center;
}

.list-summary {
  margin: 0;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

@media (max-width: 42rem) {
  .page {
    width: min(100% - 1.25rem, 76rem);
    padding-top: 0.75rem;
  }

  .topbar {
    margin-bottom: 1rem;
  }

  .brand {
    gap: 0.45rem;
    font-size: 0.94rem;
  }

  .brand-mark {
    width: 1.8rem;
    height: 1.8rem;
  }

  .theme-toggle {
    width: 2.6rem;
    height: 2.6rem;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .search {
    width: 100%;
  }

  #list th,
  #list td {
    padding: 0.75rem 0.6rem;
  }

  #list th:last-child,
  #list td.date {
    display: none;
  }

  #list th:nth-child(2),
  #list td.size {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
