:root {
  --bg: #030603;
  --panel: rgba(4, 14, 8, 0.88);
  --panel-solid: #06120a;
  --green: #00ff9c;
  --green-dim: #0c7a4c;
  --green-dark: #08331f;
  --cyan: #00e5ff;
  --text: #b6ffd9;
  --muted: #4f9a76;
  --danger: #ff3860;
  --border: rgba(0, 255, 156, 0.28);
  --glow: 0 0 6px rgba(0, 255, 156, 0.55), 0 0 18px rgba(0, 255, 156, 0.2);
  --font: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  background: radial-gradient(ellipse at center, #062012 0%, var(--bg) 70%) fixed;
  color: var(--text);
  overflow-x: hidden;
}

::selection { background: var(--green); color: #000; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #020402; }
::-webkit-scrollbar-thumb { background: var(--green-dark); border: 1px solid var(--green-dim); }
::-webkit-scrollbar-thumb:hover { background: var(--green-dim); }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 4px 0 0; text-shadow: 0 0 6px rgba(255, 56, 96, 0.6); }
.error::before { content: "[ERR] "; font-weight: 700; }

/* ---------- Fon: Matrix yomg'iri + CRT effekti ---------- */
#matrix {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.22;
  pointer-events: none;
}

.crt {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
  animation: flicker 6s infinite steps(1);
}
.crt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, transparent, rgba(0, 255, 156, 0.05), transparent);
  animation: scan 7s linear infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 0.92; }
  48% { opacity: 1; }
  82% { opacity: 0.95; }
}
@keyframes scan {
  from { top: -120px; }
  to { top: 100%; }
}

/* ---------- Inputlar ---------- */
input, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: rgba(0, 20, 10, 0.7);
  color: var(--green);
  font: inherit;
  caret-color: var(--green);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder, textarea::placeholder { color: var(--green-dim); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: var(--glow), inset 0 0 12px rgba(0, 255, 156, 0.08);
}
textarea { resize: vertical; }

input[type="file"] { padding: 6px; color: var(--muted); cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit;
  margin-right: 12px;
  padding: 5px 12px;
  border: 1px solid var(--green-dim);
  background: var(--green-dark);
  color: var(--green);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
input[type="file"]::file-selector-button:hover { background: var(--green); color: #000; }

/* ---------- Tugmalar ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--green-dim);
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
  z-index: 0;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
  z-index: -1;
}
.btn:hover:not(:disabled) { color: #000; border-color: var(--green); box-shadow: var(--glow); }
.btn:hover:not(:disabled)::before { transform: scaleX(1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn:focus-visible { outline: 1px dashed var(--green); outline-offset: 3px; }

.btn-primary { border-color: var(--green); box-shadow: 0 0 8px rgba(0, 255, 156, 0.25); text-shadow: 0 0 6px rgba(0, 255, 156, 0.6); }
.btn-primary:hover:not(:disabled) { text-shadow: none; }

.btn-danger { color: var(--danger); border-color: rgba(255, 56, 96, 0.5); }
.btn-danger::before { background: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); box-shadow: 0 0 10px rgba(255, 56, 96, 0.5); }

.icon-btn {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 8px;
  transition: color 0.2s, transform 0.2s;
}
.icon-btn:hover { color: var(--danger); transform: rotate(90deg); }

/* ---------- Glitch logo ---------- */
.logo {
  position: relative;
  display: inline-block;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--green);
  text-shadow: var(--glow);
  user-select: none;
}
.logo::before { content: ">_ "; color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.glitch::after {
  content: ">_ " attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--cyan);
  text-shadow: -2px 0 var(--danger);
  clip-path: inset(0 0 100% 0);
  animation: glitch 4s infinite steps(1);
}
@keyframes glitch {
  0%, 88%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  89% { clip-path: inset(10% 0 60% 0); transform: translate(-3px, 0); }
  91% { clip-path: inset(55% 0 20% 0); transform: translate(3px, 0); }
  93% { clip-path: inset(30% 0 45% 0); transform: translate(-2px, 1px); }
  95% { clip-path: inset(70% 0 5% 0); transform: translate(2px, -1px); }
  97% { clip-path: inset(0 0 100% 0); }
}

/* ---------- Terminal oyna ---------- */
.term {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 255, 156, 0.12), inset 0 0 40px rgba(0, 255, 156, 0.04);
  backdrop-filter: blur(3px);
}
.term-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 255, 156, 0.06);
  color: var(--muted);
  font-size: 12px;
}
.term-head h2 {
  flex: 1;
  margin: 0;
  font-size: 14px;
  color: var(--green);
  overflow-wrap: anywhere;
}
.term-head h2::before { content: "root@filehub:~/"; color: var(--muted); font-weight: 400; }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }

/* ---------- Kirish ekrani ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 520px;
  animation: power-on 0.6s ease-out both;
}
.login-card .term-body { padding: 22px 22px 26px; display: grid; gap: 14px; }
.login-card .logo { font-size: 30px; justify-self: center; }

.boot {
  margin: 0;
  min-height: 9.5em;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-wrap;
}
.boot .ok { color: var(--green); }
.boot .warn { color: #febc2e; }

.login-form { display: grid; gap: 12px; animation: fade-up 0.4s ease-out both; }
.prompt-line { display: grid; gap: 6px; }
.prompt { color: var(--cyan); text-shadow: 0 0 6px rgba(0, 229, 255, 0.5); }
.login-form .btn { width: 100%; padding: 10px; }

@keyframes power-on {
  0% { transform: scale(1, 0.005); filter: brightness(4); opacity: 0; }
  40% { transform: scale(1, 0.005); filter: brightness(4); opacity: 1; }
  70% { transform: scale(1, 1.02); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: none; }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Miltillovchi kursor */
.cursor::after {
  content: "█";
  margin-left: 2px;
  color: var(--green);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Yuqori panel ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: rgba(3, 8, 5, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  animation: slide-down 0.5s ease-out both;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1px;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  animation: border-run 4s linear infinite;
}
@keyframes border-run {
  from { transform: translateX(-100%); }
  to { transform: translateX(400%); }
}
@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.search {
  flex: 1;
  max-width: 540px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  background: rgba(0, 20, 10, 0.7);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--green); box-shadow: var(--glow); }
.search-prefix { padding: 0 4px 0 12px; color: var(--cyan); white-space: nowrap; }
.search input { border: none; background: transparent; box-shadow: none !important; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.container { max-width: 1240px; margin: 0 auto; padding: 22px 24px 60px; }

.stats { color: var(--muted); margin: 0 0 18px; min-height: 1.4em; }
.stats::before { content: "$ ls -lh ./apps  →  "; color: var(--green-dim); }

/* ---------- Kartochkalar ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  overflow: hidden;
  animation: card-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.grid.no-anim .card { animation: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
/* Burchak qavslari */
.card::before, .card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--green);
  border-style: solid;
  z-index: 2;
  transition: width 0.3s, height 0.3s;
}
.card::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.card::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.card:hover {
  transform: translateY(-4px);
  border-color: var(--green);
  box-shadow: 0 0 22px rgba(0, 255, 156, 0.25);
}
.card:hover::before, .card:hover::after { width: 40px; height: 40px; }

.card-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(rgba(0, 255, 156, 0.06) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(0, 255, 156, 0.06) 1px, transparent 1px) 0 0 / 16px 16px,
    #020905;
  color: var(--green);
  font-size: 30px;
  font-weight: 800;
  text-shadow: var(--glow);
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.55) contrast(1.1) brightness(0.85) sepia(0.25) hue-rotate(75deg);
  transition: filter 0.4s, transform 0.4s;
}
.card:hover .card-cover img { filter: none; transform: scale(1.06); }
/* Skaner chizig'i */
.card-cover::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -30%;
  height: 30%;
  background: linear-gradient(180deg, transparent, rgba(0, 255, 156, 0.35), transparent);
  opacity: 0;
}
.card:hover .card-cover::after { opacity: 1; animation: card-scan 1.2s linear infinite; }
@keyframes card-scan {
  from { top: -30%; }
  to { top: 100%; }
}

.card-body { padding: 12px 14px; display: grid; gap: 4px; flex: 1; }
.card-title { font-weight: 700; font-size: 15px; color: var(--green); overflow-wrap: anywhere; }
.card-title::before { content: "> "; color: var(--muted); }
.card-info { font-size: 12px; color: var(--muted); }
.card-actions { padding: 0 14px 14px; }
.card-actions .btn { width: 100%; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 400;
  vertical-align: middle;
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  font-size: 15px;
  animation: fade-up 0.4s both;
}
.empty::before { content: "[404] "; color: var(--danger); }

/* ---------- Dialoglar ---------- */
.dialog {
  width: min(660px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--text);
  background: var(--panel-solid);
  border-radius: 0;
}
.dialog[open] { animation: dialog-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.dialog::backdrop { background: rgba(0, 5, 2, 0.75); backdrop-filter: blur(3px); }
@keyframes dialog-in {
  0% { opacity: 0; clip-path: inset(50% 0 50% 0); }
  60% { opacity: 1; clip-path: inset(0 0 0 0); filter: brightness(1.8); }
  100% { clip-path: inset(0 0 0 0); filter: none; }
}
.dialog > form { display: contents; }
.dialog-body { padding: 18px 20px; display: grid; gap: 14px; }
.dialog-body label { display: grid; gap: 6px; color: var(--cyan); font-size: 13px; }
.dialog-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0, 255, 156, 0.03);
}
.dialog-foot > div { display: flex; gap: 8px; flex-wrap: wrap; }

.gallery { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.gallery:empty { display: none; }
.gallery img {
  height: 170px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.gallery img:hover { transform: scale(1.03); border-color: var(--green); box-shadow: var(--glow); }

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 0;
  padding: 12px 14px;
  border: 1px dashed var(--green-dark);
  font-size: 13px;
}
.meta dt { color: var(--muted); }
.meta dt::after { content: ":"; }
.meta dd { margin: 0; color: var(--green); overflow-wrap: anywhere; }
.desc { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); line-height: 1.6; }
.desc:empty { display: none; }
.desc::before { content: "# "; color: var(--muted); }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 88px; height: 88px; animation: fade-up 0.3s both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border: 1px solid var(--border); }
.thumb.new img { border: 1px dashed var(--cyan); box-shadow: 0 0 8px rgba(0, 229, 255, 0.35); }
.thumb button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--danger);
  background: #1a0006;
  color: var(--danger);
  font-size: 11px;
  line-height: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.thumb button:hover { background: var(--danger); color: #000; }

/* ---------- Progress bar ---------- */
.progress { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 14px; padding: 2px; border: 1px solid var(--green-dim); }
#progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--green) 0 8px, transparent 8px 11px);
  box-shadow: var(--glow);
  transition: width 0.15s;
  animation: stripes 0.6s linear infinite;
}
@keyframes stripes { to { background-position: 11px 0; } }
#progress-text { min-width: 140px; text-align: right; font-size: 12px; color: var(--green); }

/* ---------- Lightbox ---------- */
.lightbox { padding: 0; border: 1px solid var(--green); background: #000; max-width: 95vw; max-height: 95vh; box-shadow: 0 0 40px rgba(0, 255, 156, 0.3); }
.lightbox[open] { animation: dialog-in 0.35s both; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.9); }
.lightbox img { display: block; max-width: 95vw; max-height: 95vh; cursor: zoom-out; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 100;
  padding: 10px 18px;
  border: 1px solid var(--green);
  background: rgba(0, 12, 6, 0.95);
  color: var(--green);
  box-shadow: var(--glow);
  transform: translateX(-50%);
  animation: toast-in 0.3s ease-out;
}
.toast::before { content: "[OK] "; font-weight: 700; }
.toast.error { border-color: var(--danger); color: var(--danger); box-shadow: 0 0 14px rgba(255, 56, 96, 0.5); }
.toast.error::before { content: "[ERR] "; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Mobil ---------- */
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search-prefix { display: none; }
  .logo { font-size: 18px; letter-spacing: 2px; }
  .container { padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .gallery img { height: 130px; }
  .stats::before { content: "$ ls  →  "; }
}

/* Animatsiyani kamaytirishni so'ragan foydalanuvchilar uchun */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #matrix { display: none; }
}
