/* ---------------------------------------------------------------- base --- */
:root {
  --bg: #0a0b0f;
  --bg-2: #0e1016;
  --surface: #141722;
  --surface-2: #1a1e2b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e9ecf4;
  --muted: #99a0b3;
  --accent: #6d5dfc;
  --accent-2: #22d3ee;
  --danger: #f43f5e;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(109, 93, 252, 0.18), transparent 60%),
    radial-gradient(800px 420px at 5% 0%, rgba(34, 211, 238, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

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

h1, h2, h3 {
  line-height: 1.15;
  margin: 0;
}

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

.hidden,
[hidden] {
  display: none !important;
}

main {
  width: min(1400px, 100% - 2.5rem);
  margin: 0 auto;
  padding-bottom: 4rem;
}

/* -------------------------------------------------------------- header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(10, 11, 15, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}

.brand em {
  font-style: normal;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-2), transparent 45%),
    linear-gradient(135deg, var(--accent), #3b2fb8);
  box-shadow: 0 6px 18px rgba(109, 93, 252, 0.45);
}

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search input:focus {
  border-color: rgba(109, 93, 252, 0.7);
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.18);
}

.header-link {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: 0.15s;
  white-space: nowrap;
}

.header-link:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
}

/* ---------------------------------------------------------------- hero --- */
.hero {
  padding: clamp(3rem, 8vw, 5.5rem) 0 2rem;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.08);
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.grad {
  background: linear-gradient(90deg, #3b82f6 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 1.1rem auto 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
}

.hero-stats {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-stats span {
  color: var(--text);
  font-weight: 700;
}

/* ------------------------------------------------------------- toolbar --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 1.4rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: 0.15s;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(109, 93, 252, 0.35);
}

.toolbar-right {
  display: flex;
  gap: 0.6rem;
}

select {
  appearance: none;
  padding: 0.55rem 2.2rem 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2399a0b3' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 0.5rem center / 18px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

select:focus {
  border-color: rgba(109, 93, 252, 0.7);
}

/* ---------------------------------------------------------------- grid --- */
.grid {
  columns: 4 260px;
  column-gap: 1.1rem;
}

.card {
  break-inside: avoid;
  margin-bottom: 1.1rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(109, 93, 252, 0.55);
  outline: none;
}

.card-media {
  position: relative;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: auto;
  transition: transform 0.35s ease, filter 0.35s ease;
}

.card:hover .card-media img {
  transform: scale(1.05);
}

.badge,
.card-dl {
  position: absolute;
  bottom: 10px;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.badge {
  left: 10px;
  color: var(--accent-2);
}

.card-dl {
  right: 10px;
  color: var(--text);
}

.card-info {
  padding: 0.85rem 1rem 1rem;
}

.card-info h3 {
  font-size: 0.98rem;
  font-weight: 650;
}

.card-info p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* skeleton */
.skeleton {
  break-inside: avoid;
  margin-bottom: 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* --------------------------------------------------------------- empty --- */
.empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}

.empty h1,
.empty h2 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.empty-art {
  width: 120px;
  height: 90px;
  margin: 0 auto 1.4rem;
  border-radius: 14px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  position: relative;
}

.empty-art::after {
  content: "";
  position: absolute;
  inset: auto 18px 14px 18px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  clip-path: polygon(0 100%, 30% 34%, 52% 68%, 70% 44%, 100% 100%);
  opacity: 0.7;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 1.8rem;
}

/* ------------------------------------------------------------- buttons --- */
.btn {
  padding: 0.7rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4338ca);
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(109, 93, 252, 0.35);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: #fecdd3;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.12);
}

.btn.tiny {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------------ progress --- */
.progress {
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin: 0.9rem 0;
}

.progress .bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.progress-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.progress.indeterminate .bar {
  width: 35%;
  animation: indeterminate 1.1s ease-in-out infinite alternate;
}

@keyframes indeterminate {
  from {
    transform: translateX(-10%);
  }
  to {
    transform: translateX(285%);
  }
}

/* ---------------------------------------------------------- lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: 1fr min(360px, 34vw);
  gap: 0;
  background: rgba(5, 6, 9, 0.94);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lightbox.open {
  opacity: 1;
}

.lb-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(2.5rem, 6vw, 4rem);
  min-width: 0;
}

.lb-stage img {
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: opacity 0.25s ease;
}

.lb-loading {
  position: absolute;
  color: var(--muted);
  font-size: 0.9rem;
}

.lb-panel {
  padding: clamp(1.5rem, 3vw, 2.2rem);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.lb-category {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.lb-panel h2 {
  margin: 0.4rem 0 0.8rem;
  font-size: 1.5rem;
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tag {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background: rgba(109, 93, 252, 0.16);
  border: 1px solid rgba(109, 93, 252, 0.35);
  color: #c8c3ff;
}

.lb-meta {
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.5rem;
}

.lb-meta div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 0.45rem;
}

.lb-meta dt {
  color: var(--muted);
}

.lb-meta dd {
  margin: 0;
  font-weight: 600;
}

.lb-open {
  display: block;
  text-align: center;
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.lb-open:hover {
  color: var(--accent-2);
}

.lb-close,
.lb-nav {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(20, 23, 34, 0.85);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s;
}

.lb-close:hover,
.lb-nav:hover {
  background: var(--accent);
  border-color: transparent;
}

.lb-close {
  top: 1rem;
  right: 1rem;
}

.lb-prev,
.lb-next {
  top: 50%;
  transform: translateY(-50%);
}

.lb-prev {
  left: 1rem;
}

.lb-next {
  right: calc(min(360px, 34vw) + 1rem);
}

/* -------------------------------------------------------------- footer --- */
.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.6rem clamp(1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* --------------------------------------------------------------- toast --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translate(-50%, 20px);
  z-index: 120;
  padding: 0.75rem 1.2rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  max-width: min(90vw, 480px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind='success'] {
  border-color: rgba(34, 211, 238, 0.5);
}

.toast[data-kind='error'] {
  border-color: rgba(244, 63, 94, 0.55);
}

/* --------------------------------------------------------------- admin --- */
.admin-main {
  width: min(1100px, 100% - 2rem);
  margin: 2rem auto 4rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 1.8rem);
}

.signin {
  max-width: 420px;
  margin: 8vh auto 0;
}

.signin h1 {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.admin-head h1,
.admin-head h2 {
  font-size: 1.3rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 1.2rem;
  align-items: start;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

input[type='text'],
input[type='email'],
input[type='password'],
select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(109, 93, 252, 0.7);
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.15);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.drop {
  display: grid;
  place-items: center;
  gap: 0.3rem;
  padding: 1.8rem 1rem;
  margin-bottom: 1rem;
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: var(--bg-2);
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
}

.drop:hover,
.drop.drag {
  border-color: var(--accent);
  background: rgba(109, 93, 252, 0.1);
}

.drop-title {
  color: var(--text);
  font-weight: 600;
}

.drop-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.preview {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 0.7rem;
}

.file-meta {
  font-size: 0.82rem;
  margin: -0.4rem 0 0.9rem;
}

.form-error {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
}

.code-block {
  position: relative;
  margin: 1rem 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.code-block .btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
}

.code-block pre {
  margin: 0;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  padding-right: 4rem;
}

.hint-list {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  display: grid;
  gap: 0.4rem;
}

code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 0.1em 0.4em;
}

.code-block code {
  background: none;
  padding: 0;
}

.lib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.lib-item {
  display: grid;
  grid-template-columns: 74px 1fr auto auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
}

.lib-item img {
  width: 74px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
}

.lib-info {
  display: grid;
  min-width: 0;
}

.lib-info strong {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-info span {
  font-size: 0.78rem;
}

.pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.pill.on {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.pill.off {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.lib-actions {
  display: flex;
  gap: 0.4rem;
}

/* ---------------------------------------------------------- responsive --- */
@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow-y: auto;
  }

  .lb-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .lb-next {
    right: 1rem;
  }

  .lb-stage {
    padding: 4rem 1rem 1rem;
  }

  .lb-stage img {
    max-height: 52vh;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
  }

  .search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .grid {
    columns: 2 150px;
    column-gap: 0.75rem;
  }

  .card {
    margin-bottom: 0.75rem;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .lib-item {
    grid-template-columns: 60px 1fr;
    grid-auto-rows: auto;
  }

  .lib-item .pill,
  .lib-actions {
    grid-column: 2;
    justify-self: start;
  }
}
