/* Prompt Atlas — design system
   Themes via [data-theme]; light is the default, dark is opt-in and persisted. */

:root {
  --bg: #f7f9fc;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --line: #dbe3ee;
  --line-strong: #c3cfe0;
  --text: #0e1a2b;
  --muted: #5b6b82;
  --faint: #8494a8;
  --brand: #15803d;
  --brand-strong: #14532d;
  --brand-soft: #e7f6ec;
  --accent: #0e7490;
  --accent-soft: #e0f2f7;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow-sm: 0 1px 2px rgba(15, 26, 43, .06), 0 1px 3px rgba(15, 26, 43, .05);
  --shadow-md: 0 4px 12px rgba(15, 26, 43, .08), 0 2px 4px rgba(15, 26, 43, .04);
  --shadow-lg: 0 24px 60px rgba(15, 26, 43, .18);
  --radius: 14px;
  --radius-lg: 20px;
  --wrap: 1180px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #08111f;
  --bg-elev: #0d1a2c;
  --panel: #101f34;
  --line: #26374f;
  --line-strong: #37496a;
  --text: #eef5ff;
  --muted: #a2b4cc;
  --faint: #7f93ad;
  --brand: #bdfa76;
  --brand-strong: #d5ffa4;
  --brand-soft: #17281a;
  --accent: #76e9e5;
  --accent-soft: #12262c;
  --warn: #ffd781;
  --danger: #ffb9a9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 35px 110px rgba(0, 0, 0, .7);
}

/* Before JS runs, follow the OS preference so there is no theme flash. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #08111f;
    --bg-elev: #0d1a2c;
    --panel: #101f34;
    --line: #26374f;
    --line-strong: #37496a;
    --text: #eef5ff;
    --muted: #a2b4cc;
    --faint: #7f93ad;
    --brand: #bdfa76;
    --brand-strong: #d5ffa4;
    --brand-soft: #17281a;
    --accent: #76e9e5;
    --accent-soft: #12262c;
    --warn: #ffd781;
    --danger: #ffb9a9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 35px 110px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.wrap { width: min(var(--wrap), calc(100% - 32px)); margin-inline: auto; }
.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: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--brand); color: var(--bg-elev); padding: 10px 16px;
  border-radius: 10px; font-weight: 700; transition: top .15s;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.02em; }
.brand-logo {
  display: block; width: 58px; height: 33px; object-fit: contain; flex: none;
  border-radius: 8px; background: #fff; box-shadow: var(--shadow-sm);
}
.brand-name { font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.nav-link { font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-radius: 9px; }
.nav-link:hover { color: var(--text); background: var(--panel); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 9px 13px; font-size: 13px; font-weight: 700;
  line-height: 1.2; transition: background .14s, border-color .14s, transform .06s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--bg-elev); }
[data-theme="dark"] .btn.primary { color: #0b1a10; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.sm { padding: 7px 10px; font-size: 12px; }
.btn.icon { padding: 8px; width: 36px; height: 36px; }
.btn[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.chip {
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 700;
}
.chip:hover { color: var(--text); border-color: var(--brand); }
.chip[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; }
.hero-inner { max-width: 780px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--panel);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 700;
  color: var(--muted); letter-spacing: .01em;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.hero h1 {
  font-size: clamp(38px, 6.4vw, 74px); line-height: 1.02; letter-spacing: -.045em;
  margin: 22px 0 16px; font-weight: 800;
}
.hero h1 .grad {
  background: linear-gradient(92deg, var(--brand), var(--accent) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lede { font-size: 17px; color: var(--muted); max-width: 620px; margin: 0 0 26px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.stat {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 14px 18px; min-width: 150px; box-shadow: var(--shadow-sm);
}
.stat strong { display: block; font-size: 26px; letter-spacing: -.03em; line-height: 1.1; }
.stat small { color: var(--muted); font-size: 12.5px; }

/* ---------- Hero category browser ---------- */
.category-browser { margin-top: 34px; }
.category-title { font-size: 21px; letter-spacing: -.02em; margin: 0 0 4px; font-weight: 800; }
.category-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; }
.category-links { display: flex; flex-wrap: wrap; gap: 9px; }
.category-link {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 10px 13px; font-size: 13px; font-weight: 700;
  transition: border-color .14s, background .14s, color .14s;
}
.category-link span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.category-link:hover, .category-link:focus-visible { border-color: var(--brand); }
.category-link.active { background: var(--brand); border-color: var(--brand); color: var(--bg-elev); }
[data-theme="dark"] .category-link.active { color: #0b1a10; }
.category-link.active span { color: inherit; opacity: .8; }

/* ---------- Toolbar ---------- */
.library-head { margin-top: 20px; }
.section-title { font-size: 27px; letter-spacing: -.03em; margin: 0 0 4px; font-weight: 800; }
.section-title.spaced { margin-top: 40px; }
.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.toolbar {
  position: sticky; top: var(--header-h); z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-block: 1px solid var(--line);
  padding: 12px 0; margin-bottom: 8px;
}
.toolbar-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search {
  width: 100%; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 11px; padding: 11px 14px 11px 38px; outline: 0;
}
.search:focus { border-color: var(--brand); }
select.control {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 10px 12px; max-width: 220px; font-size: 13px; font-weight: 600;
}
.view-tabs { display: flex; gap: 6px; }
.result-meta { color: var(--muted); font-size: 13px; margin: 14px 0 4px; }
.active-filter { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 16px; }
.card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius-lg);
  padding: 20px; min-height: 250px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-icon { font-size: 22px; line-height: 1; }
.card-tags { display: flex; align-items: center; gap: 6px; }
.tag {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 3px 7px;
}
.tag.fb { color: var(--brand); background: var(--brand-soft); }
.card h3 { font-size: 18px; line-height: 1.28; letter-spacing: -.02em; margin: 2px 0 0; }
.card .byline { font-size: 12px; color: var(--muted); }
.card .excerpt {
  font-size: 13.5px; color: var(--muted); flex: 1; margin: 4px 0 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.card-actions .btn { flex: 0 1 auto; }
.star { margin-left: auto; }

/* ---------- Source rows ---------- */
.source-rows { display: grid; gap: 10px; margin-top: 16px; }
.source-row {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 14px;
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.source-num { font-size: 20px; font-weight: 800; color: var(--faint); font-variant-numeric: tabular-nums; }
.source-row h3 { margin: 0 0 6px; font-size: 16px; }
.source-row p { margin: 4px 0; font-size: 12.5px; color: var(--muted); }
.source-url { color: var(--accent); word-break: break-all; font-size: 12px; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.source-actions { display: flex; flex-direction: column; gap: 7px; align-items: stretch; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; border: 1px solid var(--line-strong); color: var(--accent); }
.badge.partial { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.badge.unavailable { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }

/* ---------- States ---------- */
.empty, .loading { grid-column: 1 / -1; text-align: center; padding: 56px 20px; color: var(--muted); }
.skeleton {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px;
  min-height: 250px; background: var(--bg-elev); overflow: hidden; position: relative;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--line) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.more-wrap { display: flex; justify-content: center; margin: 28px 0 60px; }

/* ---------- Guide / info panel ---------- */
.info-panel {
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius-lg);
  padding: 26px; margin: 48px 0; box-shadow: var(--shadow-sm);
}
.info-panel h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: -.02em; }
.info-panel p { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; max-width: 78ch; }
.info-panel .btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 12.5px; }
.footer-grid { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-start; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(6, 12, 22, .62);
  display: grid; place-items: center; padding: 16px; backdrop-filter: blur(6px);
}
.modal {
  width: min(780px, 100%); max-height: 90vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal h2 { font-size: 26px; letter-spacing: -.03em; margin: 6px 0 0; line-height: 1.2; }
.modal .meta { font-size: 11.5px; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.close-btn {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--panel); font-size: 20px; line-height: 1; display: grid; place-items: center;
}
.label { color: var(--brand); font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; margin: 22px 0 8px; }
.promptbox {
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
  background: color-mix(in srgb, var(--panel) 60%, var(--bg)); border: 1px solid var(--line);
  padding: 16px; border-radius: 12px; font-size: 14px; line-height: 1.75; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.attribution { font-size: 13px; color: var(--muted); }
.act { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sample-image { margin: 0; }
.sample-image img { display: block; width: 100%; height: auto; max-height: 62vh; object-fit: contain; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.sample-image figcaption { font-size: 12px; color: var(--faint); margin-top: 8px; }
textarea {
  width: 100%; min-height: 130px; padding: 14px; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 12px; resize: vertical; font-family: inherit;
}
details summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 4px 0; }
.detail-list { display: grid; gap: 8px; margin-top: 12px; }
.detail-list .btn { text-align: left; justify-content: flex-start; }
.note-block { margin-top: 16px; }
.saved-text { margin-top: 24px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  background: var(--text); color: var(--bg-elev); border-radius: 11px;
  padding: 13px 18px; font-weight: 700; font-size: 13.5px;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px);
  transition: opacity .18s, transform .18s; pointer-events: none;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* ---------- Standalone SEO page ---------- */
.seo-page { padding: 40px 0 60px; }
.breadcrumb { font-size: 13px; color: var(--faint); margin-bottom: 18px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.seo-page h1 { font-size: clamp(28px, 4.5vw, 42px); letter-spacing: -.035em; margin: 8px 0 12px; line-height: 1.1; }
.seo-lede { color: var(--muted); font-size: 16px; max-width: 68ch; }
.related { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

@media (max-width: 720px) {
  .source-row { grid-template-columns: 34px 1fr; }
  .source-actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; }
  .hero { padding: 40px 0 24px; }
  .modal { padding: 20px; }
  .cards { grid-template-columns: 1fr; }
  .category-links { gap: 7px; }
  .category-link { font-size: 12px; padding: 9px 11px; }
  .brand-logo { width: 46px; height: 27px; }
}
@media (max-width: 480px) {
  .brand-sub { display: none; }
  .stat { min-width: 0; flex: 1 1 40%; }
}
