:root{
  --bg:#090b13;
  --bg2:#101522;
  --card:rgba(18,24,39,.78);
  --card-solid:#111827;
  --line:rgba(255,255,255,.08);
  --line-strong:rgba(255,255,255,.14);
  --text:#f3f6ff;
  --muted:#9ba7c2;
  --blue:#4f8cff;
  --blue2:#7c5cff;
  --purple:#b263ff;
  --green:#21c17a;
  --amber:#ffb84f;
  --red:#ff5d73;
  --shadow:0 20px 60px rgba(0,0,0,.35);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top left, rgba(79,140,255,.18), transparent 30%),
    radial-gradient(circle at top right, rgba(124,92,255,.14), transparent 24%),
    linear-gradient(180deg, #0a0d16 0%, #090b13 100%);
  min-height:100vh;
}

.hidden{display:none!important}
.wrap{max-width:1280px;margin:0 auto;padding:0 20px}

.glass{
  background:var(--card);
  backdrop-filter:blur(16px);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  border-bottom:1px solid var(--line);
}
.topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding-top:16px;
  padding-bottom:16px;
}

.brand,.auth-brand{
  display:flex;
  align-items:center;
  gap:14px;
}
.brand-badge{
  width:44px;
  height:44px;
  border-radius:14px;
  display:grid;
  place-items:center;
  font-weight:800;
  background:linear-gradient(135deg,var(--blue),var(--blue2));
  box-shadow:0 10px 30px rgba(79,140,255,.35);
}
.brand h1,.auth-brand h1{margin:0;font-size:1.1rem}
.brand p,.auth-brand p{margin:2px 0 0;color:var(--muted);font-size:.88rem}

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

.app-shell{padding-top:24px;padding-bottom:32px}

.usage-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
}
.usage-card{
  padding:18px;
  border-radius:var(--radius);
}
.usage-title{
  color:var(--muted);
  font-size:.85rem;
  margin-bottom:8px;
}
.usage-value{
  font-size:1.8rem;
  font-weight:800;
  letter-spacing:-.03em;
}
.usage-small{
  font-size:1rem;
  font-weight:700;
}
.usage-sub{
  margin-top:8px;
  color:var(--muted);
  font-size:.86rem;
}

.tab-shell{
  margin-top:20px;
  border-radius:var(--radius);
  padding:20px;
}

.grid-two{
  margin-top:20px;
  display:grid;
  grid-template-columns:320px minmax(0,1fr);
  gap:20px;
}

.side-panel,.panel{border-radius:var(--radius)}
.side-panel{
  padding:18px;
  height:fit-content;
  position:sticky;
  top:92px;
}
.panel{
  padding:0;
}
.panel.active{display:block}

.main-panel{min-width:0}

.section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}
.section-head.spaced{margin-top:20px}
.section-head h3{margin:0;font-size:1rem}

.mini-panel{
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  border-radius:14px;
  padding:14px;
}
.muted{color:var(--muted)}
.small{font-size:.85rem}

.tab-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.tab-btn,.tab-pill{
  border:1px solid var(--line-strong);
  background:rgba(255,255,255,.03);
  color:var(--text);
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
  transition:.18s ease;
}
.tab-btn.active,.tab-pill.active{
  background:linear-gradient(135deg,var(--blue),var(--blue2));
  border-color:transparent;
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:14px;
}
.field{
  grid-column:span 4;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.field-full{grid-column:1/-1}

label span,.field > span{
  font-size:.82rem;
  color:var(--muted);
}

input,select,textarea,button,a{
  font:inherit;
}
input,select,textarea{
  width:100%;
  border:1px solid var(--line-strong);
  background:#101726;
  color:var(--text);
  border-radius:12px;
  padding:12px 14px;
  outline:none;
  transition:border-color .15s ease, transform .15s ease;
}
select option{
  background:#101726;
  color:var(--text);
}
input:focus,select:focus,textarea:focus{
  border-color:rgba(79,140,255,.7);
}
textarea{resize:vertical}

.action-row{
  display:flex;
  gap:10px;
  margin-top:16px;
  flex-wrap:wrap;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  border:none;
  border-radius:12px;
  padding:12px 16px;
  cursor:pointer;
  text-decoration:none;
  font-weight:700;
  transition:transform .16s ease, opacity .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover{transform:translateY(-1px)}
.btn:disabled{opacity:.6;cursor:not-allowed;transform:none}
.btn-primary{
  background:linear-gradient(135deg,var(--blue),var(--blue2));
  color:white;
}
.btn-secondary{
  background:linear-gradient(135deg,#8b5cf6,#d946ef);
  color:white;
}
.btn-ghost{
  background:rgba(255,255,255,.03);
  color:var(--text);
  border:1px solid var(--line-strong);
}
.btn-small{
  padding:8px 12px;
  font-size:.85rem;
}
.btn-block{width:100%}

.pill{
  border:1px solid var(--line-strong);
  background:rgba(255,255,255,.04);
  color:var(--muted);
  padding:7px 10px;
  border-radius:999px;
  font-size:.78rem;
}

.dropzone{
  border:1px dashed rgba(255,255,255,.22);
  background:rgba(255,255,255,.025);
  border-radius:16px;
  padding:18px;
  text-align:center;
  cursor:pointer;
  transition:.18s ease;
}
.dropzone.drag{
  border-color:rgba(79,140,255,.65);
  background:rgba(79,140,255,.08);
}
.dropzone-copy{
  display:grid;
  gap:4px;
}
.dropzone-copy strong{font-size:.98rem}
.dropzone-copy span{font-size:.86rem;color:var(--muted)}

.upload-chip{
  display:inline-flex;
  align-items:center;
  gap:10px;
  margin-top:10px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  width:max-content;
  max-width:100%;
}
.upload-chip code{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:280px;
}

.ratio-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(92px,1fr));
  gap:10px;
}
.ratio-btn{
  border:1px solid var(--line-strong);
  background:rgba(255,255,255,.03);
  color:var(--text);
  border-radius:14px;
  padding:10px;
  cursor:pointer;
  transition:.16s ease;
  display:grid;
  gap:8px;
  justify-items:center;
}
.ratio-btn:hover{
  transform:translateY(-1px);
}
.ratio-btn.active{
  border-color:rgba(79,140,255,.55);
  background:rgba(79,140,255,.12);
  box-shadow:0 0 0 1px rgba(79,140,255,.18) inset;
}
.ratio-preview{
  width:100%;
  height:38px;
  display:grid;
  place-items:center;
}
.ratio-box{
  border:1.5px solid rgba(255,255,255,.68);
  background:rgba(255,255,255,.06);
  border-radius:6px;
}
.ratio-label{
  font-size:.8rem;
  color:var(--muted);
}
.ratio-btn.active .ratio-label{
  color:#d9e6ff;
}

.progress-panel{
  margin-top:18px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  padding:14px;
}
.progress-head{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.progress-head strong{flex:1}
.progress-track{
  height:12px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--line);
  background:#0d1321;
}
.progress-bar{
  width:0%;
  height:100%;
  background:linear-gradient(90deg,var(--blue),var(--purple));
  transition:width .25s ease;
}

.spinner{
  width:18px;
  height:18px;
  border-radius:50%;
  border:3px solid rgba(255,255,255,.18);
  border-top-color:white;
  animation:spin .7s linear infinite;
}
.spinner.tiny{
  width:14px;
  height:14px;
  border-width:2px;
}
@keyframes spin{to{transform:rotate(360deg)}}

.result-grid{
  margin-top:18px;
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:16px;
}
.result-card{
  overflow:hidden;
  border-radius:16px;
  border:1px solid var(--line);
  background:var(--card-solid);
}
.result-card img,.result-card video{
  width:100%;
  display:block;
  background:black;
}
.result-meta{
  padding:12px 14px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
}
.result-meta a{
  color:#9ec1ff;
  text-decoration:none;
}
.result-meta a:hover{text-decoration:underline}

.video-result{margin-top:18px}

.debug-box{
  margin-top:18px;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.025);
  padding:14px;
}
.debug-box summary{
  cursor:pointer;
  color:var(--muted);
}
.debug-box pre{
  margin:12px 0 0;
  border-radius:12px;
  background:#0a0f1a;
  border:1px solid var(--line);
  padding:14px;
  overflow:auto;
  max-height:420px;
  color:#c7d0e8;
  white-space:pre-wrap;
  word-break:break-word;
}

.table-wrap{overflow:auto}
.table{
  width:100%;
  border-collapse:collapse;
  min-width:760px;
}
.table th,.table td{
  text-align:left;
  padding:12px;
  border-bottom:1px solid var(--line);
  font-size:.92rem;
}
.table th{
  color:var(--muted);
  font-weight:700;
}
.table code{
  background:rgba(255,255,255,.04);
  border:1px solid var(--line);
  border-radius:8px;
  padding:4px 6px;
}

.invite-output{
  margin-top:12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  padding:12px;
}
.invite-code-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.invite-code-row code{
  font-size:1.1rem;
  letter-spacing:.08em;
}

.tips{
  margin:0;
  padding-left:18px;
  color:var(--muted);
  display:grid;
  gap:8px;
  font-size:.92rem;
}

/* auth */
.auth-body{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}
.auth-shell{
  width:100%;
  max-width:460px;
}
.auth-card{
  border-radius:24px;
  padding:24px;
}
.auth-tabs{
  display:flex;
  gap:10px;
  margin:18px 0 14px;
}
.auth-form{
  display:grid;
  gap:12px;
}
.auth-status{
  min-height:20px;
  margin-bottom:12px;
  font-size:.92rem;
}
.auth-status.ok{color:var(--green)}
.auth-status.err{color:#ff97a5}
.notice{
  margin-bottom:14px;
  border-radius:14px;
  padding:10px 12px;
  border:1px solid var(--line);
  font-size:.84rem;
}
.notice.success{
  background:rgba(33,193,122,.12);
  border-color:rgba(33,193,122,.25);
  color:#b8f3d5;
}
.notice.warn{
  background:rgba(255,184,79,.12);
  border-color:rgba(255,184,79,.25);
  color:#ffd79b;
}
.notice.info{
  background:rgba(79,140,255,.12);
  border-color:rgba(79,140,255,.25);
  color:#cfe0ff;
}

/* toasts */
.toast-stack{
  position:fixed;
  top:18px;
  right:18px;
  z-index:60;
  display:flex;
  flex-direction:column;
  gap:10px;
  max-width:360px;
}
.toast{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  animation:slideIn .25s ease-out;
}
.toast.success{background:rgba(33,193,122,.16);color:#b6f0d3;border-color:rgba(33,193,122,.28)}
.toast.error{background:rgba(255,93,115,.16);color:#ffc6cf;border-color:rgba(255,93,115,.3)}
.toast.info{background:rgba(79,140,255,.16);color:#cfe0ff;border-color:rgba(79,140,255,.28)}
@keyframes slideIn{
  from{opacity:0;transform:translateY(-8px)}
  to{opacity:1;transform:translateY(0)}
}

@media (max-width: 1100px){
  .usage-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .grid-two{
    grid-template-columns:1fr;
  }
  .side-panel{
    position:static;
  }
}
@media (max-width: 800px){
  .form-grid{
    grid-template-columns:repeat(1,minmax(0,1fr));
  }
  .field{
    grid-column:1/-1;
  }
  .usage-grid{
    grid-template-columns:1fr;
  }
  .usage-value{
    font-size:1.45rem;
  }
  .topbar-inner{
    align-items:flex-start;
  }
}