:root {
  --bg: #eef1f6;
  --bg-accent: #e3e9f2;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #6b778a;
  --line: #e2e8f0;
  --accent: #2f6fed;
  --accent-hover: #2558c7;
  --accent-soft: #ebf2ff;
  --danger: #d92d20;
  --ok: #099250;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.06);
  --shadow-sm: 0 2px 8px rgba(28, 36, 48, 0.04);
  --focus: 0 0 0 3px rgba(47, 111, 237, 0.22);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  background:
    radial-gradient(800px 360px at 100% 0%, #dbe7ff 0%, transparent 55%),
    radial-gradient(700px 320px at 0% 10%, #e8eef8 0%, transparent 50%),
    var(--bg);
}

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 20px 14px 48px;
}

body.browsing {
  background: var(--bg);
}

.page.browsing {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
  animation: rise 0.45s ease both;
}

#upload-section {
  margin-bottom: 28px;
}

.card.files-full {
  flex: 1;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  animation: none;
}

.card.files-full .section-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.card.files-full #files-panel {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.dropzone {
  border: 1.5px dashed #b7c6de;
  border-radius: calc(var(--radius) - 4px);
  background: linear-gradient(180deg, #f7f9fc, #f2f5fa);
  min-height: min(42vh, 320px);
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease,
    transform 0.18s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.drop-text {
  margin: 0;
  font-weight: 700;
  font-size: 1.2rem;
}

.drop-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1rem;
  color: var(--text);
  background: #fafbfd;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.input::placeholder {
  color: #9aa6b8;
}

.input:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.btn {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(47, 111, 237, 0.22);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn-ghost:hover {
  background: #f5f7fb;
  border-color: #cfd8e6;
  box-shadow: none;
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
  box-shadow: 0 4px 10px rgba(47, 111, 237, 0.18);
}

.btn-danger {
  background: var(--danger);
  box-shadow: 0 4px 10px rgba(217, 45, 32, 0.2);
}

.btn-danger:hover {
  background: #b42318;
}

.btn-block {
  width: 100%;
  margin-bottom: 12px;
}

.msg {
  min-height: 1.25em;
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.msg.ok {
  color: var(--ok);
}

.msg.err {
  color: var(--danger);
}

.banner {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
}

.banner.ok {
  color: #067647;
  background: #ecfdf3;
  border-color: #abefc6;
}

.banner.err {
  color: #b42318;
  background: #fef3f2;
  border-color: #fecdca;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.22);
  pointer-events: none;
}

.toast.ok {
  background: #099250;
}

.toast.err {
  background: #d92d20;
}

.upload-list,
.file-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.upload-item,
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.file-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
  background: #e8eef8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-thumb.is-video {
  background: linear-gradient(160deg, #1c2430, #3a4a63);
  color: #fff;
}

.file-thumb .play-badge {
  font-size: 1rem;
  line-height: 1;
}

.file-actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.upload-name,
.file-name {
  word-break: break-all;
  font-weight: 600;
}

button.file-name.linkish {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

button.file-name.linkish:hover {
  color: var(--accent);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 22, 32, 0.72);
}

.preview-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(90vh, 900px);
  background: #0f141c;
  color: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
}

.preview-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}

.preview-media {
  max-width: 100%;
  max-height: min(78vh, 780px);
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #000;
}

video.preview-media {
  width: 100%;
}

.upload-status,
.file-size {
  color: var(--muted);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.upload-item.ok .upload-status {
  color: var(--ok);
}

.upload-item.err .upload-status {
  color: var(--danger);
}

.file-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-time {
  font-weight: 700;
  font-size: 0.92rem;
  color: #e11d48;
  letter-spacing: 0.01em;
}

.empty {
  margin: 14px 0 0;
  color: var(--muted);
  text-align: center;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .page {
    padding: 36px 24px 64px;
  }

  .page.browsing {
    padding: 0;
  }

  .card {
    padding: 22px;
  }

  .card.files-full {
    padding: 20px 28px 28px;
  }

  .row {
    flex-direction: row;
  }

  .row .input {
    flex: 1;
  }

  .btn-block {
    width: auto;
  }
}
