:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --bg-translucent: rgba(245, 243, 238, 0.92);
  --surface: #fffefa;
  --surface-translucent: rgba(255, 254, 250, 0.94);
  --surface-soft: #efede7;
  --surface-strong: #e8e5dd;
  --text: #211f1b;
  --muted: #716d64;
  --faint: #99948a;
  --line: #d9d5cc;
  --accent: #bd761d;
  --accent-soft: rgba(189, 118, 29, 0.11);
  --accent-ink: #281805;
  --accent-contrast: #281805;
  --danger: #a84937;
  --preview-bg: #e8e6e0;
  --missing-a: #eceae4;
  --missing-b: #e7e4dd;
  --skeleton-a: #e4e1da;
  --skeleton-b: #ece9e2;
  --control-shadow: rgba(61, 53, 38, 0.08);
  --radius: 14px;
  --shadow: 0 8px 28px rgba(61, 53, 38, 0.06);
  font-family: "Avenir Next", Avenir, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171714;
  --bg-translucent: rgba(23, 23, 20, 0.92);
  --surface: #201f1b;
  --surface-translucent: rgba(32, 31, 27, 0.94);
  --surface-soft: #292821;
  --surface-strong: #343229;
  --text: #f0ede5;
  --muted: #b5b0a5;
  --faint: #89847b;
  --line: #3e3b34;
  --accent: #d3923c;
  --accent-soft: rgba(211, 146, 60, 0.14);
  --accent-ink: #241607;
  --accent-contrast: #241607;
  --danger: #df806d;
  --preview-bg: #151513;
  --missing-a: #24231e;
  --missing-b: #201f1b;
  --skeleton-a: #292820;
  --skeleton-b: #343229;
  --control-shadow: rgba(0, 0, 0, 0.32);
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1560px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--bg-translucent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 17px;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--bg);
  background: var(--accent);
}

.topbar-actions,
.sync-status,
.language-switch,
.theme-switch {
  display: flex;
  align-items: center;
}
.topbar-actions { gap: 0.55rem; }
.sync-status { gap: 0.5rem; color: var(--muted); font-size: 0.74rem; }
.sync-indicator { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.sync-status[data-state="loading"] .sync-indicator { animation: pulse 1s ease-in-out infinite; }
.sync-status[data-state="error"] { color: var(--danger); }
.sync-status[data-state="error"] .sync-indicator { background: var(--danger); }

.language-switch,
.theme-switch {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}
.language-switch button,
.theme-switch button {
  height: 27px;
  padding: 0 0.65rem;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  cursor: pointer;
}
.theme-switch button { padding-inline: 0.55rem; }
.language-switch button.is-active,
.theme-switch button.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 4px var(--control-shadow);
  font-weight: 700;
}

main {
  width: min(1560px, calc(100% - 48px));
  margin: 0 auto;
  padding-bottom: 6rem;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 3rem;
  padding: 3.5rem 0 2rem;
}

h1, h2, p { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  font-size: clamp(2rem, 3.4vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 750;
}
.intro-description {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.stats {
  display: flex;
  gap: 1.35rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stats div { min-width: 64px; }
.stats dt { color: var(--muted); font-size: 0.65rem; }
.stats dd { margin: 0.3rem 0 0; font: 650 1.3rem/1 "SFMono-Regular", Consolas, monospace; }

.controls {
  position: sticky;
  top: 70px;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-translucent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.search-field {
  height: 40px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.8rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--surface-soft);
}
.search-field:focus-within { border-color: var(--accent); }
.search-icon { width: 12px; height: 12px; border: 1.4px solid var(--muted); border-radius: 50%; position: relative; }
.search-icon::after { content: ""; position: absolute; width: 5px; height: 1.4px; right: -4px; bottom: -3px; background: var(--muted); transform: rotate(45deg); }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 0.82rem; }
.search-field input::placeholder { color: var(--faint); }
kbd { padding: 0.2rem 0.34rem; border: 1px solid var(--line); border-radius: 5px; color: var(--faint); font: 0.62rem/1 "SFMono-Regular", Consolas, monospace; }

.filter-row { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-button,
.empty-state button,
.load-error button {
  min-height: 36px;
  padding: 0.5rem 0.72rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}
.filter-button:hover { color: var(--text); background: var(--surface-soft); }
.filter-button.is-active { color: var(--accent-contrast); background: var(--accent); font-weight: 700; }
.filter-button:active,
.empty-state button:active,
.load-error button:active { transform: translateY(1px); }

.library {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.1rem;
  align-items: stretch;
}

.shot-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--preview-bg);
}
.preview video,
.preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-toggle {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  width: 29px;
  height: 29px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  background: rgba(20, 19, 17, 0.72);
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.video-toggle span::before,
.video-toggle span::after { content: ""; position: absolute; top: 8px; width: 3px; height: 12px; background: white; }
.video-toggle span::before { left: 10px; }
.video-toggle span::after { right: 10px; }
.video-toggle.is-paused span::before {
  top: 7px;
  left: 11px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid white;
  background: transparent;
}
.video-toggle.is-paused span::after { display: none; }

.preview-missing {
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--missing-a), var(--missing-a) 10px, var(--missing-b) 10px, var(--missing-b) 20px);
}
.missing-glyph { width: 36px; height: 26px; margin: 0 auto 0.55rem; border: 1px solid var(--line); border-radius: 5px; position: relative; background: var(--surface); }
.missing-glyph::after { content: ""; position: absolute; left: 7px; right: 7px; top: 50%; height: 1px; background: var(--faint); transform: rotate(-28deg); }
.preview-missing p { margin: 0; font-size: 0.76rem; }
.preview-missing small { max-width: 220px; margin-top: 0.35rem; color: var(--faint); font-size: 0.62rem; }

.card-body {
  min-height: 248px;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 1rem;
}
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.card-title { min-width: 0; }
.card-title h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.card-title > p {
  margin: 0.22rem 0 0;
  overflow: hidden;
  color: var(--faint);
  font: 0.62rem/1.3 "SFMono-Regular", Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.source-link {
  color: var(--muted);
  font-size: 0.66rem;
  text-underline-offset: 3px;
}
.source-link:hover { color: var(--accent); }
.copy-button {
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.66rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.select-button {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.66rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.select-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.select-check {
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  position: relative;
  flex-shrink: 0;
}
.select-button.is-selected {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.select-button.is-selected .select-check::after {
  content: '';
  position: absolute;
  inset: 1px 2px 3px 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(40deg) scale(0.72);
}

.shot-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.selection-bar[hidden] { display: none; }
.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.selection-count {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.selection-copy,
.selection-clear {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.selection-copy {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.selection-copy:hover { filter: brightness(1.08); }
.selection-clear {
  background: transparent;
  color: var(--muted);
}
.selection-clear:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.current-style {
  min-height: 38px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0.2rem 0.55rem;
  margin-top: 0.85rem;
}
.current-style > span {
  grid-row: 1 / span 2;
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.current-style strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.current-style code {
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 0.58rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary {
  display: -webkit-box;
  min-height: 3.05em;
  margin: 0.65rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.52;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.style-selector {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.style-option {
  position: relative;
  flex: 0 0 auto;
  max-width: 170px;
  height: 30px;
  padding: 0 0.62rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.style-option:hover { border-color: var(--accent); color: var(--text); }
.style-option.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.style-option i {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--danger);
}

.card-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) auto;
  gap: 0.6rem;
  margin: auto 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}
.card-meta div { min-width: 0; }
.card-meta dt { color: var(--faint); font-size: 0.58rem; }
.card-meta dd {
  margin: 0.22rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state,
.load-error { grid-column: 1 / -1; padding: 5rem 1rem; text-align: center; color: var(--muted); }
.empty-state button,
.load-error button { border-color: var(--line); color: var(--text); background: var(--surface); }

.skeleton-card { min-height: 440px; padding: 1rem; }
.skeleton-line,
.skeleton-media {
  border-radius: 7px;
  background: linear-gradient(100deg, var(--skeleton-a) 20%, var(--skeleton-b) 38%, var(--skeleton-a) 56%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
.skeleton-line { width: 68%; height: 12px; margin-top: 0.8rem; }
.skeleton-title { width: 42%; height: 25px; margin-top: 0; }
.skeleton-media { aspect-ratio: 16 / 9; margin-top: 1rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 15;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--text);
  box-shadow: var(--shadow);
  color: var(--bg);
  font-size: 0.72rem;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.75); } }
@keyframes shimmer { to { background-position-x: -220%; } }

@media (max-width: 1240px) {
  .library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .intro { grid-template-columns: 1fr; gap: 1.5rem; }
  .stats { width: fit-content; }
  .controls { grid-template-columns: 1fr; }
  .library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  main { width: min(100% - 24px, 1560px); }
  .topbar { padding: 0 12px; }
  .topbar-actions { gap: 0.55rem; }
  .theme-switch button { padding-inline: 0.42rem; }
  .sync-status span:last-child { display: none; }
  .intro { padding: 2.5rem 0 1.5rem; }
  h1 { font-size: 2.15rem; }
  .stats { width: 100%; justify-content: space-between; }
  .controls { top: 66px; }
  kbd { display: none; }
  .library { grid-template-columns: 1fr; }
  .card-body { min-height: 232px; }
}

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

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .controls {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
