:root {
  color-scheme: light dark;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --brand-soft: #dbeafe;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --text: #10213f;
  --muted: #66748b;
  --line: #dfe7f1;
  --danger: #dc2626;
  --success: #15803d;
  --shadow: 0 22px 60px rgba(30, 64, 175, .12);
  --radius: 24px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(59, 130, 246, .14), transparent 30rem),
    radial-gradient(circle at 96% 18%, rgba(14, 165, 233, .09), transparent 26rem),
    var(--bg);
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(37, 99, 235, .26); outline-offset: 2px; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid rgba(223, 231, 241, .82);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); font-weight: 800; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  color: #fff; background: linear-gradient(145deg, #60a5fa, var(--brand-2)); box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
}
.identity { display: flex; align-items: center; gap: 12px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.status-dot.online::before { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .12); }
.text-btn, .icon-btn { border: 0; background: transparent; cursor: pointer; }
.text-btn { color: var(--brand); font-weight: 700; }
.icon-btn { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 800; }

.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 80px; }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; align-items: end; gap: 42px; padding-bottom: 54px; }
.eyebrow, .section-kicker { color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { margin: 16px 0 20px; max-width: 720px; font-size: clamp(42px, 6vw, 78px); line-height: .98; letter-spacing: -.055em; }
.hero p { max-width: 620px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.8; }
.upload-launch {
  display: flex; align-items: center; gap: 18px; width: 100%; min-height: 146px; padding: 26px;
  border: 0; border-radius: 30px; cursor: pointer; color: #fff; text-align: left;
  background: linear-gradient(145deg, #3b82f6, #1e40af); box-shadow: 0 26px 60px rgba(37, 99, 235, .28);
  transition: transform .2s ease, box-shadow .2s ease;
}
.upload-launch:hover { transform: translateY(-3px); box-shadow: 0 32px 70px rgba(37, 99, 235, .35); }
.upload-launch strong { display: block; font-size: 24px; }
.upload-launch small { display: block; margin-top: 7px; color: rgba(255,255,255,.75); line-height: 1.5; }
.upload-icon { display: grid; place-items: center; flex: 0 0 58px; height: 58px; border-radius: 19px; background: rgba(255,255,255,.17); font-size: 34px; font-weight: 300; }

.login-card, .library-section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: var(--shadow); }
.login-card { display: grid; grid-template-columns: 1fr 280px; gap: 46px; align-items: center; padding: 36px; margin-bottom: 28px; }
.login-copy h2, .section-head h2, .modal-head h2 { margin: 8px 0 10px; letter-spacing: -.025em; }
.login-copy p { margin: 0 0 20px; color: var(--muted); line-height: 1.75; }
.secondary-btn, .primary-btn, .load-more { min-height: 46px; border-radius: 14px; padding: 0 18px; cursor: pointer; font-weight: 800; }
.secondary-btn { border: 1px solid var(--line); background: var(--surface); }
.primary-btn { border: 0; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 10px 24px rgba(37,99,235,.22); }
.primary-btn:disabled { opacity: .55; cursor: wait; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; }
.qr-stage { display: grid; place-items: center; align-content: center; gap: 10px; width: 210px; height: 210px; padding: 12px; border: 1px dashed #b8c6da; border-radius: 22px; background: #fff; color: #64748b; font-size: 12px; text-align: center; overflow: hidden; }
.qr-stage img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid #dbeafe; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-code-row { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.login-code-row strong { color: var(--text); font: 800 20px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .18em; }
.login-code-row .icon-btn { min-width: auto; height: 30px; padding: 0 8px; font-size: 11px; }
.hint { margin: 9px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.library-section { padding: 32px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.section-head h2 { font-size: 28px; }
.tools { display: flex; align-items: center; gap: 10px; }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.search-box input { width: 190px; border: 0; outline: 0; color: var(--text); background: transparent; }
.empty-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 16px 0 8px; color: var(--text); }
.empty-state p { margin: 0; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin: auto; border-radius: 22px; color: var(--brand); background: var(--brand-soft); font-size: 28px; }
.file-list { display: grid; gap: 10px; padding-top: 18px; }
.file-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 15px; padding: 15px 12px; border-radius: 16px; transition: background .18s ease; }
.file-row:hover { background: var(--surface-2); }
.file-type { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: var(--brand-2); background: var(--brand-soft); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.file-main { min-width: 0; }
.file-name { margin: 0 0 6px; overflow: hidden; color: var(--text); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 999px; color: #166534; background: #dcfce7; font-size: 11px; font-weight: 800; }
.badge.private { color: #475569; background: #e2e8f0; }
.badge.expired { color: #991b1b; background: #fee2e2; }
.load-more { display: block; width: 100%; margin-top: 16px; border: 1px solid var(--line); background: var(--surface); }

.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 20px; }
.modal.open { display: grid; }
.modal-mask { position: absolute; inset: 0; background: rgba(3, 10, 24, .58); backdrop-filter: blur(8px); }
.modal-card { position: relative; z-index: 1; width: min(560px, 100%); max-height: min(720px, calc(100vh - 40px)); overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: 0 35px 100px rgba(0,0,0,.28); }
.modal-card.compact { width: min(440px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.modal-head h2 { font-size: 24px; }
.form-grid { display: grid; gap: 17px; }
.field { display: grid; gap: 8px; color: var(--text); font-size: 13px; font-weight: 800; }
.field input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface-2); outline: 0; }
.field small { color: var(--muted); font-weight: 500; }
.file-picker { padding: 22px; border: 1px dashed #9eb3d0; border-radius: 17px; background: var(--surface-2); cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker strong { color: var(--brand); font-size: 16px; }
.switch-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 58px; cursor: pointer; }
.switch-row span { display: grid; gap: 5px; }
.switch-row small { color: var(--muted); font-size: 11px; font-weight: 500; }
.switch-row input { position: absolute; right: 0; width: 48px; height: 28px; opacity: 0; cursor: pointer; }
.switch-row i { width: 48px; height: 28px; padding: 3px; border-radius: 999px; background: #cbd5e1; transition: .18s; }
.switch-row i::after { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: .18s; }
.switch-row input:checked + i { background: var(--brand); }
.switch-row input:checked + i::after { transform: translateX(20px); }
.progress { position: relative; height: 24px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #60a5fa, #2563eb); transition: width .15s; }
.progress span { position: relative; z-index: 1; display: grid; place-items: center; height: 100%; color: var(--text); font-size: 11px; font-weight: 900; }
.action-list { display: grid; gap: 7px; }
.action-btn { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 15px; border: 1px solid transparent; border-radius: 14px; background: var(--surface-2); cursor: pointer; text-align: left; }
.action-btn:hover { border-color: var(--line); }
.action-btn.danger { color: var(--danger); }
.action-btn small { color: var(--muted); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 18px); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px; color: #fff; background: #0f172a; opacity: 0; pointer-events: none; transition: .2s; box-shadow: 0 14px 40px rgba(0,0,0,.3); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #07101f; --surface: #0d192c; --surface-2: #132238; --text: #edf5ff; --muted: #92a3ba; --line: #21334e; --brand-soft: #152d56; --shadow: 0 22px 65px rgba(0,0,0,.25); }
  .qr-stage { border-color: #354a68; background: #fff; }
  .badge { color: #bbf7d0; background: #14532d; }
  .badge.private { color: #cbd5e1; background: #334155; }
  .badge.expired { color: #fecaca; background: #7f1d1d; }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 18px; }
  .shell { width: min(100% - 28px, 680px); padding: 32px 0 90px; }
  .hero { grid-template-columns: 1fr; gap: 26px; padding-bottom: 30px; }
  .hero h1 { font-size: clamp(42px, 14vw, 62px); }
  .hero p { font-size: 15px; }
  .upload-launch { min-height: 112px; padding: 21px; border-radius: 24px; }
  .upload-launch strong { font-size: 21px; }
  .upload-icon { flex-basis: 50px; height: 50px; border-radius: 16px; }
  .login-card { grid-template-columns: 1fr; gap: 28px; padding: 24px; }
  .qr-stage { width: 200px; height: 200px; }
  .library-section { padding: 22px 16px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .tools { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .file-row { grid-template-columns: 44px 1fr auto; gap: 11px; padding: 14px 4px; }
  .file-type { width: 44px; height: 44px; }
  .file-meta span:nth-child(2) { display: none; }
  .modal { align-items: end; padding: 0; }
  .modal-card, .modal-card.compact { width: 100%; max-height: calc(92vh - env(safe-area-inset-bottom)); padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; }
}
