:root{
  --bg:#0b0f17;
  --panel:#111827;
  --panel2:#0f172a;
  --card:#0b1220;
  --line:rgba(255,255,255,.08);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.60);
  --accent:#60a5fa;
  --danger:#fb7185;
  --ok:#34d399;
  --shadow:0 12px 30px rgba(0,0,0,.35);
  --radius:16px;
}

*{box-sizing:border-box}

a{color:inherit; text-decoration:none}

body{
  margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text); background: radial-gradient(1200px 700px at 20% 0%, #111b33, transparent 50%), var(--bg);
}

.app{display:flex; min-height:100vh}

.sidebar{
  width:280px; padding:22px 16px; border-right:1px solid var(--line);
  background: linear-gradient(180deg, rgba(17,24,39,.92), rgba(15,23,42,.92));
  position:sticky; top:0; height:100vh;
}

.brand{
  display:flex; align-items:center; gap:10px;
  padding:14px 14px; border:1px solid var(--line); border-radius:18px;
  background: rgba(255,255,255,.02);
  margin-bottom:16px;
}

.dot{width:10px; height:10px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 4px rgba(96,165,250,.12)}

.brand h1{font-size:14px; margin:0; letter-spacing:.6px; font-weight:650}
.brand p{margin:0; font-size:12px; color:var(--muted)}

.nav{display:flex; flex-direction:column; gap:6px; margin-top:10px}

.nav button{
  width:100%;
  background:transparent; border:1px solid transparent; color:var(--text);
  padding:12px 12px; border-radius:14px; text-align:left; cursor:pointer;
  display:flex; align-items:center; justify-content:space-between;
}

.nav button:hover{background:rgba(255,255,255,.03); border-color:var(--line)}
.nav button.active{background:rgba(96,165,250,.10); border-color:rgba(96,165,250,.35)}

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

.content{flex:1; padding:22px; max-width:1400px}

.topbar{
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom:14px;
}

.title h2{margin:0; font-size:18px}
.title p{margin:4px 0 0; font-size:12px; color:var(--muted)}

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

.btn{
  border:1px solid var(--line); background:rgba(255,255,255,.02); color:var(--text);
  padding:10px 12px; border-radius:14px; cursor:pointer;
}
.btn:hover{background:rgba(255,255,255,.04)}
.btn.primary{border-color:rgba(96,165,250,.45); background:rgba(96,165,250,.12)}
.btn.danger{border-color:rgba(251,113,133,.45); background:rgba(251,113,133,.10)}

.panel{
  border:1px solid var(--line); background:rgba(11,18,32,.55);
  border-radius:var(--radius); box-shadow: var(--shadow);
  padding:14px;
}

.row{display:flex; gap:10px; flex-wrap:wrap}

.field{
  display:flex; align-items:center; gap:10px;
  border:1px solid var(--line); background:rgba(255,255,255,.02);
  padding:10px 12px; border-radius:14px;
  min-width:220px; flex:1;
}

.field input, .field select{
  width:100%; background:transparent; border:0; outline:0;
  color:var(--text); font-size:14px;
}

select option{background:#0b0f17; color:#fff}

.hint{font-size:12px; color:var(--muted); margin-top:10px}

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

.card{
  border:1px solid var(--line);
  background: rgba(255,255,255,.02);
  border-radius:18px;
  overflow:hidden;
  position:relative;
  min-height:160px;
}

.thumb{
  height:130px; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  border-bottom:1px solid var(--line);
}

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

.meta{padding:10px 10px 12px}

.meta .name{font-size:13px; font-weight:650; margin:0 0 4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.meta .sub{font-size:12px; color:var(--muted); margin:0; display:flex; gap:8px; flex-wrap:wrap}

.badge{
  border:1px solid var(--line);
  padding:2px 8px; border-radius:999px; font-size:12px; color:var(--muted);
  background:rgba(255,255,255,.02);
}

/* hover menu */
.menuBtn{
  position:absolute; top:10px; right:10px;
  width:36px; height:36px; border-radius:12px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.20);
  color:var(--text); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  opacity:0; transform: translateY(-4px); transition: .15s ease;
}

.card:hover .menuBtn{opacity:1; transform: translateY(0)}

.dropdown{
  position:absolute; top:52px; right:10px;
  border:1px solid var(--line); background:rgba(15,23,42,.98);
  border-radius:14px; box-shadow: var(--shadow);
  min-width:160px; padding:6px; display:none;
  z-index:10;
}

.dropdown button{
  width:100%; text-align:left; border:0; cursor:pointer;
  background:transparent; color:var(--text);
  padding:10px 10px; border-radius:12px;
}

.dropdown button:hover{background:rgba(255,255,255,.04)}
.dropdown .danger{color:#fecaca}

/* Modal */
.modalWrap{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:none; align-items:center; justify-content:center;
  padding:18px; z-index:999;
}

.modal{
  width:min(720px, 100%);
  border:1px solid var(--line);
  border-radius:22px;
  background:rgba(15,23,42,.98);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.modalHeader{
  padding:16px 16px 12px;
  border-bottom:1px solid var(--line);
  display:flex; justify-content:space-between; align-items:center;
}

.modalHeader h3{margin:0; font-size:16px}

.modalBody{padding:16px}

.dropzone{
  border:1px dashed rgba(255,255,255,.20);
  border-radius:18px;
  background:rgba(255,255,255,.02);
  padding:18px;
  min-height:160px;
  display:flex; flex-direction:column; gap:10px;
  align-items:center; justify-content:center;
  text-align:center;
}

.dropzone.dragover{
  border-color: rgba(96,165,250,.70);
  background: rgba(96,165,250,.08);
}

.fileList{width:100%; max-height:180px; overflow:auto; border-top:1px solid var(--line); padding-top:10px}
.fileList div{font-size:13px; color:var(--muted); padding:4px 0}

.twoCol{display:grid; grid-template-columns: 1fr 1fr; gap:10px}

@media (max-width: 900px){
  .sidebar{display:none}
  .content{padding:16px}
  .twoCol{grid-template-columns:1fr}
}

/* Login */
.loginWrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:18px;
}
.loginCard{
  width:min(520px, 100%);
  border:1px solid var(--line); border-radius:22px;
  background:rgba(15,23,42,.98); box-shadow: var(--shadow);
  overflow:hidden;
}
.loginCard .head{padding:18px; border-bottom:1px solid var(--line)}
.loginCard h2{margin:0; font-size:18px}
.loginCard p{margin:6px 0 0; color:var(--muted); font-size:13px}
.loginCard .body{padding:18px}

.err{color:#fecaca; font-size:13px; margin-top:10px}


.flash{
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  padding:10px 12px;
  border-radius:14px;
  margin-right:12px;
  font-size:13px;
  color:var(--text);
}
.flash.ok{border-color:rgba(52,211,153,.45); background:rgba(52,211,153,.10)}
.flash.err{border-color:rgba(251,113,133,.45); background:rgba(251,113,133,.10); color:#fecaca}
.flash.info{}

/* File input styling */
input[type="file"]{
  width:100%;
  color:var(--muted);
  font-size:13px;
}

/* Open the upload modal without JS */
#uploadModal:target{
  display:flex;
}

#folderModal:target{display:flex;}

#previewModal:target{display:flex;}

.modalWide{width:min(1100px, 100%);}

.previewFrame{
  width:100%;
  height:min(72vh, 820px);
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(2,6,23,.55);
  overflow:hidden;
}
.previewFrame iframe{width:100%; height:100%; border:0; display:block; background:#0b1220;}
.previewFrame img{width:100%; height:100%; object-fit:contain; display:block;}
.previewOther{height:100%; display:flex; align-items:center; justify-content:center; padding:18px; color:var(--muted);}


.folderBar{display:flex; gap:8px; flex-wrap:wrap; margin-top:10px;}
.folderChip{
  border:1px solid rgba(148,163,184,.18);
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  color:var(--muted);
  background:rgba(2,6,23,.25);
  user-select:none;
}
.folderChip.dropTarget{
  border-color:rgba(96,165,250,.45);
  background:rgba(96,165,250,.08);
  color:var(--text);
}



/* Playlists */
.playlistLayout{
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.playlistLeft{flex: 1.4; min-width: 360px;}
.playlistRight{flex: 1; min-width: 320px; display:flex; flex-direction:column; gap:10px;}

.playlistList{
  border:1px solid rgba(148,163,184,.14);
  border-radius:18px;
  background:rgba(2,6,23,.20);
  overflow:hidden;
}
.plRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid rgba(148,163,184,.10);
  cursor:pointer;
}
.plRow:last-child{border-bottom:0}
.plRow:hover{background:rgba(255,255,255,.03)}
.plRow.active{background:rgba(96,165,250,.10); border-bottom-color:rgba(96,165,250,.18)}
.plRow .n{font-weight:750; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.plRow .c{font-size:12px; color:var(--muted);}

.playlistEditor{
  border:1px solid rgba(148,163,184,.14);
  border-radius:18px;
  background:rgba(2,6,23,.20);
  padding:12px;
}
.playlistEditorHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.plTitle{font-size:14px; font-weight:900;}
.plItems{display:flex; flex-direction:column; gap:8px; min-height:80px;}
.plItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border:1px solid rgba(148,163,184,.16);
  border-radius:16px;
  background:rgba(2,6,23,.25);
}
.plItem.dragover{border-color:rgba(96,165,250,.45); background:rgba(96,165,250,.06)}
.plItem .left{display:flex; align-items:center; gap:10px; min-width:0; flex:1;}
.plHandle{
  width:28px; height:28px;
  border-radius:12px;
  border:1px solid rgba(148,163,184,.16);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:var(--muted);
  cursor:grab;
  user-select:none;
}
.plItem .name{font-weight:750; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.plItem .meta{font-size:11px; color:var(--muted); margin-top:2px;}
.plItem .actions{display:flex; gap:8px; align-items:center;}
.plIconBtn{
  width:34px; height:34px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(15,23,42,.55);
  color:var(--text);
  cursor:pointer;
}
.plIconBtn:hover{background:rgba(255,255,255,.05)}

.plAddBtn{
  position:absolute;
  left:10px; top:10px;
  width:36px; height:36px;
  border-radius:14px;
  border:1px solid rgba(96,165,250,.35);
  background:rgba(96,165,250,.12);
  color:var(--text);
  cursor:pointer;
  display:none;
}
.card:hover .plAddBtn{display:inline-flex; align-items:center; justify-content:center;}
.plBadgeWrap{margin-top:8px; display:flex; gap:6px; flex-wrap:wrap;}
.plSmallBadge{
  font-size:10px;
  padding:2px 6px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.18);
  color:var(--muted);
}

/* Playlist duration input */
.plDurWrap{display:flex; align-items:center; gap:8px;}
.plDurLabel{font-size:11px; color:var(--muted);}
.plDurInput{
  width:88px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(2,6,23,.25);
  color:var(--text);
  outline:none;
}
.plDurInput:focus{border-color:rgba(96,165,250,.45)}

#playlistEditModal:target{display:flex;}
#mediaPickerModal:target{display:flex;}

/* Playlists list (only) */
.plRowActions{display:flex; gap:8px; align-items:center;}
.plEditBtn{
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(15,23,42,.55);
  color:var(--text);
  cursor:pointer;
}
.plEditBtn:hover{background:rgba(255,255,255,.05)}

/* Playlist description textarea */
#plEditDesc{
  width:100%;
  resize:vertical;
  min-height:74px;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(2,6,23,.25);
  color:var(--text);
  outline:none;
}
#plEditDesc:focus{border-color:rgba(96,165,250,.45)}
.sepDot{margin:0 8px; color:rgba(148,163,184,.55);}

/* Playlist status badge */
.plStatusBadge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:11px;
  font-weight:850;
  padding:3px 10px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(15,23,42,.55);
  color:var(--text);
  letter-spacing:.02em;
  white-space:nowrap;
}
.plStatus-draft{
  border-color:rgba(96,165,250,.35);
  background:rgba(96,165,250,.14);
}
.plStatus-active{
  border-color:rgba(52,211,153,.35);
  background:rgba(52,211,153,.14);
}
.plStatus-archived{
  border-color:rgba(148,163,184,.28);
  background:rgba(148,163,184,.10);
  color:rgba(226,232,240,.88);
}

/* Playlist item mini preview */
.plMiniThumb{
  width:44px;
  height:44px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(2,6,23,.25);
  overflow:hidden;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
}
.plMiniThumb img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.plMiniIcon{
  font-size:11px;
  font-weight:900;
  color:rgba(148,163,184,.85);
  letter-spacing:.02em;
}

/* Switch (toggle) */
.switch{
  position:relative;
  display:inline-flex;
  width:44px;
  height:24px;
  flex:0 0 auto;
}
.switch input{opacity:0; width:0; height:0}
.switch .slider{
  position:absolute;
  cursor:pointer;
  inset:0;
  background:rgba(148,163,184,.22);
  border:1px solid rgba(148,163,184,.22);
  transition:.18s ease;
  border-radius:999px;
}
.switch .slider:before{
  content:"";
  position:absolute;
  height:18px;
  width:18px;
  left:3px;
  top:2px;
  background:white;
  border-radius:999px;
  transition:.18s ease;
  box-shadow:0 8px 16px rgba(0,0,0,.25);
}
.switch input:checked + .slider{
  background:rgba(52,211,153,.22);
  border-color:rgba(52,211,153,.32);
}
.switch input:checked + .slider:before{transform:translateX(20px);}

/* Schedules list */
.scheduleList{
  border:1px solid rgba(148,163,184,.14);
  border-radius:18px;
  background:rgba(2,6,23,.20);
  overflow:hidden;
}
.scRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-bottom:1px solid rgba(148,163,184,.10);
}
.scRow:last-child{border-bottom:0}
.scL{display:flex; flex-direction:column; gap:2px; min-width:0}
.scT{font-weight:750; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.scS{font-size:11px; color:rgba(148,163,184,.85); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.scR{display:flex; align-items:center; gap:10px; flex:0 0 auto}
.badge{
  display:inline-flex;
  align-items:center;
  font-size:11px;
  font-weight:850;
  padding:3px 10px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(15,23,42,.55);
  color:var(--text);
}
.badgeActive{border-color:rgba(52,211,153,.35); background:rgba(52,211,153,.14)}
.badgeInactive{border-color:rgba(148,163,184,.28); background:rgba(148,163,184,.10); color:rgba(226,232,240,.88)}

.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px}
@media (max-width: 860px){.grid2{grid-template-columns:1fr}}
.cardMini{
  border:1px solid rgba(148,163,184,.14);
  border-radius:18px;
  background:rgba(2,6,23,.20);
  padding:12px;
}
.subHint{font-size:11px; color:rgba(148,163,184,.70); margin-top:2px}
.weekdays{display:flex; flex-wrap:wrap; gap:8px}
.dayBtn{
  border:1px solid rgba(148,163,184,.16);
  background:rgba(2,6,23,.18);
  color:var(--text);
  padding:8px 10px;
  border-radius:999px;
  font-size:12px;
  cursor:pointer;
}
.dayBtn.active{
  border-color:rgba(96,165,250,.45);
  background:rgba(96,165,250,.14);
}

#scEditDesc{
  width:100%;
  resize:vertical;
  min-height:74px;
  padding:10px 12px;
  border-radius:16px;
  border:1px solid rgba(148,163,184,.16);
  background:rgba(2,6,23,.25);
  color:var(--text);
  outline:none;
}
#scEditDesc:focus{border-color:rgba(96,165,250,.45)}
