/* Can My Agent — plain CSS, no framework, no build step.
   Identity: the prompt text is the product. Treat it like a document you can
   edit in place, on a calm technical ground. Lift only the document and the
   action panel; everything else is a 1px line. */

/* ------------------------------------------------------------------ tokens */

:root {
  /* Light is the product default; dark is opt-in via [data-theme="dark"].
     color-scheme keeps form controls and scrollbars in step with the tokens. */
  color-scheme: light;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1b1d21;
  --muted: #5b6270;
  --line: #dfe3ea;
  --accent: #e8590c;
  --accent-soft: #fff1e8;
  --accent-fg: #ffffff;
  /* Text-on-soft needs more contrast than the button background does, so the
     two are separate tokens. #9a3908 on #fff1e8 is 6.4:1; --accent is 3.5:1. */
  --accent-text: #9a3908;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff6dd;

  --radius: 8px;
  --gutter: 16px;
  --maxw: 72rem;

  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-17: 1.0625rem;
  --fs-22: 1.375rem;
  --fs-30: 1.875rem;
  --fs-40: 2.5rem;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica,
    Arial, sans-serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1115;
  --surface: #171a21;
  --fg: #eceef2;
  --muted: #9aa3b2;
  --line: #262b35;
  --accent: #ff7a2f;
  --accent-soft: #2a1a10;
  --accent-fg: #14100c;
  --accent-text: #ffa46a;
  --ok: #63d69b;
  --ok-soft: #122c20;
  --warn: #f0c874;
  --warn-soft: #2e2410;
}

/* ------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 var(--gutter);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--fs-17);
  font-weight: 400;
  line-height: 1.55;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-size: var(--fs-30);
}
h2 {
  font-size: var(--fs-22);
  font-weight: 600;
}
h3 {
  font-size: var(--fs-17);
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--fg);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  position: static;
  display: inline-block;
  padding: 0.5rem 0.75rem;
}

.eyebrow {
  font-size: var(--fs-13);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.eyebrow-link {
  color: inherit;
}

.lede {
  color: var(--muted);
  font-size: var(--fs-17);
  max-width: 65ch;
}
.fine {
  color: var(--muted);
  font-size: var(--fs-13);
  max-width: 65ch;
}
.tnum {
  font-variant-numeric: tabular-nums;
}
.mono {
  font-family: var(--mono);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

/* ---------------------------------------------------------- header, footer */

.site-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

header.site {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
  margin-bottom: 1rem;
}

/* The toolbar is the homepage's control surface. It sticks to the top of the
   viewport on scroll; the header does not, so top: 0 is correct. */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * var(--gutter));
  padding: 0.625rem var(--gutter);
}
.toolbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Segmented sort control. Links, not buttons: the state is a URL. */
.seg {
  display: flex;
  /* Four nowrap labels are wider than a 360px phone and a flex item cannot
     shrink below its content, so the control scrolls rather than pushing the
     page sideways. Same trick as the category row. */
  flex: 1 1 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.seg::-webkit-scrollbar {
  display: none;
}
.seg-item {
  flex: none;
  padding: 0.4375rem 0.6875rem;
  font-size: var(--fs-13);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-right: 1px solid var(--line);
}
.seg-item:last-child {
  border-right: 0;
}
.seg-item:hover {
  color: var(--fg);
  background: var(--accent-soft);
}
.seg-item.active {
  background: var(--fg);
  color: var(--bg);
  font-weight: 500;
}

.btn-dice {
  min-height: 0;
  padding: 0.375rem 0.75rem;
  font-size: var(--fs-13);
  white-space: nowrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--muted);
}
/* Both glyphs ship in the HTML; CSS picks the right one, so first paint is
   correct with no JavaScript. */
.theme-toggle .icon-moon,
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: inline;
}

.lede-block {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.lede-h1 {
  font-size: var(--fs-30);
  max-width: 24ch;
}
.lede-sub {
  font-family: var(--sans);
  font-size: var(--fs-17);
  color: var(--muted);
  max-width: 65ch;
}
.result-count {
  margin-top: 0.125rem;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--fs-22);
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--fg);
}

.toolbar .search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.625rem;
}
.toolbar .search:focus-within {
  border-color: var(--muted);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.search-icon {
  color: var(--muted);
  flex: none;
}
.toolbar .search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-15);
  padding: 0.5rem 0;
}
.toolbar .search input:focus {
  outline: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-left: auto;
}

.quiet {
  color: var(--muted);
  font-size: var(--fs-15);
  text-decoration: none;
  white-space: nowrap;
}
.quiet:hover {
  color: var(--fg);
  text-decoration: underline;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 3rem;
}

footer.site {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0 2rem;
  color: var(--muted);
  font-size: var(--fs-13);
}
footer.site .site-inner {
  justify-content: space-between;
}
.foot-links {
  display: flex;
  gap: 1rem;
}
footer.site a {
  color: var(--muted);
}

/* ------------------------------------------------------------------- chips */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--fs-13);
  font-weight: 500;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.verified {
  color: var(--ok);
  background: var(--ok-soft);
}
.badge.unverified {
  color: var(--warn);
  background: var(--warn-soft);
}

.cat,
.tag {
  display: inline-block;
  font-size: var(--fs-13);
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  background: var(--surface);
}
.cat:hover {
  color: var(--fg);
  border-color: var(--muted);
}
.cat.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

nav.cats {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.125rem;
}
nav.cats::-webkit-scrollbar {
  display: none;
}
nav.cats .cat {
  flex: none;
}

/* ------------------------------------------------------------------ buttons */

button {
  font: inherit;
  cursor: pointer;
}

/* The UA rule for [hidden] loses to any author `display`, and .btn sets one. */
[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: var(--fs-15);
  font-weight: 500;
  padding: 0.625rem 1rem;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  text-align: center;
}
.btn:hover {
  border-color: var(--muted);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
  width: 100%;
}
.btn-primary:hover {
  border-color: var(--accent);
  filter: brightness(1.06);
}
.btn-secondary {
  width: 100%;
}
.btn-quiet {
  color: var(--muted);
}
.btn-quiet:hover {
  color: var(--fg);
}

/* -------------------------------------------------------------------- list */

.list-head {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.blurb {
  color: var(--muted);
  max-width: 65ch;
}

ul.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

li.row {
  position: relative;
  background: var(--surface);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
li.row:hover {
  background: var(--accent-soft);
}
.row-link {
  text-decoration: none;
}
.row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}
.row-link:hover {
  text-decoration: underline;
}
.row-desc {
  color: var(--muted);
  font-size: var(--fs-15);
}

.excerpt {
  font-family: var(--mono);
  font-size: var(--fs-13);
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.var-chip {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0 0.25rem;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-13);
  color: var(--muted);
  margin-top: 0.125rem;
}
.row-meta a,
.row-meta .who {
  position: relative;
  z-index: 1;
  color: var(--muted);
}
.stat {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
}

/* --------------------------------------------------------- prompt document */

.doc-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.doc {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.doc h1 {
  font-size: var(--fs-30);
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-13);
  color: var(--muted);
}
.doc-meta .who {
  color: var(--muted);
}
.hint {
  color: var(--muted);
}
.doc-note {
  color: var(--muted);
  font-size: var(--fs-13);
  border-left: 2px solid var(--accent);
  padding-left: 0.625rem;
}

.prompt-doc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-family: var(--mono);
  font-size: var(--fs-15);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin-top: 0.25rem;
}

.chip {
  font: inherit;
  font-family: var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-bottom: 1px dashed var(--accent);
  border-radius: 4px;
  padding: 0 0.25rem;
  min-width: 2ch;
  max-width: 100%;
}
.chip:hover {
  border-bottom-style: solid;
}
.chip-input::placeholder {
  color: var(--accent);
  opacity: 0.75;
}
.chip-input.filled {
  color: var(--fg);
  background: var(--accent-soft);
  border-bottom-style: solid;
}
.chip-jump {
  cursor: pointer;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ------------------------------------------------------------------- panel */

.panel {
  min-width: 0;
}
.panel-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.magic {
  color: var(--muted);
  font-size: var(--fs-13);
}
.panel-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.panel-secondary .btn {
  flex: 1 1 auto;
  font-size: var(--fs-13);
  padding: 0.5rem 0.625rem;
  min-height: 38px;
}

.details {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}
.details summary {
  font-size: var(--fs-13);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.details .params {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding-top: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field label {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--muted);
}
.field abbr {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0.125rem;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-15);
}
.field textarea.mono {
  font-family: var(--mono);
  line-height: 1.6;
  resize: vertical;
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.statgrid dt {
  font-size: var(--fs-13);
  color: var(--muted);
}
.statgrid dd {
  margin: 0;
  font-size: var(--fs-22);
  font-family: var(--display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.statgrid .attribution {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--sans);
  font-size: var(--fs-13);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ notices */

.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: var(--fs-15);
  color: var(--muted);
}
.notice.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(32rem, calc(100vw - 2 * var(--gutter)));
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-13);
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.toast.show {
  opacity: 1;
}
.toast:empty {
  display: none;
}

/* ------------------------------------------------------------------ submit */

.narrow {
  max-width: 40rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
form.stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.75rem;
}
.var-preview {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}
.var-preview.show {
  display: flex;
}
.var-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-family: var(--mono);
  font-size: var(--fs-13);
}

/* ------------------------------------------------------------- wider screens */

@media (min-width: 40rem) {
  :root {
    --gutter: 24px;
  }
  .toolbar .search {
    order: 1;
    flex: 1 1 12rem;
    max-width: 26rem;
  }
}

@media (min-width: 56.25rem) {
  ul.rows {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 60rem) {
  .doc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    gap: 2.5rem;
    align-items: start;
  }
  .doc-layout > .notice {
    grid-column: 1 / -1;
  }
  .panel {
    position: sticky;
    top: 1.5rem;
  }
  .panel-card {
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  }
  .doc h1 {
    font-size: var(--fs-40);
  }
}

/* The primary action stays in reach on a phone. One button, one handler. */
@media (max-width: 59.99rem) {
  .doc-layout {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
  .card #copy {
    position: fixed;
    left: var(--gutter);
    right: var(--gutter);
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    width: auto;
    z-index: 15;
    box-shadow: 0 1px 12px rgb(0 0 0 / 0.14);
  }
  .card .toast {
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
