:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-strong: #f2f5f8;
  --text: #162033;
  --muted: #647084;
  --line: #d9e0ea;
  --line-strong: #c3ccd9;
  --accent: #0f766e;
  --accent-strong: #0d5f59;
  --accent-soft: #d9f4ee;
  --blue: #2563eb;
  --violet: #7c3aed;
  --orange: #c2410c;
  --red: #be123c;
  --gold: #a16207;
  --green: #15803d;
  --shadow: none;
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 16px 22px 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0 14px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.source-link,
.icon-button,
.filter-option,
.tag-button {
  min-height: 36px;
  border-radius: var(--radius);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover,
.source-link:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.filters,
.results-pane,
.detail-pane {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(360px, 0.8fr) minmax(520px, 1.2fr);
  gap: 14px;
  align-items: start;
}

.filters,
.results-pane,
.detail-pane {
  border-radius: var(--radius);
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
}

.filters {
  position: sticky;
  top: 12px;
  display: grid;
  max-height: calc(100vh - 24px);
  gap: 18px;
  overflow: auto;
  padding: 14px;
}

.filter-block {
  display: grid;
  gap: 10px;
}

.filter-list {
  display: grid;
  gap: 8px;
}

.filter-option {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.filter-option:hover,
.filter-option.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--dot-color, var(--accent));
}

.filter-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.tag-button {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.tag-button.is-active,
.tag-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.results-pane {
  min-width: 0;
  padding: 16px;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.results-toolbar h2 {
  margin-bottom: 4px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.toolbar-search {
  width: 240px;
}

.toolbar-search input,
.sort-control select {
  min-height: 38px;
}

#resultCount {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sort-control select {
  min-height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

.results-list {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.prompt-card {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--card-color, var(--accent));
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.prompt-card:hover,
.prompt-card:focus-visible,
.prompt-card.is-selected {
  border-color: var(--card-color, var(--accent));
  box-shadow: 0 12px 24px rgba(22, 32, 51, 0.08);
  transform: translateY(-1px);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card-color, var(--accent)) 14%, #fff);
  color: color-mix(in srgb, var(--card-color, var(--accent)) 72%, #111827);
  font-size: 12px;
  font-weight: 800;
}

.length-chip {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prompt-card h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.35;
}

.prompt-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.card-tags,
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mini-tag {
  min-height: 22px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.detail-pane {
  position: sticky;
  top: 16px;
  min-width: 0;
  overflow: hidden;
}

.empty-detail {
  padding: 28px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.detail-kicker {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-head h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.3;
}

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

.icon-button {
  display: inline-grid;
  width: 38px;
  min-width: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.icon-button svg,
.source-link svg,
.search-icon svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.prompt-body {
  max-height: calc(100vh - 190px);
  min-height: 500px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: #20293a;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.action-status {
  min-height: 18px;
  margin-bottom: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    max-height: none;
  }

  .detail-pane {
    position: static;
    grid-column: 1 / -1;
  }

  .prompt-body {
    max-height: 560px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .results-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .results-pane {
    order: 1;
  }

  .detail-pane {
    order: 2;
  }

  .filters {
    order: 3;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .toolbar-search,
  .sort-control,
  .sort-control select {
    width: 100%;
  }

  .sort-control {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

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

  .detail-head {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    justify-content: flex-start;
  }

  .prompt-body {
    max-height: 480px;
    min-height: 280px;
  }
}
