:root{
  --bg0:#05070c;
  --bg1:#0a0f1d;
  --card:rgba(255,255,255,.06);
  --card2:rgba(255,255,255,.08);
  --border:rgba(255,255,255,.12);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.62);
  --shadow:0 24px 80px rgba(0,0,0,.55);
  --primary:#7c5cff;
  --primary2:#23d5ff;
  --danger:#ff4d6d;
  --ok:#4ade80;
  --radius:18px;
  --radius2:14px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:radial-gradient(1100px 600px at 20% 0%, rgba(124,92,255,.26), transparent 60%),
             radial-gradient(900px 600px at 80% 10%, rgba(35,213,255,.18), transparent 55%),
             radial-gradient(800px 500px at 50% 100%, rgba(124,92,255,.12), transparent 60%),
             linear-gradient(180deg, var(--bg0), var(--bg1));
}

body[data-authed="1"] .auth-when-unauthed{display:none !important}
body[data-authed="0"] .auth-when-authed{display:none !important}

.bg{
  position:fixed; inset:0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.12), transparent 45%),
    radial-gradient(circle at 75% 30%, rgba(255,255,255,.10), transparent 50%),
    radial-gradient(circle at 55% 80%, rgba(255,255,255,.08), transparent 55%);
  filter: blur(26px);
  opacity:.65;
  pointer-events:none;
}

.shell{
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 18px 60px;
  position:relative;
}

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

.brand{display:flex; align-items:center; gap:12px}
.logo{
  width:44px; height:44px;
  display:grid; place-items:center;
  font-weight:800;
  letter-spacing:.5px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,92,255,.95), rgba(35,213,255,.90));
  box-shadow: 0 10px 30px rgba(124,92,255,.25);
}
.title{font-weight:800; font-size: 16px}
.subtitle{color:var(--muted); font-size: 13px; margin-top:2px}
.subtitle a{
  color: rgba(255,255,255,.78);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}
.subtitle a:hover{color: rgba(35,213,255,.92)}

.top-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  flex-wrap: wrap;
}

.grid{
  display:grid;
  grid-template-columns: 1.1fr .9fr;
  gap:16px;
}
@media (max-width: 880px){
  .grid{grid-template-columns: 1fr}
  .topbar{flex-direction:column; align-items:stretch}
  .top-actions{justify-content:flex-end}
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.section-title{font-weight:800; margin-bottom: 12px}
.muted{color:var(--muted)}
.hint{color:var(--muted); font-size: 12px; margin-top: 10px}
.hint-block{display:flex; flex-direction:column; gap:6px}
.hint-title{color: rgba(255,255,255,.78); font-weight:900; letter-spacing:.2px}

.btn{
  appearance:none;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-weight:700;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover{background: rgba(255,255,255,.09)}
.btn:active{transform: translateY(1px)}
.btn[disabled]{opacity:.5; cursor:not-allowed}
.btn.primary{
  border-color: rgba(124,92,255,.55);
  background: linear-gradient(135deg, rgba(124,92,255,.92), rgba(35,213,255,.70));
}
.btn.ghost{background: transparent}

.icon-btn{
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
}
.icon-btn svg{
  width: 18px;
  height: 18px;
  opacity: .9;
}
.icon-btn.danger:hover{
  border-color: rgba(255,77,109,.55);
  background: rgba(255,77,109,.14);
}

.form{display:flex; flex-direction:column; gap:8px; margin-top:12px}
.label{font-size: 12px; color:var(--muted); font-weight:700; letter-spacing:.2px}
.input{
  width:100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.25);
  color: var(--text);
  outline:none;
}
.input:focus{border-color: rgba(124,92,255,.75)}

.alert{
  border:1px solid rgba(255,77,109,.45);
  background: rgba(255,77,109,.12);
  padding: 10px 12px;
  border-radius: 14px;
  color: rgba(255,255,255,.92);
  margin-top: 12px;
}

.dropzone{
  border:1px dashed rgba(255,255,255,.22);
  background: rgba(0,0,0,.20);
  border-radius: var(--radius2);
  padding: 18px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  cursor:pointer;
  min-height: 120px;
  transition: border-color .15s ease, background .15s ease, transform .08s ease;
  outline: none;
}
.dropzone:hover{background: rgba(0,0,0,.26)}
.dropzone:active{transform: translateY(1px)}
.dropzone.dragover{
  border-color: rgba(35,213,255,.75);
  background: rgba(35,213,255,.08);
}
.dz-title{font-weight:800}
.dz-sub{color:var(--muted); font-size: 13px}

.list-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin: 14px 0 8px;
}

.file-list{
  list-style:none;
  padding:0; margin:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.file{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
.file.header{
  border-style: dashed;
  background: rgba(124,92,255,.08);
}
.file.page{
  padding-left: 18px;
  background: rgba(0,0,0,.18);
  border-color: rgba(255,255,255,.08);
}
.file.page .name{
  font-weight: 900;
}
.file[draggable="true"]{cursor:grab}
.file:active{cursor:grabbing}
.file.dragging{opacity:.55}
.file .meta{display:flex; flex-direction:column; gap:2px; min-width: 0}
.file .name{font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 520px}
.file .sub{color:var(--muted); font-size: 12px}
.file .tools{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}

.thumb-btn{
  width: 40px;
  height: 52px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.thumb-btn:hover{background: rgba(0,0,0,.28)}
.thumb-btn:active{transform: translateY(1px)}
.thumb-btn[disabled]{opacity:.55; cursor:not-allowed}
.thumb-img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-ph{
  color: rgba(255,255,255,.62);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: .2px;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 6px 10px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
  color: rgba(255,255,255,.88);
  font-weight:800;
  font-size: 12px;
}

.row{display:flex; flex-direction:column; gap:14px}
.label-row{display:flex; align-items:center; justify-content:space-between; margin-bottom:8px}
.range{width:100%}

.toggle{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
  cursor:pointer;
}
.toggle input{position:absolute; opacity:0; pointer-events:none}
.switch{
  width:44px;
  height:26px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.22);
  position:relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  transition: background .15s ease, border-color .15s ease;
}
.switch::after{
  content:"";
  width:20px;
  height:20px;
  border-radius:999px;
  position:absolute;
  top:2px;
  left:2px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  transition: transform .15s ease, background .15s ease;
}
.toggle input:checked + .switch{
  border-color: rgba(35,213,255,.55);
  background: rgba(35,213,255,.18);
}
.toggle input:checked + .switch::after{
  transform: translateX(18px);
  background: rgba(255,255,255,.95);
}
.toggle-text{color: rgba(255,255,255,.86); font-weight:800; font-size: 13px}

.stats{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top: 14px;
}
.stat{
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  border-radius: 16px;
  padding: 12px;
}
.stat-k{color:var(--muted); font-size: 12px; font-weight:800}
.stat-v{font-size: 18px; font-weight:900; margin-top:6px}

.actions{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:10px;
  margin-top: 14px;
}
.btn.cta{
  width: 100%;
  padding: 14px 14px;
  border-radius: 16px;
  font-size: 15px;
}
.empty{
  border:1px dashed rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 14px 12px;
  color: var(--muted);
  margin-top: 10px;
}

.toast{
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  background: rgba(0,0,0,.60);
  border:1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events:none;
}
.toast.show{opacity: 1; transform: translateY(0)}

a.btn{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

body.modal-open{overflow:hidden}
body.modal-open main.shell{
  filter: blur(10px);
  transform: scale(.99);
}

.modal-backdrop{
  position: fixed;
  inset: 0;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
}
.modal-backdrop[hidden]{display:none !important}

.modal{
  width: 100%;
  max-width: 520px;
}

.modal-preview{
  max-width: 980px;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.modal-title{font-weight:900}

.preview-meta{
  margin-top: 8px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-stage{
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.24);
  overflow: hidden;
  min-height: 220px;
  max-height: min(72vh, 900px);
  display: grid;
  place-items: center;
}

.preview-loading{
  color: rgba(255,255,255,.72);
  font-weight: 900;
  letter-spacing: .2px;
}

.preview-img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.access-row{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap: wrap;
}

.access-link{
  color: rgba(255,255,255,.92);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
  cursor: pointer;
}
.access-link:hover{
  color: rgba(35,213,255,.92);
}

.access-sep{
  color: rgba(255,255,255,.72);
}

.email-text{
  color: rgba(255,255,255,.82);
  user-select: text;
}

.footer{
  margin-top: 18px;
  padding: 6px 2px 0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color: var(--muted);
  font-size: 13px;
}

.footer-link{
  display:inline-flex;
  align-items:center;
  gap:8px;
  color: var(--muted);
  text-decoration:none;
  font-weight:800;
}
.footer-link:hover{color: rgba(35,213,255,.92)}
.footer-link .gh{width:18px; height:18px; opacity:.9}
