:root {
  color-scheme: dark;
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --text: #cdd6f4;
  --subtext0: #a6adc8;
  --blue: #89b4fa;
  --lavender: #b4befe;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--base);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

a,
label {
  color: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto;
  border: 1px solid var(--surface0);
  background: var(--mantle);
}

.view-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface0);
  background: var(--crust);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 650;
}

.brand-icon {
  color: var(--lavender);
}

.view-controls {
  display: flex;
  gap: 6px;
}

.view-controls label {
  border: 1px solid var(--surface1);
  background: var(--surface0);
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
}

#gallery-view:checked ~ .toolbar .view-controls label[for="gallery-view"],
#list-view:checked ~ .toolbar .view-controls label[for="list-view"] {
  border-color: var(--blue);
  color: var(--blue);
}

.pathbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--surface0);
}

.back-link {
  color: var(--blue);
  text-decoration: none;
  border: 1px solid var(--surface1);
  background: var(--surface0);
  padding: 4px 9px;
}

.current-dir {
  color: var(--subtext0);
}

.file-area {
  min-height: 420px;
  padding: 14px;
}

.entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-items: start;
}

.item {
  min-width: 0;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--surface0);
  background: var(--base);
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.item:hover {
  border-color: var(--surface2);
  background: #232337;
}

.item-icon {
  color: var(--lavender);
  font-size: 24px;
  line-height: 1;
}

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

.item-meta {
  color: var(--subtext0);
  font-size: 0.84rem;
  margin-top: 8px;
}

.empty {
  color: var(--subtext0);
  padding: 18px 8px;
}

#list-view:checked ~ .file-area .entries {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#list-view:checked ~ .file-area .item {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

#list-view:checked ~ .file-area .item-icon {
  font-size: 20px;
}

#list-view:checked ~ .file-area .item-meta {
  margin-top: 0;
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 16px);
    margin: 8px auto;
  }

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

  .entries {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
