:root{
  color-scheme: dark;
  --bg:#070A12;
  --text:#E9EEFF;
  --muted:#AAB3D6;
  --line:rgba(255,255,255,.08);
  --brand:#2D7CFF;
  --heroH:42vh;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(45,124,255,.25), transparent 70%),
    radial-gradient(1200px 600px at 90% 10%, rgba(0,255,200,.12), transparent 70%),
    var(--bg);
  overflow:hidden; /* portal: no scroll */
}

a{ color:inherit; text-decoration:none; }
.container{ width:min(1120px, 92vw); margin:0 auto; }

.hero{
  position:relative;
  height:var(--heroH);
  min-height:320px;
  max-height:520px;
  display:flex;
  align-items:flex-end;
  overflow:hidden;
  border-bottom:1px solid var(--line);
}

.hero-bg{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
  transform:scale(1.02);
  filter:saturate(1.1) contrast(1.05);
}

.hero-overlay{
  position:absolute; inset:0;
  background: linear-gradient(180deg, rgba(7,10,18,.25) 0%, rgba(7,10,18,.92) 72%, rgba(7,10,18,1) 100%);
}

/* Top bar inside hero (logo top-left + admin top-right) */
.hero-topbar{
  position:absolute;
  top:14px;
  left:0;
  right:0;
  z-index:2;
}

.hero-topbar-inner{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
}

.brandmark{ display:inline-flex; align-items:flex-start; }

.hero-topbar .logo{
  width:140px;
  height:auto;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.45));
}

.hero-content{
  position:relative;
  width:min(1120px, 92vw);
  margin:0 auto;
  padding:74px 0 22px; /* space for top bar */
}

.hero-copy{
  max-width:740px;
  text-align:left;
}

.hero-copy h1{ margin:0; font-size: clamp(28px, 3.8vw, 44px); letter-spacing:.2px; }
.hero-copy p{ margin:8px 0 0; color:var(--muted); }

.hero-actions{
  display:flex;
  gap:10px;
  margin-top:14px;
  flex-wrap:wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  font-weight:650;
}
.btn:hover{ transform: translateY(-1px); border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.06); }

.btn-primary{
  background: linear-gradient(135deg, rgba(45,124,255,.95), rgba(45,124,255,.55));
  border-color: rgba(45,124,255,.45);
}
.btn-ghost{ background: rgba(255,255,255,.02); }

main.container{
  height: calc(100vh - var(--heroH));
  min-height: 320px;
  display:flex;
  flex-direction:column;
}

.grid-2{
  display:grid;
  grid-template-columns:1fr;
  gap:16px;
  padding:16px 0;
  flex:1;
  min-height:0;
}
@media (min-width:900px){
  .grid-2{ grid-template-columns:1fr 1fr; }
}

.card{
  background: linear-gradient(180deg, rgba(14,20,48,.92), rgba(11,16,38,.92));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
}

.card-head{
  padding:16px 16px 12px;
  border-bottom:1px solid var(--line);
}
.card-head h2{ margin:0; font-size:18px; }
.card-head p{ margin:6px 0 0; color:var(--muted); }

.toolbar{
  display:flex;
  gap:10px;
  padding:12px 16px 10px;
  flex-wrap:wrap;
  border-bottom:1px solid var(--line);
}

.search, .select{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#0b1026;
  color:#ffffff;
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;
}

.search{ flex:1; min-width:210px; }
.select{ min-width:170px; }

.select option{
  background:#0b1026;
  color:#ffffff;
}

.list{
  padding:10px 10px 14px;
  flex:1;
  min-height:0;
}
/* Smooth transition when switching "pages" */
.list{
  transition: opacity .14s ease, transform .14s ease;
}

.list.is-transitioning{
  opacity: 0;
  transform: translateY(6px);
}
.item{
  min-width:0;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  margin:10px 6px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
}

.item > div:first-child{ flex:1; min-width:0; }

.item-title{
  font-weight:700;
  display:-webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;   /* max 2 lines */
  overflow:hidden;
  text-overflow:ellipsis;
  overflow-wrap:anywhere;
  word-break:break-word;
}

.item-meta{ color:var(--muted); font-size:12px; margin-top:4px; }

.item-actions{
  display:flex;
  gap:8px;
  flex:0 0 auto;
  white-space:nowrap;
}

/* Pager */
.pager{
  position:relative;
  z-index:2;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 16px;
  border-top:1px solid var(--line);
  background: rgba(7,10,18,.86);
  backdrop-filter: blur(10px);
}

.pager .count{ color:var(--muted); font-size:12px; }
.pager .count.is-hidden{ display:none; }

.iconbtn{
  pointer-events:auto;
  width:40px;
  height:40px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.iconbtn:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
}
.iconbtn:disabled{
  opacity:.45;
  cursor:not-allowed;
  transform:none;
}

.footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 0 18px;
  border-top:1px solid var(--line);
}

.muted{ color:var(--muted); }
.small{ font-size:12px; }

/* Admin page (scroll allowed) */
.topbar{
  position:sticky; top:0;
  background: rgba(7,10,18,.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 0;
}
.topbar-left{ display:flex; align-items:center; gap:10px; }
.logo-sm{ width:34px; height:auto; opacity:.95; }

.admin-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 0;
}
@media (min-width: 900px){
  .admin-grid{ grid-template-columns: 1fr 1fr; }
}

.upload-form{ padding: 14px 16px 16px; }
.field{ display:block; margin-bottom: 12px; }
.field span{ display:block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="file"]{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
  color: var(--text);
  outline:none;
}

.notice{
  margin:10px 16px 0;
  padding:10px 12px;
  border:1px solid rgba(45,124,255,.35);
  background: rgba(45,124,255,.08);
  border-radius:14px;
  color: var(--text);
}

code{ color:#cfe0ff; }
/* Admin file manager rows */
.admin-filelist{ display:flex; flex-direction:column; gap:10px; }

.admin-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
  min-width:0;
}

.admin-row-left{ flex:1; min-width:0; }
.admin-row-title{
  font-weight:700;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.admin-row-meta{ color:var(--muted); font-size:12px; margin-top:4px; }

.admin-row-actions{ display:flex; gap:8px; flex:0 0 auto; white-space:nowrap; }

.btn-danger{
  border-color: rgba(255,90,90,.35);
  background: rgba(255,90,90,.12);
}
.btn-danger:hover{
  border-color: rgba(255,90,90,.55);
  background: rgba(255,90,90,.18);
}
