:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1e1e20;
  --muted: #5b5d63;
  --accent: #ffb400;
  --shadow: 0 10px 24px rgba(20, 22, 26, 0.08);
  --border-radius: 16px;
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  padding: 56px 24px 24px;
  text-align: center;
}

header h1 {
  margin: 0 0 12px;
  font-size: 2.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.header-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.header-logo:hover {
  transform: rotate(15deg) scale(1.1);
}

header p {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

main {
  max-width: var(--max-width);
  margin: 0 auto 96px;
  padding: 0 24px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
  position: sticky;
  top: 16px;
  z-index: 200;
  background: rgba(245, 246, 248, 0.92);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 18px 36px rgba(15, 16, 20, 0.08);
}

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

.filter-button {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.filter-button:hover {
  transform: translateY(-2px);
}

.filter-button.active {
  background: var(--accent);
  color: #322000;
  font-weight: 600;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.85;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.search-box:focus-within .search-icon {
  opacity: 1;
  transform: scale(1.1);
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  font-size: 0.95rem;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 180, 0, 0.25);
}

.result-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 16px;
}

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

.case-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.case-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(20, 22, 26, 0.12);
}

.case-cover {
  position: relative;
  padding-top: 66%;
  overflow: hidden;
}

.case-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 4px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.case-number {
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.case-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.case-categories span {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.case-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.case-title a {
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.case-title a:hover {
  text-decoration: underline;
}

.case-by {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--muted);
  gap: 16px;
}

.loading-placeholder img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.back-to-top {
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #322000;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(255, 180, 0, 0.4);
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 120;
  transform: translateY(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.back-to-top img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.back-to-top:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(255, 180, 0, 0.6);
}

.back-to-top:hover img {
  transform: translateY(-2px);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top.visible:hover {
  transform: translateY(-4px);
}

.back-to-top:focus-visible {
  outline: 3px solid rgba(255, 180, 0, 0.5);
  outline-offset: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 56px rgba(15, 16, 20, 0.2);
  width: min(960px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-header {
  padding: 28px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.modal-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-link {
  font-size: 0.9rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.modal-link:hover {
  text-decoration: underline;
}

.modal-prompt {
  padding: 24px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-prompt h3 {
  margin: 0;
  font-size: 1rem;
}

.copy-button {
  border: none;
  background: var(--accent);
  color: #322000;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.copy-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(255, 180, 0, 0.35);
}

.copy-button:disabled {
  background: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.4);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.modal-prompt pre {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  background: #f1f3f6;
  font-size: 0.95rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
}

.modal-prompt code {
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

.modal-note {
  margin: 0;
  font-size: 0.85rem;
  color: #6d6f76;
}

.modal-gallery {
  padding: 24px 32px 32px;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.modal-table th,
.modal-table td {
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 12px;
  vertical-align: top;
  background: #fff;
}

.modal-table th {
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.modal-table td.empty {
  background: rgba(0, 0, 0, 0.02);
}

.modal-thumb {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.thumb-button {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(20, 22, 26, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumb-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(20, 22, 26, 0.18);
}

.thumb-button img {
  width: 100%;
  max-width: 240px;
  max-height: 160px;
  object-fit: cover;
  display: block;
}

.modal-thumb figcaption {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1100;
}

.modal-lightbox.hidden {
  display: none;
}

.modal-lightbox img {
  max-width: min(90vw, 1024px);
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

@media (max-width: 720px) {
  header {
    padding-top: 40px;
  }

  header h1 {
    font-size: 1.9rem;
  }

  .header-logo {
    width: 44px;
    height: 44px;
  }
  
  .search-icon {
    width: 28px;
    height: 28px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .controls {
    top: 8px;
    padding: 16px;
  }

  .modal-dialog {
    width: 100%;
  }

  .modal-prompt {
    padding: 24px 20px 0;
  }

  .modal-gallery {
    padding: 20px;
  }

  .thumb-button img {
    width: 100%;
    max-height: 200px;
  }

  .back-to-top {
    right: 16px;
    bottom: 24px;
    width: 56px;
    height: 56px;
  }

  .back-to-top img {
    width: 36px;
    height: 36px;
  }
}
