:root {
  color-scheme: dark;

  /* === 核心色票 === */
  --bg: #0a0e14;
  --bg-elevated: #111823;
  --bg-surface: rgba(21, 31, 44, 0.65);
  --bg-surface-hover: rgba(28, 41, 58, 0.8);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(99, 179, 255, 0.35);

  --text: #e6edf5;
  --text-muted: #8b98a9;
  --text-dim: #5a6573;

  --accent: #63b3ff;
  --accent-bright: #8ac5ff;
  --accent-glow: rgba(99, 179, 255, 0.4);

  --success: #5ce8a4;
  --warning: #ffb455;
  --danger: #ff6b7a;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);

  --transition: 160ms cubic-bezier(0.4, 0.0, 0.2, 1);
  --transition-slow: 280ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK TC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  overflow-x: hidden;
}

/* Subtle ambient glow, not the previous noisy grid */
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(99, 179, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(92, 232, 164, 0.04), transparent);
}

/* ============= TYPOGRAPHY ============= */
h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 { font-size: 1.25rem; }

code {
  font-family: "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-bright);
}

pre {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}

pre code {
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.82em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  vertical-align: baseline;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button, input, select {
  font: inherit;
  color: inherit;
}

/* ============= TOP BAR ============= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), rgba(99, 179, 255, 0.6));
  color: var(--bg);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.brand-name {
  color: var(--text);
}

.stats {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.stat-item span {
  color: var(--text);
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 12px;
  background: var(--border-strong);
}

/* ============= CONTAINER ============= */
.container {
  position: relative;
  z-index: 1;
  width: min(780px, 100% - 32px);
  margin: 0 auto;
  padding: 32px 0 64px;
}

.upload-section,
.results-section {
  margin-bottom: 32px;
}

/* ============= DROP ZONE ============= */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
}

.drop-zone:hover,
.drop-zone:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  border-color: var(--border-accent);
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(99, 179, 255, 0.06);
  box-shadow: 0 0 0 4px rgba(99, 179, 255, 0.1);
  transform: scale(1.005);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  color: var(--accent);
  background: rgba(99, 179, 255, 0.1);
  border-radius: 50%;
  transition: all var(--transition);
}

.drop-zone:hover .drop-icon,
.drop-zone.is-dragging .drop-icon {
  transform: translateY(-2px);
  background: rgba(99, 179, 255, 0.15);
}

.drop-text h2 {
  margin-bottom: 6px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.drop-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.drop-link {
  color: var(--accent);
  font-weight: 500;
}

/* ============= SELECTED FILES ============= */
.selected-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0 0;
}

.selected-files:empty {
  display: none;
}

.selected-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  animation: slide-in 180ms ease;
}

.selected-file-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(99, 179, 255, 0.12);
  color: var(--accent);
}

.selected-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.selected-file-size {
  flex-shrink: 0;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.selected-file-remove {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}

.selected-file-remove:hover {
  color: var(--danger);
  background: rgba(255, 107, 122, 0.1);
}

/* ============= CONTROLS ============= */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

select,
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition);
  appearance: none;
}

select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b98a9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px rgba(99, 179, 255, 0.12);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

/* ============= BUTTONS ============= */
.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  margin-top: 20px;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: 0 2px 10px rgba(99, 179, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 179, 255, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.btn-label {
  position: relative;
  z-index: 1;
}

.btn-progress {
  position: absolute;
  inset: 0;
  left: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.1));
  transition: width 120ms linear;
  pointer-events: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn-ghost svg {
  transition: transform var(--transition);
}

.btn-ghost:hover svg {
  transform: rotate(-180deg);
}

/* ============= SECTION HEAD ============= */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ============= RESULTS ============= */
.results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.92rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.file-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  animation: slide-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.file-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.file-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.file-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(99, 179, 255, 0.12);
  color: var(--accent);
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.file-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.file-meta-item.expiring {
  color: var(--warning);
}

.file-meta-item.expired {
  color: var(--danger);
}

.file-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-action:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(99, 179, 255, 0.08);
}

.btn-action.btn-copy.is-copied {
  color: var(--success);
  border-color: rgba(92, 232, 164, 0.3);
  background: rgba(92, 232, 164, 0.08);
}

.btn-action.btn-download {
  color: var(--accent);
  border-color: rgba(99, 179, 255, 0.25);
  background: rgba(99, 179, 255, 0.08);
}

.btn-action.btn-download:hover {
  color: var(--accent-bright);
  border-color: rgba(99, 179, 255, 0.4);
  background: rgba(99, 179, 255, 0.14);
}

.btn-action.btn-delete:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 122, 0.3);
  background: rgba(255, 107, 122, 0.08);
}

/* ============= API DRAWER ============= */
.api-drawer {
  margin-top: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.api-drawer:hover {
  border-color: var(--border-strong);
}

.api-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  list-style: none;
  user-select: none;
}

.api-drawer summary::-webkit-details-marker {
  display: none;
}

.api-drawer summary:hover {
  color: var(--text);
}

.api-drawer .chevron {
  transition: transform var(--transition);
  color: var(--text-dim);
}

.api-drawer[open] .chevron {
  transform: rotate(180deg);
}

.api-content {
  padding: 0 16px 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.api-content p {
  margin: 0 0 12px;
}

.api-content p:last-child {
  margin-bottom: 0;
}

.api-content pre {
  margin: 12px 0;
}

/* ============= TOAST ============= */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  pointer-events: auto;
  animation: toast-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-out {
  animation: toast-out 200ms ease forwards;
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent); }

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }

.toast-message {
  flex: 1;
  color: var(--text);
}

/* ============= ANIMATIONS ============= */
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

/* ============= REDUCED MOTION ============= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 560px) {
  .topbar {
    padding: 12px 16px;
  }

  .container {
    width: calc(100% - 24px);
    padding: 20px 0 40px;
  }

  .drop-zone {
    min-height: 180px;
    padding: 32px 16px;
  }

  .drop-icon {
    width: 48px;
    height: 48px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .file-actions {
    flex-wrap: wrap;
  }

  .stats {
    font-size: 0.8rem;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: none;
  }
}

/* ============= LIGHT MODE (auto) ============= */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --bg-elevated: #ffffff;
    --bg-surface: rgba(255, 255, 255, 0.8);
    --bg-surface-hover: rgba(255, 255, 255, 1);

    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.16);
    --border-accent: rgba(49, 130, 206, 0.4);

    --text: #1a202c;
    --text-muted: #64748b;
    --text-dim: #94a3b8;

    --accent: #3182ce;
    --accent-bright: #2c5282;
    --accent-glow: rgba(49, 130, 206, 0.3);
  }

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

  .bg-glow {
    background:
      radial-gradient(ellipse 80% 50% at 20% 0%, rgba(49, 130, 206, 0.06), transparent),
      radial-gradient(ellipse 60% 40% at 80% 20%, rgba(56, 161, 105, 0.04), transparent);
  }

  .topbar {
    background: rgba(245, 247, 250, 0.72);
  }

  .brand-icon {
    color: #ffffff;
  }

  .btn-primary {
    color: #ffffff;
  }

  kbd {
    color: var(--text-muted);
    background: #ffffff;
  }

  code {
    color: var(--accent-bright);
  }
}
