:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --line: #e2e8f0;
  --accent: #0d7377;
  --accent-2: #14919b;
  --danger: #c23b22;
  --ok: #1f7a4c;
  --warn: #b45309;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --radius: 14px;
  --font: "Outfit", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Fraunces", "Songti SC", "STSong", serif;
  --ink: #0b1f24;
  --sea: #0f6e6a;
  --mist: #d7ebe6;
  --sand: #e8dfd0;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(13, 115, 119, 0.12), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(20, 145, 155, 0.1), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

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

/* Login — banner wallpaper (ported from hugo-teek hero-bg) */
.login-body {
  --login-text: #f4faf8;
  --login-muted: rgba(244, 250, 248, 0.78);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 20px 28px;
  overflow: hidden;
  color: var(--login-text);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Dual-layer wallpaper host: solid base + crossfade top layer */
.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  --hero-bg-crossfade-duration: 2s;
  --hero-bg-crossfade-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

.login-bg::before,
.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  backface-visibility: hidden;
  transform: scale(1.06) translateZ(0);
  transform-origin: center center;
  animation: login-bg-breathing 8s ease-in-out 2s infinite;
}

.login-bg::before {
  background-image: var(--hero-bg-image-1, none);
  opacity: var(--hero-bg-opacity-1, 1);
  z-index: 0;
  transition: none;
}

.login-bg::after {
  background-image: var(--hero-bg-image-2, none);
  opacity: 0;
  z-index: 1;
  will-change: opacity;
  transition: opacity var(--hero-bg-crossfade-duration) var(--hero-bg-crossfade-ease);
}

.login-bg.hero-bg-incoming::after {
  opacity: 1;
}

.login-bg.hero-bg-no-transition::before,
.login-bg.hero-bg-no-transition::after {
  transition: none !important;
}

.login-bg.is-hero-bg-transitioning::before,
.login-bg.is-hero-bg-transitioning::after {
  animation-play-state: paused;
}

.login-bg.paused::before,
.login-bg.paused::after {
  animation-play-state: paused;
}

/* Readability scrim over bright wallpapers */
.login-bg-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 20, 22, 0.42) 0%, rgba(7, 20, 22, 0.28) 45%, rgba(7, 20, 22, 0.55) 100%),
    radial-gradient(900px 520px at 12% 18%, rgba(232, 223, 208, 0.08), transparent 58%);
}

@keyframes login-bg-breathing {
  0%, 100% { transform: scale(1.06) translateZ(0); }
  50% { transform: scale(1.08) translateZ(0); }
}

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

@media (max-width: 768px) {
  @keyframes login-bg-breathing {
    0%, 100% { transform: scale(1.04) translateZ(0); }
    50% { transform: scale(1.06) translateZ(0); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-bg::before,
  .login-bg::after {
    animation: none !important;
  }
  .login-bg {
    --hero-bg-crossfade-duration: 0.01s;
  }
}

.login-stage {
  position: relative;
  z-index: 2;
  width: min(100%, 440px);
  animation: loginRise 0.7s ease both;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,0.16), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.16);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f7f3ea;
  animation: loginRise 0.75s ease 0.08s both;
}
.login-brand h1 {
  font-family: var(--font-display);
  font-size: clamp(42px, 8vw, 56px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: #f7f3ea;
  margin-bottom: 10px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  animation: loginRise 0.75s ease 0.12s both;
}
.login-brand p {
  font-size: 15px;
  color: var(--login-muted);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
  animation: loginRise 0.75s ease 0.18s both;
}

.login-panel {
  position: relative;
  padding: 28px 26px 24px;
  border-radius: 20px;
  background: rgba(8, 18, 22, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  animation: loginRise 0.8s ease 0.22s both;
}

.login-panel .input-group { margin-bottom: 18px; }
.login-panel .input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: rgba(244, 250, 248, 0.82);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.login-panel .input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  color: #0b1f24;
  background: rgba(247, 243, 234, 0.94);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.login-panel .input-group input::placeholder {
  color: rgba(11, 31, 36, 0.4);
}
.login-panel .input-group input:focus {
  border-color: rgba(15, 110, 106, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 110, 106, 0.22);
  transform: translateY(-1px);
}

.btn-login,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn-login {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #14827c 0%, #0d5f5b 100%);
  letter-spacing: 0.04em;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(7, 20, 22, 0.35);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 115, 119, 0.25);
}
.btn:disabled, .btn-login:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--danger); }

.login-panel .error-message {
  display: none;
  margin-top: 14px;
  text-align: center;
  color: #ffb4a8;
  font-size: 13px;
}
.login-panel .error-message.countdown { color: #ffd59a; }

.login-footer {
  position: relative;
  z-index: 2;
  margin-top: 28px;
  font-size: 12px;
  color: rgba(244, 250, 248, 0.62);
  text-align: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
  animation: loginRise 0.8s ease 0.3s both;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.login-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.login-footer a:hover {
  color: #f7f3ea;
  border-bottom-color: rgba(247, 243, 234, 0.45);
  text-decoration: none;
}
.login-version {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(244, 250, 248, 0.42);
  user-select: all;
}

@media (max-width: 480px) {
  .login-panel { padding: 24px 18px 20px; }
  .login-brand h1 { font-size: 40px; }
}

/* Admin layout */
.admin-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand h1 { font-size: 26px; letter-spacing: 0.03em; }
.brand span { color: var(--muted); font-size: 13px; }

.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
}
.panel-hint {
  color: var(--muted);
  font-size: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stats.stats-summary {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .stats.stats-summary { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .stats.stats-summary { grid-template-columns: repeat(2, 1fr); }
}
.stat {
  background: linear-gradient(180deg, #f8fbfb, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

.upload-zone {
  border: 1.5px dashed #9ec5c7;
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  background: rgba(13, 115, 119, 0.03);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(13, 115, 119, 0.08);
}
.upload-zone h3 { margin-bottom: 6px; }
.upload-zone p { color: var(--muted); font-size: 13px; }
.upload-zone input { display: none; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.toolbar label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.view-toggle {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.view-toggle .view-btn {
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}
.view-toggle .view-btn + .view-btn {
  border-left: 1px solid var(--line);
}
.view-toggle .view-btn:hover {
  color: var(--accent);
  background: rgba(13, 115, 119, 0.06);
}
.view-toggle .view-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.grid.grid-5x5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.grid.view-list {
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (max-width: 1100px) {
  .grid.grid-5x5:not(.view-list) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grid.grid-5x5:not(.view-list) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid.grid-5x5:not(.view-list) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-toggle { margin-left: 0; width: 100%; }
  .view-toggle .view-btn { flex: 1; }
}

.pager {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pager-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.pager-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.pager-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pager-btn.pager-ok {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
.pager-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}
.pager-goto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}
.pager-goto input {
  width: 56px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  outline: none;
}
.pager-goto input:focus {
  border-color: var(--accent);
}
.pager-total {
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.card .thumb {
  aspect-ratio: 1;
  background: #eef2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: zoom-in;
}
.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card .meta {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.card .title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .meta-sep { opacity: 0.55; }
.card .meta-date { overflow: hidden; text-overflow: ellipsis; }
.card .meta-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
}
.badge.ready { background: #e7f7ee; color: var(--ok); }
.badge.processing { background: #fff7e6; color: var(--warn); }
.badge.failed { background: #fdeceb; color: var(--danger); }
.badge[title*="PicList"] { background: #e8f1ff; color: #1d4f91; }

.card .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.card .actions .btn { padding: 6px 10px; font-size: 12px; }

/* List view: one row per image */
.grid.view-list .card {
  flex-direction: row;
  align-items: center;
  border-radius: 10px;
  min-height: 72px;
}
.grid.view-list .card .thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  aspect-ratio: auto;
  border-radius: 0;
}
.grid.view-list .card .meta {
  flex: 1;
  padding: 10px 14px;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.grid.view-list .card .title {
  flex: 1 1 180px;
  min-width: 120px;
  font-size: 14px;
}
.grid.view-list .card .meta-info {
  flex: 0 0 auto;
  font-size: 12px;
  min-width: 140px;
}
.grid.view-list .card .meta-badges {
  flex: 0 0 auto;
}
.grid.view-list .card .actions {
  flex: 0 0 auto;
  margin-left: auto;
  flex-wrap: nowrap;
}

@media (max-width: 720px) {
  .grid.view-list .card .meta {
    gap: 8px;
  }
  .grid.view-list .card .meta-info {
    min-width: 0;
    width: 100%;
  }
  .grid.view-list .card .actions {
    margin-left: 0;
    width: 100%;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1a2332;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: min(92vw, 420px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(10, 16, 24, 0.28);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-success {
  top: 50%;
  bottom: auto;
  left: 50%;
  transform: translate(-50%, -40%) scale(0.92);
  padding: 22px 28px 20px;
  border-radius: 16px;
  background: linear-gradient(160deg, #12352c 0%, #0b1f24 100%);
  border: 1px solid rgba(61, 184, 130, 0.45);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 24px 64px rgba(10, 16, 24, 0.45);
}
.toast.toast-success.show {
  transform: translate(-50%, -50%) scale(1);
}
.toast.toast-success::before {
  content: "✓";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(61, 184, 130, 0.22);
  color: #5ee9a8;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 24, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 88vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; align-items: flex-start; }
}
