/* AI Prompt library (/prompts).
   Flat, hairline-bordered, accent-agnostic — matches the GMI design system.
   Two-column: sticky category rail + a filterable table of prompt rows; clicking
   a row opens a detail overlay with the full prompt. */

.prompts-hero .page-hero-sub { max-width: 680px; }

.prompts-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 24px 96px;
}
@media (min-width: 640px) { .prompts-layout { padding: 8px 40px 104px; } }
@media (min-width: 920px) {
  .prompts-layout { grid-template-columns: 248px 1fr; gap: 48px; padding: 8px 64px 112px; }
}

/* ── sticky rail ─────────────────────────────────────────── */
.prompts-rail { font-size: 14px; }
@media (min-width: 920px) {
  .prompts-rail {
    position: sticky; top: 80px; align-self: start;
    max-height: calc(100vh - 96px); overflow-y: auto;
  }
}

.prompts-search { position: relative; margin-bottom: 16px; }
.prompts-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--fg-mute); pointer-events: none;
}
.prompts-search-input {
  width: 100%; box-sizing: border-box;
  padding: 11px 34px 11px 36px;
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--border); border-radius: 0;
  font-family: var(--font-mono); font-size: 13px;
}
.prompts-search-input::placeholder { color: var(--fg-mute); }
.prompts-search-input:focus { outline: none; border-color: var(--accent); }
.prompts-search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; line-height: 1; font-size: 18px;
  background: none; border: 0; color: var(--fg-mute); cursor: pointer;
}
.prompts-search-clear:hover { color: var(--fg); }

/* ── tag-chip filter bar ─────────────────────────────────── */
.prompts-tagbar-wrap { margin-bottom: 18px; }
.prompts-tagbar-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.prompts-tagbar-title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-mute);
}
.prompts-tag-clear {
  background: none; border: 0; cursor: pointer; padding: 0;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--fg-mute);
}
.prompts-tag-clear:hover { color: var(--accent); }

.prompts-tagbar { display: flex; flex-wrap: wrap; gap: 6px; }
.prompt-tagchip {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 0;
  padding: 4px 9px; cursor: pointer; text-transform: lowercase; line-height: 1.2;
}
.prompt-tagchip:hover { color: var(--fg); border-color: var(--accent); }
.prompt-tagchip.is-active {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
}

.prompts-status {
  border: 1px solid var(--border); background: var(--bg-soft);
  padding: 16px 18px; color: var(--fg-dim); font-size: 14px; margin: 0 0 24px;
}

.prompts-rail-navhead { margin: 0 0 8px; }

.prompts-rail-nav { display: flex; flex-direction: column; }
.prompts-rail-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; color: var(--fg-dim);
  border-bottom: 1px solid var(--border-soft);
  text-decoration: none;
}
.prompts-rail-link:hover { color: var(--fg); }
.prompts-rail-link.active { color: var(--accent); }
.prompts-rail-link.is-empty { opacity: 0.35; pointer-events: none; }
.prompts-rail-ic { display: inline-flex; width: 17px; height: 17px; flex: none; }
.prompts-rail-ic svg { width: 17px; height: 17px; }
.prompts-rail-label { flex: 1; font-size: 13.5px; }
.prompts-rail-count {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-mute);
  border: 1px solid var(--border-soft); padding: 1px 6px; min-width: 14px; text-align: center;
}

/* ── main column ─────────────────────────────────────────── */
.prompts-main { min-width: 0; }

.prompts-noresults {
  border: 1px solid var(--border); background: var(--bg-soft);
  padding: 16px 18px; color: var(--fg-dim); font-size: 14px; margin: 0 0 24px;
}

.prompt-cat { margin-bottom: 44px; scroll-margin-top: 88px; }
.prompt-cat.is-hidden { display: none; }

.prompt-cat-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding-bottom: 14px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.prompt-cat-ic {
  display: inline-flex; width: 26px; height: 26px; flex: none; color: var(--accent);
  margin-top: 2px;
}
.prompt-cat-ic svg { width: 26px; height: 26px; }
.prompt-cat-name { font-size: 19px; margin: 0 0 4px; letter-spacing: -0.01em; }
.prompt-cat-blurb { margin: 0; color: var(--fg-dim); font-size: 13.5px; max-width: 70ch; }

/* ── needs-input toggle ──────────────────────────────────── */
.prompts-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  margin: 0 0 18px; font-size: 12.5px; color: var(--fg-dim);
}
.prompts-toggle input { accent-color: var(--accent); width: 14px; height: 14px; flex: none; }
.prompts-toggle:hover { color: var(--fg); }

/* ── prompt table (rows) ─────────────────────────────────── */
.prompt-table {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-bottom: 0;
}
.prompt-row {
  display: flex; align-items: center; gap: 16px; width: 100%;
  text-align: left; cursor: pointer; font: inherit;
  background: var(--bg); color: inherit;
  border: 0; border-bottom: 1px solid var(--border);
  padding: 15px 16px;
}
.prompt-row:hover { background: var(--bg-soft); }
.prompt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prompt-row.is-hidden { display: none; }

.prompt-row-main { flex: 1; min-width: 0; }
.prompt-row-title { font-size: 14.5px; margin: 0 0 3px; letter-spacing: -0.01em; }
.prompt-row-summary { margin: 0; color: var(--fg-dim); font-size: 12.5px; line-height: 1.5; }

.prompt-row-meta { flex: none; display: flex; align-items: center; gap: 12px; }

/* Square per-row copy button — grabs the prompt without opening the row. */
.prompt-row-copy {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; cursor: pointer;
  background: var(--bg-soft); color: var(--fg-mute);
  border: 1px solid var(--border); border-radius: 0;
}
.prompt-row-copy:hover { color: var(--fg); border-color: var(--accent); }
.prompt-row-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.prompt-row-copy .ic { width: 15px; height: 15px; }
.prompt-row-copy .ic-check { display: none; }
.prompt-row-copy.is-copied {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent);
}
.prompt-row-copy.is-copied .ic-copy { display: none; }
.prompt-row-copy.is-copied .ic-check { display: inline-flex; }

.prompt-row-chev { display: inline-flex; width: 16px; height: 16px; color: var(--fg-mute); }
.prompt-row-chev svg { width: 16px; height: 16px; }
.prompt-row:hover .prompt-row-chev { color: var(--accent); }

@media (max-width: 620px) {
  .prompt-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .prompt-row-meta { width: 100%; justify-content: space-between; }
}

/* ── indicator flags ─────────────────────────────────────── */
.prompt-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.prompt-flag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.03em;
  text-transform: uppercase; line-height: 1.4; white-space: nowrap;
  padding: 2px 7px; border: 1px solid var(--border); color: var(--fg-dim);
}
.prompt-flag.flag-readonly { color: var(--fg-mute); border-color: var(--border-soft); }
.prompt-flag.flag-needs-input {
  color: var(--accent); border-color: var(--accent-edge); background: var(--accent-soft);
}
.prompt-flag.flag-edits {
  color: #fca5a5; border-color: rgba(248, 113, 113, 0.42);
  background: rgba(248, 113, 113, 0.14);
}
:root[data-theme="light"] .prompt-flag.flag-edits {
  color: #b42318; border-color: rgba(220, 38, 38, 0.38);
  background: rgba(220, 38, 38, 0.09);
}
.prompt-flags-lg .prompt-flag { font-size: 11px; padding: 4px 9px; }

/* ── shared copy button ──────────────────────────────────── */
.prompt-copy {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; cursor: pointer;
  background: var(--bg-soft); color: var(--fg-dim);
  border: 1px solid var(--border); border-radius: 0;
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.prompt-copy:hover { color: var(--fg); border-color: var(--accent); }
.prompt-copy-ic { width: 14px; height: 14px; }
.prompt-copy.is-copied { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.prompt-copy.is-copied .prompt-copy-ic { display: none; }

/* ── shared tag chips (used in the detail view) ──────────── */
.prompt-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.prompt-tag {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-mute);
  border: 1px solid var(--border-soft); padding: 2px 7px; text-transform: lowercase;
  cursor: pointer;
}
.prompt-tag:hover { color: var(--accent); border-color: var(--accent); }

/* ── detail modal ────────────────────────────────────────── */
body.prompt-modal-open { overflow: hidden; }
.prompt-modal { position: fixed; inset: 0; z-index: 100; display: flex; }
.prompt-modal[hidden] { display: none; }
.prompt-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.prompt-modal-dialog {
  position: relative; margin: auto; z-index: 1;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); padding: 24px;
}
@media (min-width: 640px) { .prompt-modal-dialog { padding: 28px 32px; } }

.prompt-modal-head { display: flex; align-items: flex-start; gap: 16px; }
.prompt-modal-heading { flex: 1; min-width: 0; }
.prompt-modal-cat {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
}
.prompt-modal-title { font-size: 21px; margin: 6px 0; letter-spacing: -0.01em; }
.prompt-modal-blurb { margin: 0; color: var(--fg-dim); font-size: 13.5px; }
.prompt-modal-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.prompt-modal-close {
  flex: none; width: 32px; height: 32px; line-height: 1; font-size: 24px;
  background: none; border: 1px solid var(--border); color: var(--fg-mute); cursor: pointer;
}
.prompt-modal-close:hover { color: var(--fg); border-color: var(--accent); }
@media (max-width: 560px) {
  .prompt-modal-head { flex-direction: column; }
  .prompt-modal-actions { width: 100%; justify-content: space-between; }
}

.prompt-flags-lg { margin-top: 16px; }
.prompt-modal-summary { margin: 14px 0 0; color: var(--fg); font-size: 14px; line-height: 1.6; }

.prompt-modal-bodywrap { margin-top: 20px; }
.prompt-modal-bodyhead {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.prompt-modal-bodylabel {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg-mute);
}

/* The prompt text box now uses theme surface tokens, so it inverts properly in
   both dark and light mode (the old fixed --bg-code surface never inverted). */
.prompt-body {
  margin: 0;
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--border);
  padding: 16px 18px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
