:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #161814;
  --muted: #62675e;
  --line: #d9ddd2;
  --accent: #0b6b68;
  --accent-strong: #094f4d;
  --chip: #eef3e8;
  --shadow: 0 8px 26px rgba(29, 34, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.lightbox-active {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.94);
  backdrop-filter: blur(14px);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

p {
  margin: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions a,
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 9px 12px;
  text-decoration: none;
  white-space: nowrap;
}

button:disabled {
  cursor: progress;
  opacity: 0.66;
}

button.primary,
button:hover,
.actions a:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: calc(100vh - 78px);
}

.sidebar {
  position: sticky;
  top: 79px;
  height: calc(100vh - 79px);
  padding: 20px;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.search {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: var(--panel);
  color: var(--ink);
}

.category-list {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
}

.category.active {
  border-color: var(--accent);
  background: #e7f1ee;
  color: var(--accent-strong);
}

.badge {
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 12px;
}

.results {
  padding: 22px;
}

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

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.preview {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #ecefe7;
  overflow: hidden;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-button {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: block;
}

.preview-button:hover {
  transform: none;
  border-color: transparent;
}

.preview-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.prompt {
  max-height: 190px;
  overflow: auto;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf8;
  color: #24271f;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
}

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

.card-actions a {
  color: var(--accent-strong);
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  border-radius: 6px;
  background: #17201d;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  padding: 10px 12px;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.lightbox.open {
  display: block;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 16, 12, 0.78);
}

.lightbox-panel {
  position: absolute;
  inset: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #10120f;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
}

.lightbox-header h2 {
  margin: 0;
  color: #fff;
  font-size: 15px;
  line-height: 1.35;
  text-transform: none;
}

.lightbox-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

@media (max-width: 780px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .lightbox-panel {
    inset: 8px;
  }

  .lightbox-header {
    align-items: flex-start;
  }
}
