:root{
  color-scheme: dark;

  --bg: #0b0d14;
  --panel: #12162a;
  --text: #e9ecff;
  --muted: #a7afd6;
  --line: rgba(255,255,255,0.12);
  --link: #7aa2ff;
  --accent: rgba(247,210,74,0.18);
  --danger: #ff6b7a;
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

.logo{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  flex: 0 0 auto;
}

.title{ font-weight: 900; letter-spacing: .2px; line-height: 1.15; }
.subtitle{ font-size: 12px; color: var(--muted); line-height: 1.25; margin-top: 2px; }

.actions{ display:flex; align-items:center; gap: 8px; }

.container{ max-width: 1100px; margin: 0 auto; padding: 18px 16px; }

.btn{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.btn:hover{ background: rgba(255,255,255,0.10); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }

.btn-small{ padding: 6px 10px; border-radius: 10px; font-size: 12px; }

.btn-ghost{
  background: transparent;
}
.btn-ghost:hover{
  background: rgba(255,255,255,0.06);
}

.btn-primary{
  border-color: rgba(247,210,74,0.35);
  background: var(--accent);
}
.btn-primary:hover{
  background: rgba(247,210,74,0.24);
}

.btn-danger{
  border-color: rgba(255,107,122,0.45);
  background: rgba(255,107,122,0.12);
}
.btn-danger:hover{
  background: rgba(255,107,122,0.18);
}

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

.card{
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px;
  background: rgba(18,22,42,0.88);
  box-shadow: 0 18px 45px rgba(0,0,0,0.35);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.thumb{
  width: 100%;
  height: 150px;
  object-fit: contain;        /* scale by width + height */
  object-position: center;
  display: block;
  background: rgba(255,255,255,0.06);
}

.card-body{
  padding: 12px 12px 14px 12px;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.card-title{
  font-weight: 900;
  letter-spacing: .2px;
}

.card-desc{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  min-height: 18px;
}

.card-link{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


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

/* ---- Admin full-page view (not a modal) ---- */
.hidden{ display:none !important; }

.admin-page{
  min-height: calc(100vh - 64px);
  padding: 12px 0 26px 0;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  background: radial-gradient(1200px 520px at 50% 0%, rgba(122,162,255,0.14), transparent 58%);
}

.admin-shell{
  width: 50%;
  max-width: 980px;
  padding: 0 16px;
}

/* Responsive fallback */
@media (max-width: 900px){
  .admin-shell{ width: 100%; }
}

.admin-stage{
  width: 100%;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  background: rgba(18,22,42,0.98);
  box-shadow: 0 18px 70px rgba(0,0,0,0.65);
  overflow: hidden;
}

.admin-stage-header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  flex-wrap: wrap;
}

.admin-stage-title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
}

.admin-stage-subtitle{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
  margin-top: 4px;
}

.admin-stage-body{ padding: 14px; }


/* ---- Modal system ---- */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
}

.modal{
  width: min(920px, 100%);
  max-height: 82vh;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  background: rgba(18,22,42,0.98);
  box-shadow: 0 18px 70px rgba(0,0,0,0.65);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.modal-title{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .2px;
}

.modal-body{
  padding: 14px;
}

.panel{
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  padding: 14px;
}

.row{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.row-between{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.sep{
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  margin: 12px 0;
}

.label{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

input, textarea{
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea{ min-height: 90px; resize: vertical; }

input:focus, textarea:focus{
  border-color: rgba(122,162,255,0.65);
  box-shadow: 0 0 0 3px rgba(122,162,255,0.18);
}

.chk{
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.chk2{
  justify-content: flex-start;
  color: var(--text);
}
.chk2 span{ color: var(--muted); }

.chk2 input[type="checkbox"]{
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  display: inline-grid;
  place-content: center;
  margin: 0;
}
.chk2 input[type="checkbox"]:focus{
  outline: none;
  border-color: rgba(122,162,255,0.65);
  box-shadow: 0 0 0 3px rgba(122,162,255,0.18);
}
.chk2 input[type="checkbox"]::before{
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  transform: scale(0);
  transition: transform .12s ease-in-out;
  background: var(--link);
}
.chk2 input[type="checkbox"]:checked::before{
  transform: scale(1);
}

.subpanel{
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  padding: 12px;
}

.img-local-path{
  width: 100%;
  font-size: 12px;
  color: var(--text);
  opacity: .9;
}

.img-path{
  max-width: 100%;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  min-width: 0;
}

.list{ display:flex; flex-direction: column; gap: 10px; }

.item{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  flex-wrap: wrap;
  min-width: 0;
}

.item.dragging{ opacity: .6; }

.name{ font-weight: 900; }
.meta{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.pill{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  color: var(--text);
}
.pill.off{
  border-color: rgba(255,107,122,0.45);
  background: rgba(255,107,122,0.12);
  color: #ffd0d6;
}

.preview{
  width: 100%;
  height: 180px;
  object-fit: contain;        /* scale by width + height */
  object-position: center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
}

/* ---- Toast ---- */
.toast-root{
  position: fixed;
  right: 14px;
  bottom: 14px;
  display:flex;
  flex-direction: column;
  gap: 10px;
  z-index: 5000;
}

.toast{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(18,22,42,0.98);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 18px 45px rgba(0,0,0,0.45);
  color: var(--text);
  font-size: 13px;
}
.toast.ok{ border-color: rgba(247,210,74,0.35); }
.toast.err{ border-color: rgba(255,107,122,0.55); }
