:root {
  --bg: #0d0d0f;
  --panel: #16161a;
  --panel-2: #1d1d22;
  --line: #2a2a31;
  --text: #ecedf0;
  --muted: #8b8d98;
  --accent: #e8e8ea;
  --danger: #ff4d4d;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ------------------------------------------------------------------ header */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(13, 13, 15, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  letter-spacing: .14em;
  font-size: 15px;
  text-decoration: none;
}

.count { color: var(--muted); font-size: 13px; margin-left: 10px; letter-spacing: 0; font-weight: 400; }

.usermenu { position: relative; }

.userbtn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.userbtn:hover { background: var(--panel-2); }
.userbtn .caret { color: var(--muted); font-size: 10px; }

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  display: none;
}
.dropdown.open { display: block; }
.dropdown button, .dropdown a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.dropdown button:hover, .dropdown a:hover { background: var(--panel-2); }
.dropdown .logout { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------------- grid */
main { padding: 22px 20px 60px; max-width: 1500px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: #3a3a44; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card .meta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 12px 11px;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card .name {
  font-size: 12px;
  color: #d8d9de;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dl {
  flex: none;
  background: #fff;
  color: #000;
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.dl:hover { background: #d9d9dd; }
.dl:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------ busy overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 8, 10, .74);
  backdrop-filter: blur(3px);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  text-align: center;
  padding: 14px;
}
.card.busy .overlay { display: flex; }
.card.busy img { filter: grayscale(.5) brightness(.75); }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card.taken { animation: fade .45s ease forwards; pointer-events: none; }
@keyframes fade { to { opacity: 0; transform: scale(.94); } }

.empty { color: var(--muted); text-align: center; padding: 80px 20px; }

/* ------------------------------------------------------------------ login */
.loginwrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.loginbox {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 28px;
}
.loginbox h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .16em; }
.loginbox p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; }

input[type=text], input[type=password] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  margin-bottom: 16px;
}
input:focus { outline: none; border-color: #4a4a57; }

button.primary {
  width: 100%;
  background: #fff;
  color: #000;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
button.primary:hover { background: #d9d9dd; }
button.primary:disabled { opacity: .6; cursor: default; }

.err { color: var(--danger); font-size: 13px; min-height: 19px; margin: 0 0 10px; }

/* ------------------------------------------------------------------ admin */
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.section h2 { margin: 0 0 14px; font-size: 16px; }

.drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.drop.hot { border-color: #6b6b7a; color: var(--text); background: var(--panel-2); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 160px; }
.row input { margin-bottom: 0; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: #4a4a57; }
.btn.red { color: var(--danger); }
.mini { padding: 5px 10px; font-size: 12px; }
.muted { color: var(--muted); }
.ok { color: #4ade80; font-size: 13px; }
.bar { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 12px; display: none; }
.bar.on { display: block; }
.bar i { display: block; height: 100%; background: #fff; width: 0; transition: width .2s; }

.tabpane { display: none; }
.tabpane.active { display: block; }

.ctabox {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  min-height: 62px;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}
.ctabox.placeholder { color: var(--muted); font-size: 14px; }
.ctabar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn.big { padding: 13px 30px; font-size: 15px; font-weight: 650; background: #fff; color: #000; border-color: #fff; }
.btn.big:hover { background: #d9d9dd; }

/* -------------------------------------------------------------- header nav */
.headleft { display: flex; align-items: center; gap: 22px; min-width: 0; }

.nav { display: flex; gap: 2px; }
.nav button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.nav button:hover { color: var(--text); background: var(--panel); }
.nav button.active { color: var(--text); background: var(--panel-2); }

/* ------------------------------------------------------------- categories */
.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}
.cats button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 15px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.cats button:hover { color: var(--text); border-color: #4a4a57; }
.cats button.active { background: #fff; border-color: #fff; color: #000; font-weight: 600; }
.cats button .n { opacity: .55; margin-left: 6px; font-size: 12px; }
.cats:empty { display: none; }

.cathead {
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 26px 0 13px;
}
.catblock:first-child .cathead { margin-top: 0; }

@media (max-width: 620px) {
  header { flex-wrap: wrap; gap: 10px; }
  .headleft { gap: 14px; width: 100%; }
  .nav button { padding: 6px 11px; }
}
