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

:root {
  --bg: #0d1117;
  --card-bg: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --red: #f85149;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ====== Header ====== */
header {
  text-align: center;
  padding: 48px 24px 24px;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #f0f6fc;
}
.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 6px;
}

/* ====== FAB ====== */
.fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(88,166,255,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(88,166,255,0.5);
}

/* ====== Main ====== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 64px 0;
  font-size: 1rem;
}

.folder-section {
  margin-bottom: 48px;
}
.folder-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.folder-title .count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

/* ====== Grid (perf: content-visibility) ====== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.image-grid img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  background: var(--card-bg);
  content-visibility: auto;
  contain-intrinsic-size: 260px 162px;
}
.image-grid img:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* ====== Lightbox ====== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  cursor: zoom-out;
  animation: fadeIn 0.15s;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
}
.lightbox .close {
  position: fixed;
  top: 20px;
  right: 32px;
  font-size: 2.2rem;
  color: var(--muted);
  cursor: pointer;
  z-index: 1001;
  transition: color 0.2s;
  line-height: 1;
}
.lightbox .close:hover { color: #fff; }
#lightbox-info {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 12px;
  text-align: center;
}

/* ====== Empty ====== */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 0;
  font-size: 1rem;
}
.empty p { margin-bottom: 8px; }
.empty code { color: var(--accent); background: var(--card-bg); padding: 2px 8px; border-radius: 4px; }

/* ====== Modal ====== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.15s;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.modal-content h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}
.modal-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 20px;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { color: #fff; }

/* ====== File picker ====== */
.file-picker {
  display: block;
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
.file-picker:hover { border-color: var(--accent); }
.file-picker input { display: none; }
.file-picker span { color: var(--accent); font-weight: 600; }

/* ====== Preview list ====== */
.preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 150px;
  overflow-y: auto;
}
.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-item .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.preview-item .remove:hover { background: var(--red); }

/* ====== Captcha ====== */
.captcha-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 1.1rem;
}
.captcha-label {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  line-height: 1;
}
.captcha-eq {
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin: 0 2px;
}
.captcha-input {
  width: 64px;
  height: 34px;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  line-height: 34px;
}
.captcha-input:focus { border-color: var(--accent); }

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

/* ====== Progress ====== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}
.progress-bar.hidden { display: none; }
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}
.progress-text {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ====== Confirm ====== */
.btn-confirm {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-confirm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-confirm:not(:disabled):hover { opacity: 0.85; }

.upload-msg {
  margin-top: 12px;
  font-size: 0.85rem;
  text-align: center;
}
.upload-msg.success { color: var(--green); }
.upload-msg.error { color: var(--red); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
