:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #1d2528;
  --muted: #667175;
  --line: #dad5ca;
  --accent: #0e7c86;
  --accent-strong: #0a5762;
  --warm: #b85c38;
  --green: #607c3c;
  --shadow: 0 10px 32px rgba(29, 37, 40, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 245, 239, 0.96) 28rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  border-block: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.94);
  backdrop-filter: blur(12px);
}

.controls-inner {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px 190px 160px;
  gap: 10px;
  padding: 12px 0;
}

.search,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.13);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 28px 0 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.result-count {
  color: var(--muted);
  font-size: 14px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding-bottom: 42px;
}

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

.thumb-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  display: block;
}

.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e7e1d5;
  object-fit: cover;
  display: block;
}

.case-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  min-height: 0;
}

.case-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.case-title h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0;
}

.case-id {
  flex: 0 0 auto;
  color: var(--warm);
  font-weight: 700;
  font-size: 12px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef5f3;
  color: #245960;
  font-size: 12px;
  white-space: nowrap;
}

.pill.scene {
  background: #f5eee5;
  color: #855237;
}

.prompt {
  position: relative;
  flex: 1 1 auto;
  min-height: 156px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #e4dfd3;
  border-radius: var(--radius);
  background: #fbfaf7;
  padding: 10px;
  color: #263032;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.btn {
  flex: 1 1 112px;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn.translate {
  border-color: rgba(14, 124, 134, 0.35);
  background: #f2faf9;
  color: var(--accent-strong);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.btn:hover {
  filter: brightness(0.98);
}

.translation {
  display: block;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #d7e6e4;
  border-radius: var(--radius);
  background: #f6fbfa;
  color: #233335;
  padding: 10px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.translation[hidden] {
  display: none;
}

.empty {
  display: none;
  margin: 26px 0 80px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 0 0 52px;
}

.load-more {
  min-width: 180px;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 650;
}

.load-more[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  min-height: 42px;
  display: none;
  align-items: center;
  justify-content: center;
  max-width: min(520px, calc(100% - 32px));
  padding: 0 16px;
  border-radius: 999px;
  background: #1d2528;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.toast.show {
  display: flex;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 18px;
  background: rgba(15, 20, 22, 0.88);
}

.lightbox.open {
  display: grid;
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
}

.lightbox-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.lightbox-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.lightbox-stage {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  background: #111;
}

footer {
  border-top: 1px solid var(--line);
  padding: 24px 0 36px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 880px) {
  .controls-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1480px);
  }

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

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .thumb {
    aspect-ratio: 1 / 1;
  }

  .case-body {
    gap: 8px;
    padding: 9px;
  }

  .case-title h3 {
    display: -webkit-box;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.32;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .case-id {
    font-size: 10px;
  }

  .meta {
    display: none;
  }

  .prompt {
    min-height: 74px;
    max-height: 88px;
    padding: 8px;
    font-size: 10.5px;
    line-height: 1.45;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .actions .btn:only-child {
    grid-column: 1 / -1;
  }

  .btn {
    width: 100%;
    min-height: 34px;
    font-size: 12px;
  }

  .translation {
    max-height: 160px;
    font-size: 12px;
  }

  .lightbox {
    padding: 12px;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }
}
