:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand2: #0ea5e9;
  --accent: #059669;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrap { width: min(860px, 100% - 32px); margin: 0 auto; }

.hidden { display: none !important; }

/* topbar */
.topbar { background: linear-gradient(120deg, #1e1b4b, #312e81 55%, #155e75); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-icon { display: flex; align-items: center; }
.brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: .2px; }
.brand-name em { font-style: normal; color: #7dd3fc; }
.disk-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px; padding: 6px 12px;
  font-size: .82rem; color: #e0e7ff; white-space: nowrap;
}

/* hero */
.hero { text-align: center; padding: 56px 8px 34px; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.5rem); line-height: 1.2; margin: 0 0 12px; font-weight: 800; }
.hero .hl { background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.02rem; max-width: 560px; margin: 0 auto; }
.hero p strong { color: var(--ink); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.input-label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 10px; }
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-row input {
  flex: 1 1 260px; padding: 13px 16px; font-size: .98rem;
  border: 1.5px solid var(--line); border-radius: 12px; outline: none; transition: border-color .15s, box-shadow .15s;
  background: #fbfcfe; color: var(--ink);
}
.input-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); background: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; border-radius: 12px; padding: 12px 18px;
  font-size: .95rem; font-weight: 700; transition: transform .06s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn-primary:not(:disabled):hover { box-shadow: 0 8px 20px rgba(79, 70, 229, .38); }
.btn-accent { background: #ecfdf5; color: var(--accent); border: 1.5px solid #a7f3d0; }
.btn-accent:not(:disabled):hover { background: #d1fae5; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); padding: 8px 14px; font-size: .86rem; }
.btn-ghost:hover { color: var(--ink); border-color: #cbd5e1; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1.5px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 8px 14px; font-size: .86rem; border-radius: 10px; }

.hint { font-size: .82rem; color: var(--muted); margin: 12px 0 0; }
.alert { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: .9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: var(--brand); border: 1px solid #bfdbfe; }

/* folder card */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-head h2 { margin: 0 0 4px; font-size: 1.12rem; }
.sub { margin: 0; color: var(--muted); font-size: .88rem; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-list li {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fbfcfe; transition: background .15s;
}
.file-list li:hover { background: #fff; border-color: #cbd5e1; }
.file-ic { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; }
.file-ic.f-doc { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.file-ic.f-img { background: linear-gradient(135deg, #0ea5e9, #22d3ee); }
.file-ic.f-vid { background: linear-gradient(135deg, #f43f5e, #fb7185); }
.file-ic.f-zip { background: linear-gradient(135deg, #f59e0b, #f97316); }
.file-ic.f-misc { background: linear-gradient(135deg, #64748b, #94a3b8); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 650; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: .8rem; color: var(--muted); }
.file-key-hint { font-size: .72rem; color: var(--warn); }
.file-act { flex: 0 0 auto; display: flex; gap: 8px; }

/* sections */
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 1.05rem; }
.section-title .sub { max-width: 380px; }
.badge-busy { font-size: .78rem; color: var(--warn); background: #fffbeb; border: 1px solid #fde68a; padding: 3px 10px; border-radius: 999px; }

/* download cards */
.dl-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px; }
.dl-top { display: flex; align-items: center; gap: 12px; }
.dl-top .file-name { flex: 1; }
.dl-status { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 3px 10px; border-radius: 999px; }
.st-running { color: var(--brand); background: #eef2ff; }
.st-queued { color: var(--muted); background: #f1f5f9; }
.st-done { color: var(--accent); background: #ecfdf5; }
.st-error { color: var(--danger); background: #fef2f2; }
.st-canceled { color: var(--muted); background: #f1f5f9; }

.progress-wrap { margin: 12px 0 4px; }
.progress { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand2)); transition: width .8s linear; }
.progress-fill.done { background: linear-gradient(90deg, var(--accent), #34d399); }
.progress-fill.err { background: var(--danger); }
.progress-meta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; gap: 6px; }
.progress-meta b { color: var(--ink); font-weight: 650; }
.dl-actions { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.dl-actions .btn { padding: 8px 14px; font-size: .86rem; border-radius: 10px; }
.dl-key { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.dl-key input { flex: 1 1 120px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-size: .9rem; max-width: 180px; outline: none; }
.dl-key input:focus { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
.dl-error { margin-top: 10px; color: var(--danger); font-size: .84rem; background: #fef2f2; border: 1px solid #fecaca; padding: 9px 12px; border-radius: 10px; }

/* footer */
.footer { margin-top: auto; background: #fff; border-top: 1px solid var(--line); padding: 18px 0 26px; }
.footer-note { color: var(--muted); font-size: .78rem; text-align: center; margin: 14px 0 0; }
.disk-bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.disk-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #10b981, #0ea5e9); border-radius: 999px; transition: width .6s ease; }

.loader {
  width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .hero { padding: 38px 4px 24px; }
  .file-ic { flex-basis: 36px; width: 36px; height: 36px; }
  .file-act { flex-direction: column; }
  .topbar-inner { padding: 10px 0; }
}