:root {
  color-scheme: dark;
  --bg: #171717;
  --panel: #262626;
  --panel-alt: #303030;
  --header: #393939;
  --line: #606060;
  --line-soft: #454545;
  --text: #dedede;
  --muted: #aaa;
  --link: #f0a0a0;
  --link-hover: #ffd0d0;
  --selected: #594242;
  --green: #83c783;
  --red: #ff8f8f;
  --yellow: #d7be73;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font: 12px/1.35 Verdana, Arial, sans-serif;
}

button, input, select { font: inherit; }
button, summary { touch-action: manipulation; }

a { color: var(--link); }
a:hover { color: var(--link-hover); }

.shell {
  width: min(1540px, calc(100% - 20px));
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
}

.site-header { border-bottom: 1px solid #111; }

.header-main {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 6px 10px;
  background: #202020;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #eee;
  text-decoration: none;
  font: bold 18px Georgia, "Times New Roman", serif;
}

.mark {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.header-tools { display: flex; align-items: center; gap: 10px; }

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  background: var(--header);
  border-top: 1px solid var(--line);
}

nav a, .nav, .display-settings > summary {
  border: 0;
  border-right: 1px solid #555;
  border-radius: 0;
  background: transparent;
  color: #ddd;
  padding: 7px 13px;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

nav a:hover, .nav:hover, .nav.active {
  background: var(--selected);
  color: #fff;
}

#queueCount {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 4px;
  border: 1px solid #777;
  text-align: center;
}

main { padding: 10px; }

.panel, .card {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
}

.section-title {
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -1px -1px 8px;
  padding: 5px 8px;
  border: 1px solid #707070;
  background: var(--header);
  color: #f0f0f0;
  font-weight: bold;
}

.status-table {
  display: grid;
  grid-template-columns: minmax(190px,.9fr) minmax(300px,2fr) minmax(150px,.7fr) minmax(130px,.6fr);
  margin-bottom: 8px;
}
.status-table > div { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 6px 8px; border-right: 1px solid var(--line-soft); }
.status-table > div:last-child { border-right: 0; }
.status-table b { color: #bbb; }
.statusline { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border: 1px solid #111; background: var(--yellow); }
.dot.connected { background: var(--green); }

.searchbox { position: relative; z-index: 20; padding: 5px; }
.searchline {
  display: grid;
  grid-template-columns: 105px minmax(150px,220px) minmax(240px,1fr) auto auto auto auto;
  align-items: center;
  gap: 5px;
}
.compact-label > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.compact-label input, .compact-label select { margin-top: 0; }
.query-label input { font-size: 12px; }
.tag-tools { display: grid; grid-template-columns: 88px auto; gap: 3px; }
.tag-tools select, .tag-tools .directory-button { width: auto; margin: 0; }
.advanced-search { position: relative; }
.advanced-search > summary {
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #777;
  background: #303030;
  color: #ddd;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.advanced-search > summary::-webkit-details-marker { display: none; }
.advanced-search > summary::after { content: " ▾"; color: #aaa; }
.advanced-search[open] > summary { background: var(--selected); color: #fff; }
.advanced-search[open] > summary::after { content: " ▴"; }
.advanced-search-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  width: min(900px, calc(100vw - 42px));
  padding: 8px;
  border: 1px solid #777;
  background: #222;
  box-shadow: 3px 3px 0 #0009;
}
.advanced-actions { display: flex; justify-content: flex-end; margin-top: 7px; }

label { display: block; color: #bbb; font-size: 11px; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  margin-top: 3px;
  padding: 4px 6px;
  border: 1px solid #707070;
  border-radius: 0;
  outline: none;
  background: #151515;
  color: #eee;
}
input:focus, select:focus { border-color: #d0a0a0; outline: 1px solid #d0a0a0; }

.primary, .smallbutton, .directory-button {
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #777;
  border-radius: 0;
  background: #3b3b3b;
  color: #eee;
  text-decoration: none;
  cursor: pointer;
}
.primary:hover, .smallbutton:hover, .directory-button:hover { background: #505050; color: #fff; }
.primary:disabled, .smallbutton:disabled { color: #777; background: #2a2a2a; cursor: not-allowed; }
.directory-button { width: 100%; margin-top: 4px; }

.filters {
  display: grid;
  grid-template-columns: repeat(5,minmax(135px,1fr));
  gap: 6px 8px;
  margin-top: 6px;
}
.sourcehint, .footnote, .muted { color: var(--muted); }
.sourcehint { margin: 0; }
.footnote { margin: 6px 2px; }

.resultbar, .pagination {
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  background: var(--header);
}
.resultbar h2 { margin: 0; font-size: 12px; }
.resultbar span { color: #bbb; }
.pagination { justify-content: center; border-top: 0; margin-top: 0; }
.pagination span { min-width: 90px; text-align: center; }

.empty { padding: 24px; text-align: center; color: #bbb; }
.empty p { margin: 5px 0 0; }

.release {
  display: grid;
  grid-template-columns: minmax(0,1fr) 75px 75px 95px 105px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--line-soft);
}
.release.native-release { grid-template-columns: minmax(0,1fr) 78px 70px 70px 90px 100px; }
.release:nth-child(odd) { background: #2b2b2b; }
.release:last-child { border-bottom: 0; }
.releasehead { min-height: 28px; background: #333!important; color: #bbb; font-weight: bold; }
.sort-heading {
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #bbb;
  font-weight: bold;
  text-align: right;
  cursor: pointer;
}
.sort-heading.title-sort { text-align: left; }
.sort-heading:hover, .sort-heading.active { color: #fff; text-decoration: underline; }
.release a { color: var(--link); text-decoration: none; overflow-wrap: anywhere; }
.release a:hover { color: var(--link-hover); text-decoration: underline; }
.release p { display: flex; flex-wrap: wrap; gap: 3px 6px; margin: 3px 0 0; color: #aaa; font-size: 10px; }
.release .metric { text-align: right; color: #bbb; font-variant-numeric: tabular-nums; }
.release .seeds { color: var(--green); }

.badge, .tag {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid #666;
  border-radius: 0;
  background: #333;
  color: #ddd;
  font-size: 10px;
  line-height: 1.35;
}
.badge.sukebei { color: #f1b8c7; }

.error { color: var(--red); margin: 6px 0; }
.error:empty { display: none; }
.hidden { display: none!important; }

.login { max-width: 430px; margin: 70px auto; padding: 0 10px 10px; }
.login label { margin-top: 8px; }
.login .primary { margin-top: 10px; }

.progress { height: 12px; border: 1px solid #666; background: #181818; overflow: hidden; }
.progress span { display: block; width: var(--progress,0%); height: 100%; background: #7d5555; }

.note { margin-top: 8px; padding: 8px; }
.note p { margin: 5px 0; color: #bbb; }
code { color: #ccc; font-size: 11px; overflow-wrap: anywhere; }

footer { display: flex; justify-content: space-between; margin-top: 12px; padding: 7px 10px; border-top: 1px solid var(--line); color: #888; }

dialog {
  width: min(520px,94vw);
  padding: 0 10px 10px;
  border: 2px solid #777;
  border-radius: 0;
  background: #222;
  color: var(--text);
  box-shadow: 4px 4px 0 #0009;
}
dialog::backdrop { background: #000b; }
dialog label { margin-top: 8px; }
dialog .primary { margin-top: 10px; }
.close { min-height: 20px; border: 0; background: transparent; color: #fff; font-size: 18px; cursor: pointer; }
.chosen { padding: 7px; border: 1px solid var(--line-soft); background: #191919; overflow-wrap: anywhere; }

.toast {
  position: fixed;
  z-index: 200;
  right: 12px;
  bottom: 12px;
  max-width: 420px;
  padding: 8px 12px;
  border: 1px solid #aaa;
  background: #333;
  color: #fff;
}

@media (max-width: 900px) {
  .searchline { grid-template-columns: 100px minmax(135px,190px) minmax(210px,1fr) auto auto; }
  .tag-tools { grid-column: auto; }
  .advanced-search { grid-column: auto; }
  .filters { grid-template-columns: repeat(3,minmax(125px,1fr)); }
  .status-table { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .status-table > div:nth-child(2) { border-right: 0; }
  .release { grid-template-columns: minmax(0,1fr) 65px 75px 95px; }
  .release.native-release { grid-template-columns: minmax(0,1fr) 70px 65px 85px 90px; }
  .release > .leechers { display: none; }
}

@media (max-width: 620px) {
  .shell { width: 100%; border: 0; }
  main { padding: 6px; }
  .header-main { align-items: flex-start; }
  .header-tools { flex-direction: column-reverse; align-items: flex-end; }
  nav a, .nav { flex: 1 1 auto; text-align: center; padding: 8px 6px; }
  .status-table { grid-template-columns: 1fr; }
  .status-table > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .status-table > div:last-child { border-bottom: 0; }
  .status-detail { display: none!important; }
  .searchline { grid-template-columns: 92px minmax(0,1fr) auto auto; }
  .category-control { grid-column: 2 / -1; grid-row: 2; }
  .query-label { grid-column: 1 / -1; grid-row: 3; }
  #languageFilter { grid-column: 1 / 3; grid-row: 4; }
  .tag-tools { grid-column: 3 / -1; grid-row: 4; }
  .advanced-search { position: static; }
  .advanced-search-panel { top: auto; left: 0; right: 0; width: 100%; margin-top: 4px; }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .release { grid-template-columns: minmax(0,1fr) 55px 75px; }
  .release.native-release { grid-template-columns: minmax(0,1fr) 55px 72px; }
  .release > .size, .native-release > .downloads { display: none; }
  .releasehead { font-size: 10px; }
  .resultbar { align-items: flex-start; }
}
