*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1f1f1f;
  --border: #2a2a2a;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: rgba(124,58,237,.15);
  --text: #e8e8e8;
  --muted: #666;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.3px;
}
.logo span { color: var(--accent); }
.admin-link {
  font-size: .8rem;
  color: transparent;
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color .3s, border-color .3s;
  user-select: none;
}
.admin-link:hover {
  color: var(--muted);
  border-color: var(--border);
}

/* ── Main ───────────────────────────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
main.center { justify-content: center; }
main.wide { max-width: 1200px; padding: 32px 28px; }

/* ── Slide-down animation wrapper ───────────────────────── */
.slide-down {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 0.38s var(--ease),
    opacity 0.3s var(--ease),
    margin-top 0.38s var(--ease);
  margin-top: 0;
}
.slide-down > .slide-inner { overflow: hidden; min-height: 0; }
.slide-down.open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 20px;
}
#sectionStorage.open { margin-top: 0; }

/* ── Upload box / dropzone ──────────────────────────────── */
.upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  user-select: none;
  margin-top: 0;
}
.upload-box:hover, .upload-box.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-hint svg { color: var(--muted); margin-bottom: 12px; }
.drop-hint p { color: var(--muted); line-height: 1.6; }
.drop-hint small { font-size: .8rem; }

.file-list-wrap { display: flex; flex-direction: column; gap: 10px; padding-bottom: 2px; }
.add-more-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: .85rem;
  padding: 8px 14px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: color .15s, border-color .15s;
}
.add-more-btn:hover { color: var(--text); border-color: var(--accent); }

.file-list { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .85rem;
}
.file-list li .fl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list li .fl-size { color: var(--muted); margin-left: 10px; white-space: nowrap; }
.file-list li .fl-rm {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; margin-left: 8px; line-height: 1;
  transition: color .15s;
}
.file-list li .fl-rm:hover { color: var(--danger); }

/* ── Options section ────────────────────────────────────── */
.options-inner { display: flex; flex-direction: column; gap: 16px; padding-bottom: 2px; }
.section-label {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 4px;
  display: block;
}

/* ── Comment field ──────────────────────────────────────── */
.comment-field { display: flex; flex-direction: column; }
input[type="text"], input[type="password"], textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: .95rem;
  font-family: var(--font);
  outline: none;
  width: 100%;
  transition: border-color .2s;
  resize: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 44px; line-height: 1.5; }

/* ── Expiry grid ────────────────────────────────────────── */
.expiry-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.expiry-opt { cursor: pointer; transition: opacity .2s, transform .2s; }
.expiry-opt input { display: none; }
.expiry-opt span {
  display: block;
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .85rem;
  transition: border-color .15s, background .15s, color .15s;
}
.expiry-opt input:checked + span {
  border-color: var(--accent);
  background: var(--accent-light);
  color: #c4b5fd;
}
.expiry-opt.disabled { opacity: .3; pointer-events: none; }

/* ── Password toggle ────────────────────────────────────── */
.pw-toggle-row { display: flex; align-items: center; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-label input { display: none; }
.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  flex-shrink: 0;
  position: relative;
  transition: background .2s, border-color .2s;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle-label input:checked + .toggle-track {
  background: var(--accent-light);
  border-color: var(--accent);
}
.toggle-label input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--accent);
}
.toggle-text { font-size: .9rem; color: var(--text); }
.toggle-hint { font-size: .78rem; color: var(--muted); font-style: italic; }

/* ── Large file notice ──────────────────────────────────── */
.large-file-notice {
  font-size: .82rem;
  color: #f59e0b;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 8px;
  padding: 8px 12px;
}

/* ── Password section ───────────────────────────────────── */
.pw-inner { display: flex; flex-direction: column; gap: 8px; padding-bottom: 2px; }

/* ── Upload button section ──────────────────────────────── */
.upload-btn-inner { padding-bottom: 2px; }
.btn-upload {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background .15s, opacity .15s, transform .1s;
}
.btn-upload:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-upload:active { transform: translateY(0); }
.btn-upload:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Storage bar ────────────────────────────────────────── */
.storage-bar-wrap { display: flex; flex-direction: column; gap: 6px; padding-bottom: 2px; }
.storage-labels { display: flex; justify-content: space-between; align-items: center; }
.storage-text { font-size: .78rem; color: var(--muted); }
.storage-track { height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.storage-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width .5s var(--ease);
}
.storage-fill.warn { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* ── Progress bar ───────────────────────────────────────── */
.progress-inner { display: flex; flex-direction: column; gap: 8px; padding-bottom: 2px; }
.progress-track { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  transition: width .25s var(--ease);
}
.progress-labels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
#progressPct { color: var(--text); font-weight: 600; }

/* ── Results ────────────────────────────────────────────── */
.results-inner { display: flex; flex-direction: column; gap: 10px; padding-bottom: 2px; }
#linkList { list-style: none; display: flex; flex-direction: column; gap: 8px; }

/* Each link item slides in with stagger */
@keyframes linkIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#linkList li {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: linkIn 0.4s var(--ease) both;
}
#linkList li .link-label {
  color: var(--muted);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}
#linkList li a { color: #a78bfa; word-break: break-all; flex: 1; text-decoration: none; }
#linkList li a:hover { text-decoration: underline; }
.copy-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-size: .75rem; padding: 3px 8px; cursor: pointer;
  flex-shrink: 0; transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

/* ── Preview ────────────────────────────────────────────── */
.preview-wrap {
  width: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 70vh;
}
.preview-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  border-radius: 10px;
}
.preview-video {
  width: 100%;
  max-height: 70vh;
  display: block;
  outline: none;
}
.file-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.file-info-row svg { flex-shrink: 0; color: var(--muted); }
.file-info-row .file-name { font-size: .95rem; font-weight: 600; word-break: break-all; text-align: left; }
.file-info-row .file-size { font-size: .8rem; color: var(--muted); text-align: left; }
.file-info-row .file-comment { font-size: .85rem; color: #a78bfa; text-align: left; margin-top: 3px; font-style: italic; }

/* ── Download card ──────────────────────────────────────── */
.download-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.file-name { font-size: 1.05rem; font-weight: 600; word-break: break-all; }
.file-size { font-size: .85rem; color: var(--muted); }
.pw-section { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.error-card { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.error-card p { color: var(--muted); }
.error-msg { color: var(--danger); font-size: .85rem; }

/* ── Scan badge ─────────────────────────────────────────── */
.scan-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  padding: 7px 14px;
  border-radius: 20px;
  font-weight: 500;
  width: 100%;
  justify-content: center;
}
.scan-badge.clean {
  background: rgba(34,197,94,.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,.2);
}
.scan-badge.warn {
  background: rgba(245,158,11,.1);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,.2);
}
.scan-badge.error {
  background: rgba(100,100,100,.1);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Spinner ────────────────────────────────────────────── */
.spinner-wrap { padding: 24px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Admin ──────────────────────────────────────────────── */
.login-box {
  max-width: 380px;
  margin: 60px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box h2 { font-size: 1.2rem; font-weight: 700; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-header h2 { font-size: 1.2rem; font-weight: 700; }
.stats-text { font-size: .82rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 10px 12px; vertical-align: middle; }
.tag {
  display: inline-block;
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}
.tag-active  { background: rgba(34,197,94,.12);  color: var(--success); }
.tag-expired { background: rgba(239,68,68,.12);  color: var(--danger); }
.tag-deleted { background: rgba(100,100,100,.15); color: var(--muted); }
.del-btn, .dl-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-size: .75rem; padding: 4px 10px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.del-btn:hover { color: var(--danger); border-color: var(--danger); }
.dl-btn:hover  { color: var(--success); border-color: var(--success); }
.del-btn:disabled, .dl-btn:disabled { opacity: .3; cursor: not-allowed; }
.action-cell { display: flex; gap: 6px; align-items: center; }

/* ── Footer ─────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 18px;
  font-size: .78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Recent Uploads ─────────────────────────────────────── */
.recent-section {
  max-width: 680px;
  width: 100%;
  margin: 0 auto 32px;
  padding: 0 16px;
}
.recent-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.recent-inner .section-label { margin-bottom: 12px; }
.recent-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: .88rem;
}
.recent-date {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.recent-label {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-label:hover { text-decoration: underline; }
.recent-list li.invalid .recent-label {
  text-decoration: line-through;
  color: var(--muted);
  pointer-events: none;
}
.recent-list li.invalid .recent-date { text-decoration: line-through; }

/* ── Util ───────────────────────────────────────────────── */
.hidden { display: none !important; }
