/* selfhosted catalog — terminal/CRT theme */

:root {
  --bg: #05080a;
  --bg-soft: #070d09;
  --panel: #081109;
  --line: #14251a;
  --line-soft: #0f1a13;
  --fg: #b7c9b9;
  --fg-bright: #e6ffe6;
  --dim: #5c7262;
  --dim-2: #44584c;
  --accent: #39ff88;
  --accent-dim: #1f7a45;
  --amber: #ffd166;
  --red: #ff7b72;
  --blue: #9fd0ff;
  --mono: "Berkeley Mono", "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", "Liberation Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(57, 255, 136, 0.06), transparent 70%),
    radial-gradient(700px 400px at 100% 100%, rgba(57, 255, 136, 0.03), transparent 70%);
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  opacity: 0.45;
  mix-blend-mode: multiply;
}

::selection { background: var(--accent); color: #041007; }

a { color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 14px;
  background: #04070a;
  border-bottom: 1px solid var(--line);
}

.win-dots { display: flex; gap: 5px; }
.win-dots i {
  width: 7px; height: 7px;
  border: 1px solid var(--accent-dim);
  background: transparent;
  display: block;
}

.brand {
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--dim);
  white-space: nowrap;
}
.brand .prompt { color: var(--accent); }
.brand .colon { color: var(--dim-2); }
.brand .path { color: var(--fg); }
.brand:hover .path { color: var(--fg-bright); }

.switch { display: flex; gap: 0; margin-left: 8px; }
.switch a {
  text-decoration: none;
  font-size: 11.5px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-right: 0;
  color: var(--dim);
  background: #060b08;
}
.switch a:last-child { border-right: 1px solid var(--line); }
.switch a:hover { color: var(--fg-bright); background: #0a1510; }
.switch a.on {
  color: #041007;
  background: var(--accent);
  border-color: var(--accent);
}

.topbar-spacer { flex: 1; }

.src-link {
  font-size: 11px;
  color: var(--dim-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}
.src-link:hover { color: var(--accent); }

/* ---------- layout ---------- */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  align-items: start;
}

.side {
  position: sticky;
  top: 44px;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 0 0 48px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.side-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px 8px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim-2);
}

.catnav { display: flex; flex-direction: column; }
.catnav a {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 3px 12px;
  text-decoration: none;
  color: var(--dim);
  font-size: 12px;
  border-left: 2px solid transparent;
}
.catnav a:hover { color: var(--fg-bright); background: #0a1510; border-left-color: var(--accent); }
.catnav .cn { flex: 1; }
.catnav .cc { color: var(--dim-2); font-variant-numeric: tabular-nums; font-size: 11px; }
.catnav a.off { opacity: 0.35; }

.content {
  padding: 0 18px 90px;
  min-width: 0;
}

/* ---------- controls ---------- */

.controls {
  position: sticky;
  top: 44px;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  background: rgba(5, 8, 10, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px dashed var(--line);
}

.search {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 5px 9px;
  min-width: 0;
}
.search:focus-within { border-color: var(--accent-dim); }
.search .p { color: var(--accent); font-size: 12px; }
.search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg-bright);
  font: inherit;
  font-size: 12.5px;
}
.search input::placeholder { color: var(--dim-2); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
.hits { color: var(--dim-2); font-size: 10.5px; white-space: nowrap; }

.sorts { display: flex; align-items: center; gap: 6px; }
.lab { color: var(--dim-2); font-size: 10.5px; letter-spacing: 0.1em; }
.sbtn {
  font: inherit;
  font-size: 11.5px;
  padding: 4px 9px;
  color: var(--dim);
  background: #060b08;
  border: 1px solid var(--line);
  cursor: pointer;
}
.sbtn:hover { color: var(--fg-bright); border-color: var(--accent-dim); }
.sbtn.on { color: #041007; background: var(--accent); border-color: var(--accent); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 0 0;
  font-size: 11px;
  color: var(--dim);
}
.legend .sep { color: var(--line); }
.legend .dim { color: var(--dim-2); }
.legend .tr { color: var(--accent); font-weight: 400; }

/* ---------- categories ---------- */

.cat { scroll-margin-top: 104px; }

.cat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 30px 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.cat-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: 0.01em;
}
.cat-head .en {
  margin-left: 9px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--dim-2);
  letter-spacing: 0.02em;
}
.cat-head .num {
  margin-left: auto;
  color: var(--accent);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.cat-desc {
  margin: 7px 0 12px;
  color: var(--dim);
  font-size: 12px;
  max-width: 100ch;
}

.cards { display: grid; grid-template-columns: 1fr; }

/* ---------- card ---------- */

.card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  padding: 9px 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  content-visibility: auto;
  contain-intrinsic-size: auto 66px;
}
.card:hover { background: #081109; }
.card.archived { opacity: 0.62; }
.card.archived:hover { opacity: 0.9; }

.ic img, .ic .ph {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #000;
}
.ic .ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: hsl(var(--h), 70%, 68%);
  background: hsl(var(--h), 55%, 8%);
  border-color: hsl(var(--h), 40%, 22%);
}

.title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.name {
  color: var(--fg-bright);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.name:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.tag {
  font-size: 10px;
  line-height: 15px;
  padding: 0 5px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag.stars { color: var(--amber); border-color: #3a2f10; background: #100d03; }
.tag.ver {
  color: var(--blue);
  border-color: #14304a;
  background: #040a10;
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag.arch { color: var(--red); border-color: #4a1714; background: #120404; display: inline-flex; align-items: center; gap: 4px; }
.tag.tr { color: var(--accent); border-color: var(--accent-dim); background: #04120a; text-transform: uppercase; }

.desc {
  margin: 3px 0 5px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #93a89a;
  max-width: 120ch;
  overflow-wrap: anywhere;
}
.desc.ru { color: #b9d3c0; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--dim-2);
}
.meta .sep { color: var(--line); }
.meta .lic { color: #8fae9a; }
.upd { font-variant-numeric: tabular-nums; }

.act { display: flex; align-items: center; gap: 6px; padding-top: 1px; }
.go {
  border: 1px solid var(--line);
  padding: 1px 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  line-height: 18px;
}
.go:hover { background: var(--accent); color: #041007; border-color: var(--accent); }
.src {
  margin-left: 2px;
  border: 1px solid var(--line-soft);
  color: var(--dim-2);
  text-decoration: none;
  font-size: 9.5px;
  padding: 2px 5px;
  line-height: 14px;
  flex: none;
}
.src:hover { color: var(--fg-bright); border-color: var(--line); }

/* ---------- empty / footer ---------- */

.empty {
  margin: 60px auto;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.empty p { margin: 0 0 10px; }
.empty b { color: var(--fg-bright); font-weight: 600; }
.link {
  background: none;
  border: 0;
  border-bottom: 1px dotted var(--accent-dim);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.link:hover { border-bottom-style: solid; }

.foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--dim-2);
}
.foot a { color: var(--dim); text-decoration: none; border-bottom: 1px dotted var(--line); }
.foot a:hover { color: var(--accent); }
.foot .dim { color: var(--dim-2); }

/* ---------- home ---------- */

.home {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 44px - 45px);
  display: grid;
  place-items: center;
  padding: 28px 18px 40px;
}

.screen {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #071009 0%, #05080a 100%);
  box-shadow: 0 0 0 1px #0a120d, 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(57, 255, 136, 0.05);
  padding: 18px 22px 22px;
}

.bootline {
  font-size: 11.5px;
  color: var(--dim);
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.bootline .prompt { color: var(--accent); }
.bootline .colon { color: var(--dim-2); }
.bootline .dim { color: var(--dim-2); }

.boot div {
  font-size: 12.5px;
  color: #8fb79b;
  line-height: 1.8;
  white-space: pre-wrap;
}
.boot .ok { color: var(--accent); }
.boot b { color: var(--fg-bright); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Явные переносы в блоке загрузки: на широком экране каждая строка целиком,
   на телефоне — по смыслу, а не там, где кончилась ширина. */
br.ml { display: none; }

.choose { margin: 20px 0 9px; color: var(--fg-bright); font-size: 13px; }
.choose.center { text-align: center; }

.entry {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #060b08;
  padding: 11px 13px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--fg-bright);
  font-size: 14px;
}
.entry:hover { background: #0a1810; border-color: var(--accent); }
.entry .key { color: var(--fg-bright); }
.entry:hover .key { color: var(--accent); }
.dots { flex: 1; border-bottom: 1px dotted var(--line); height: 1px; margin: 0 4px; }
.entry .cnt { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.entry .arrow { color: var(--accent); }

.hint {
  margin: 14px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim-2);
  max-width: 90ch;
}

.cursor {
  margin-top: 12px;
  color: var(--accent);
  animation: blink 1.05s steps(1) infinite;
  font-size: 13px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- топ-12 на главной: список прямоугольников ---------- */

.tiles {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 10px 0 0;
}

.tile {
  display: grid;
  grid-template-columns: 17px 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 4px 10px 4px 7px;
  border: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
  background: linear-gradient(90deg, #08120c 0%, #060b08 55%, #050a07 100%);
  text-decoration: none;
}
.tile:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, #0b1a11 0%, #081310 60%, #06100a 100%);
}

.t-rank {
  font-size: 10px;
  line-height: 1;
  text-align: right;
  color: var(--dim-2);
  font-variant-numeric: tabular-nums;
}
.tile:hover .t-rank { color: var(--accent-dim); }

.t-ic {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #cfd8d0;
  border: 1px solid #aebdb1;
}
.tile:hover .t-ic { background: #e8efe9; border-color: var(--accent); }
.t-ic--dark { background: #060b08; border-color: var(--line); }
.tile:hover .t-ic--dark { background: #0a1810; border-color: var(--accent); }

.t-ic img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}
.t-ic .ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  color: hsl(var(--h), 60%, 26%);
  background: transparent;
  border: 0;
}
.t-ic--dark .ph { color: hsl(var(--h), 70%, 68%); }

.t-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.t-name {
  flex: none;
  max-width: 45%;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--fg-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile:hover .t-name { color: var(--accent); }
.t-desc {
  min-width: 0;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-stars {
  font-size: 10.5px;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.to-top {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #060b08;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { background: var(--accent); color: #041007; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .layout { display: block; }
  .side {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
    overflow: visible;
  }
  .side-head { padding-bottom: 4px; }
  .catnav {
    flex-direction: row;
    overflow-x: auto;
    gap: 0;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .catnav::-webkit-scrollbar { display: none; }
  .catnav { mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .catnav a {
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    padding: 6px 10px;
  }
  .catnav a:hover { border-left-color: transparent; border-bottom-color: var(--accent); }
  .content { padding: 0 12px 70px; }
  .home { place-items: start center; padding-top: 16px; }
  .controls { top: 44px; }
  .cat { scroll-margin-top: 150px; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .win-dots, .src-link { display: none; }
  br.ml { display: inline; }
  .boot div { line-height: 1.68; font-size: 12px; }
  .card { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; padding: 9px 6px 9px 4px; }
  .act { grid-column: auto; padding-top: 2px; }
  .ic img, .ic .ph { width: 22px; height: 22px; }
  .title { gap: 4px; }
  .src { font-size: 8.5px; padding: 1px 3px; line-height: 13px; margin-left: 1px; }
  .go { padding: 0 5px; line-height: 17px; font-size: 11px; }
  .desc { margin: 2px 0 4px; }
  .desc { font-size: 12px; }
  .tile { grid-template-columns: 15px 26px minmax(0, 1fr) auto; gap: 8px; }
  .t-ic { width: 26px; height: 26px; }
  .t-ic img { width: 18px; height: 18px; }
  .t-desc { display: none; }
  .t-name {
    flex: 0 1 auto;
    min-width: 0;
    max-width: none;
    font-size: 11.5px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .t-main { gap: 6px; }
  .t-stars { font-size: 10px; }
  .meta { font-size: 9.5px; gap: 4px; }
  .tag { font-size: 9.5px; line-height: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
}
