:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255,255,255,.72);
  --muted2: rgba(255,255,255,.5);
  --line: rgba(255,255,255,.12);
  --chip: rgba(255,255,255,.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 18px 18px 28px;
  background: var(--bg);
  color: var(--fg);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  background: var(--bg, #0b0b0b);
  padding-top: 10px;
  padding-bottom: 10px;
}

.subbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 14px 0;
}

.subnav {
  background: var(--chip);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  font: inherit;
  cursor: pointer;
}

.subnav[aria-pressed="true"] {
  color: var(--fg);
  border-color: rgba(255,255,255,.35);
}

.subhint {
  color: var(--muted2);
  user-select: none;
}

.page {
  border: 1px solid var(--line);
  background: var(--chip);
  border-radius: 12px;
  padding: 14px;
  margin: 0 0 14px 0;
}

.page-inner h2 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
}

.page-inner p {
  margin: 0 0 10px 0;
  color: var(--muted);
}

.cardish {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(0,0,0,.3);
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
}

.stat {
  background: var(--chip);
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.lizzies {
  border-color: hotpink;
  color: hotpink;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  background: var(--chip);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  font: inherit;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  color: var(--fg);
  border-color: rgba(255,255,255,.35);
}

.chip-select {
  cursor: default;
  display: flex;
  gap: 6px;
  align-items: center;
}

.chip-select select {
  background: transparent;
  color: var(--fg);
  border: 0;
  outline: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.gear {
  color: var(--muted);
  user-select: none;
  font-size: 14px;
  line-height: 1;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip);
}

h1 {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
}

h1 .muted {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
}

tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.col-name {
  width: 44%;
}

.col-mod {
  width: 16%;
  white-space: nowrap;
}

.col-size {
  width: 10%;
  white-space: nowrap;
}

.col-res {
  width: 18%;
  white-space: nowrap;
}

.col-type {
  width: 6%;
  white-space: nowrap;
  color: var(--muted);
}

.col-actions {
  width: 6%;
  white-space: nowrap;
}

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

a:hover {
  text-decoration: underline;
}

.namecell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.arrow {
  color: var(--muted2);
  flex: 0 0 auto;
}

.filename {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
  text-decoration: none;
  color: inherit;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

a.filename {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
  color: inherit;
  text-decoration: none;
  position: relative;
  transition: color .3s ease;
}

a.filename::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #00ffff;
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity .3s ease, transform .344s ease;
}

a.filename:hover {
  color: #00ffff;
}

a.filename:hover::after {
  opacity: 1;
  transform: scaleX(1);
}

.pill {
  color: rgba(255,255,255,.70);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.pill-nsfw {
  background: rgba(255, 0, 0, .18);
  border-color: rgba(255, 0, 0, .55);
  color: rgba(255, 90, 90, 1);
  font-weight: 700;
}

.nsfw-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 43, 43, .95);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: .3px;
  z-index: 2;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

body.nsfw-on .card.nsfw .thumb img {
  filter: blur(18px);
}

body.nsfw-on #previewBox.nsfw img {
  filter: blur(18px);
}

.actions a {
  color: var(--muted);
}

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

.favBtn {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.favBtn:hover {
  color: var(--fg);
  text-decoration: underline;
}

tr.fav .filename {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.res {
  color: rgba(255,255,255,.82);
}

.res .tag {
  color: var(--muted);
}

.preview {
  position: fixed;
  left: 0;
  top: 0;
  width: 300px;
  height: 180px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.90);
  border-radius: 10px;
  padding: 8px;
  display: none;
  z-index: 9999;
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  pointer-events: none;
  opacity: 0;
  transform: translate(24px, 24px);
  transition: opacity 120ms ease;
}

.preview.show {
  opacity: 1;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview.big {
  width: 360px;
  height: 220px;
}

.footer {
  margin-top: 10px;
  color: var(--muted2);
}

.empty {
  color: var(--muted);
  padding: 10px 0;
}

code {
  color: var(--fg);
  background: var(--chip);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

.col-type {
  display: none;
}
}

@media (max-width: 820px) {
  .col-actions {
    display: none;
  }

  .col-res {
    width: 26%;
  }

  .col-name {
    width: auto;
  }
}

@media (max-width: 720px) {
  .preview {
    display: none !important;
  }
}

.pill-8k {
  border-color: rgba(170,120,255,.35);
  color: rgba(210,190,255,.9);
}

.pill-5k {
  border-color: rgba(140,200,255,.30);
  color: rgba(190,230,255,.9);
}

.pill-4k {
  border-color: rgba(120,220,255,.35);
  color: rgba(180,245,255,.95);
}

.pill-2k {
  border-color: rgba(200,255,170,.25);
  color: rgba(230,255,210,.9);
}

.pill-fhd {
  border-color: rgba(255,220,140,.25);
  color: rgba(255,240,200,.9);
}

.pill-hd {
  border-color: rgba(255,255,255,.18);
  color: rgba(255,255,255,.78);
}

.pill-uw {
  border-color: rgba(255,190,120,.30);
  color: rgba(255,230,200,.92);
}

.pill-pt {
  border-color: rgba(255,140,200,.25);
  color: rgba(255,205,235,.9);
}

.pill-sq {
  border-color: rgba(255,255,255,.18);
  color: rgba(255,255,255,.78);
}

body.gallery-mode table#fileTable {
  display: none;
}

body.gallery-mode #gallery {
  display: grid !important;
}

.gallery {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  overflow: hidden;
  min-height: 170px;
}

.card .thumb {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 130px;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card .meta {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card .meta a {
  color: var(--fg);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card .meta a:hover {
  text-decoration: underline;
}

.card .pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card .actions {
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card .actions a, .card .actions button {
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.card .actions a:hover, .card .actions button:hover {
  color: var(--fg);
  text-decoration: underline;
}

@media (max-width: 520px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }

  .card .thumb {
    height: 110px;
  }
}

.filename {
  max-width: 420px;
}

@media (max-width: 900px) {
  .filename {
    max-width: 260px;
  }
}

@media (max-width: 600px) {
  .filename {
    max-width: 170px;
  }
}