/* Dark is the default (Claude Code's dark theme); light follows the OS
   (Claude Code's light theme). Every color comes from these tokens.
   --accent is for text (>= 4.5:1 on --bg, --panel and a selected row);
   --accent-line is the brand orange for borders and outlines.
   --sel-bg / --accent-sel: the selected menu row's background and name,
   >= 4.5:1 for the name and --dim text over --panel (tested). The home
   list's hover row reuses them over --bg (tested too). */
:root {
  color-scheme: dark;
  --bg: #1a1918;
  --panel: #262624;
  --fg: #e8e6e1;
  --dim: #9c9a93;
  --accent: #d97757;
  --accent-line: #d97757;
  --accent-soft: rgba(217, 119, 87, 0.16);
  --sel-bg: rgba(217, 119, 87, 0.10);
  --accent-sel: #e08a6c;
  --border: #3d3c38;
  --hover: rgba(255, 255, 255, 0.04);
  --shadow: rgba(0, 0, 0, 0.45);
  --code-bg: #111110;
  --band: #1a1918; /* opaque strip behind the mobile corner links (D26) */
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #faf9f5;
    --panel: #f0eee6;
    --fg: #1f1e1d;
    --dim: #5e5d59;
    --accent: #a3462a;
    --accent-line: #c96442;
    --accent-soft: rgba(217, 119, 87, 0.10);
    --sel-bg: rgba(217, 119, 87, 0.10);
    --accent-sel: #a3462a;
    --border: #d3d0c5;
    --hover: rgba(31, 30, 29, 0.05);
    --shadow: rgba(31, 30, 29, 0.14);
    --code-bg: #f0eee6;
    --band: #faf9f5;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, .menu li:focus-visible, .tx-tool summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.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;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 32px 16px 48px; }

.dim { color: var(--dim); }
kbd {
  font-family: inherit; color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px;
}

/* terminal */
.term {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: text;
}
.term p { margin: 0 0 4px; }

.welcome {
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.welcome p { margin: 0 0 4px; }
.welcome-title { margin-bottom: 8px !important; }
.welcome-title strong { font-weight: 700; }
.spark { color: var(--accent); }

.prompt-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 42px;
}
.prompt-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
.caret-sign { color: var(--dim); }
.prompt-box:focus-within .caret-sign { color: var(--fg); }
.line { white-space: pre; overflow: hidden; }
.hint { color: var(--dim); margin-left: 2px; }

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  vertical-align: text-bottom;
  background: var(--fg);
  animation: blink 1.06s steps(1) infinite;
}
.prompt-box:not(:focus-within) .cursor { background: transparent; box-shadow: inset 0 0 0 1px var(--dim); animation: none; }
@keyframes blink { 50% { opacity: 0; } }

/* Hidden but focusable; font-size >=16px stops iOS zoom. */
.cmd {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  cursor: text;
}

/* dropdown: ~8 rows visible (--row each), the rest scrolls */
.menu {
  --row: 30px;
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: calc(8 * var(--row) + 10px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu li[role="option"] {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--row);
  padding: 2px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.menu li .nm { flex: 0 0 auto; min-width: 11em; white-space: nowrap; }
.menu li .kd { flex: 0 0 3.6em; color: var(--dim); font-size: 0.78em; }
.menu li .ds { flex: 1 1 auto; min-width: 0; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu li[role="option"]:hover { background: var(--hover); }
.menu li[aria-selected="true"], .menu li[aria-selected="true"]:hover { background: var(--sel-bg); }
.menu li[aria-selected="true"] .nm { color: var(--accent-sel); }
.menu .note { padding: 6px 12px; color: var(--fg); overflow-wrap: anywhere; }
.menu .note + li[role="option"] { margin-top: 2px; }

/* home: Claude Code style screen, output scrolls above a prompt pinned to the bottom */
.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.feed {
  flex: 1 0 auto;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 24px;
}
.dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--bg);
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(8px + env(safe-area-inset-bottom, 0px));
}
.dock-in { position: relative; max-width: 828px; margin: 0 auto; }
/* Tabbing through the list never parks a link behind the pinned prompt.
   (Not scroll-padding on html: that would scroll the page on every keystroke.) */
.feed a { scroll-margin-bottom: 140px; }
.dock .menu {
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  margin: 0 0 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  max-height: min(calc(8 * var(--row) + 10px), 55vh);
  max-height: min(calc(8 * var(--row) + 10px), 55dvh);
  box-shadow: 0 -8px 24px var(--shadow);
}
.dock .keys { margin: 6px 0 0; font-size: 0.8rem; }
.dock .keys kbd { border: 0; padding: 0; color: var(--dim); }
.bullet { color: var(--accent); font-size: 0.8em; vertical-align: 1px; }

/* GitHub link */
.gh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--dim);
}
.gh:hover { color: var(--fg); background: var(--accent-soft); }
.gh-fixed {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  background: var(--bg);
  border: 1px solid var(--border);
}
.page-home .feed { padding-top: 84px; }

/* avatar link to the main site (top left, mirrors .gh-fixed) */
.me {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--dim);
  font-size: 0.62rem;
  line-height: 1.2;
  border-radius: 8px;
}
.me img { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); display: block; }
.me:hover, .me:focus-visible { color: var(--fg); }
.me:hover img, .me:focus-visible img { border-color: var(--accent-line); box-shadow: 0 0 10px var(--accent-soft), 0 0 3px var(--accent-line); }
.me-fixed { position: fixed; top: 8px; left: 12px; z-index: 20; }
body:not(.page-home):not(.detail) .wrap { padding-top: 84px; }

/* catalog */
.catalog { margin-top: 28px; }
.catalog-title { font-size: 1rem; margin: 0; }
.count { color: var(--dim); margin: 2px 0 20px; }
.group h2 { font-size: 0.95rem; color: var(--accent); margin: 20px 0 6px; text-transform: lowercase; }
.group .n { color: var(--dim); font-weight: 400; }
.skill-list { list-style: none; margin: 0; padding: 0; }
.skill-list a {
  display: flex;
  gap: 16px;
  padding: 6px 8px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}
.skill-list a:hover { background: var(--sel-bg); }
.skill-list a:hover .nm { color: var(--accent-sel); }
.skill-list .nm { flex: 0 0 11em; color: var(--accent); }
.skill-list .ds {
  color: var(--dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.foot { margin-top: 40px; font-size: 0.85rem; }

/* detail page */
.echo-line { color: var(--dim); }
.detail-name { font-size: 1.3rem; margin: 12px 0 8px; overflow-wrap: anywhere; }
.tag {
  font-size: 0.75rem; font-weight: 400; color: var(--accent);
  border: 1px solid var(--accent-line); border-radius: 4px; padding: 0 6px; vertical-align: middle;
}
.detail-desc { margin: 0 0 16px !important; }

/* sticky prompt bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
}
.home { flex: 0 0 auto; text-decoration: none; color: var(--dim); }
.home:hover { color: var(--accent); }
.prompt-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
.topbar .prompt-box { min-height: 36px; padding: 5px 10px; }
.topbar .menu {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  max-height: min(calc(8 * var(--row) + 10px), 60vh);
  box-shadow: 0 8px 24px var(--shadow);
}

.out { min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-line);
  border-radius: 8px;
  padding: 4px 16px 14px;
  margin: 8px 0 24px;
}
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 0.85rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip .k { color: var(--dim); }
.chip-tested { border-color: var(--accent-line); }

.sec { margin: 0 0 28px; min-width: 0; line-height: 1.7; }
.sec h2 {
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}
.sec h2::before { content: "## "; color: var(--dim); }
.sec h3, .sec h4, .sec h5, .sec h6 { font-size: 0.95rem; margin: 16px 0 6px; }
.sec p { margin: 0 0 14px; overflow-wrap: anywhere; }
.sec ul, .sec ol { margin: 0 0 14px; padding-left: 1.6em; }
.sec li { margin: 8px 0; overflow-wrap: anywhere; }
.sec li > ul, .sec li > ol { margin: 10px 0; }
.sec code {
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 0 3px;
  font-size: 0.92em;
}
/* code inside a link: the link color on --accent-soft misses 4.5:1, so no chip */
.sec a code { background: none; padding: 0; }
.sec pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 12px;
  overflow-x: auto;
  max-width: 100%;
}
.sec pre code { background: none; padding: 0; font-size: 0.9em; overflow-wrap: normal; }
.sec blockquote {
  margin: 0 0 12px;
  padding: 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--dim);
}
.table-wrap { overflow-x: auto; max-width: 100%; margin: 0 0 12px; }
.table-wrap table { border-collapse: collapse; font-size: 0.9em; }
.table-wrap th, .table-wrap td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}
.table-wrap td { overflow-wrap: normal; }
.table-wrap th { color: var(--accent); }
.sec hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* Flow diagram: inline SVG from a ```mermaid fence (scripts/flow_svg.py).
   Drawn at its natural size; a graph wider than the column scrolls inside
   .flow, never the page. Colours only from tokens (tested contrast:
   text >= 4.5:1, lines and borders >= 3:1 on --bg / --panel). */
.flow { overflow-x: auto; max-width: 100%; margin: 0 0 12px; }
.flow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.flow-svg { display: block; max-width: none; height: auto; }
.flow-svg text { font-family: var(--mono); font-size: 13px; }
.flow-node rect { fill: var(--panel); stroke: var(--accent-line); stroke-width: 1.5; }
.flow-label { fill: var(--fg); }
.flow-edge path { fill: none; stroke: var(--dim); stroke-width: 1.5; }
.flow-edge polygon { fill: var(--dim); stroke: none; }
.flow-dotted path { stroke-dasharray: 5 4; }
.flow-elabel rect { fill: var(--bg); stroke: none; }
.flow-etext { fill: var(--dim); }

/* Example transcript: the home terminal's chrome; "> prompt", then
   "⏺" replies and collapsed "⏺ Tool(args)" calls with a "⎿" result. */
.tx {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 12px;
  min-width: 0;
}
.tx > * + * { margin-top: 10px; }
.tx-prompt, .tx-reply, .tx-tool summary, .tx-res { display: flex; gap: 8px; min-width: 0; }
.tx-text { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.tx-md .tx-text { white-space: normal; }
.tx-md .tx-text > :last-child { margin-bottom: 0; }
.tx-gt { color: var(--dim); }
.tx-prompt .tx-text { color: var(--fg); }
.tx-dot { flex: 0 0 auto; color: var(--fg); }
.tx-tool .tx-dot { color: var(--accent); }
.tx-tool summary { cursor: pointer; list-style: none; overflow-wrap: anywhere; }
.tx-tool summary::-webkit-details-marker { display: none; }
.tx-name { font-weight: 700; }
.tx-more { color: var(--dim); }
.tx-tool[open] .tx-more { display: none; }
.tx-res { margin: 4px 0 0 1.4em; color: var(--dim); }
.tx-line { color: var(--dim); white-space: pre-wrap; }

/* sample workflows: /workflows page + each detail page's section */
.wf-links { list-style: none; padding-left: 0 !important; }
.wf-links li { margin: 0 0 10px; }
.wf-chain { font-size: 0.85em; }
.wf-toc ul { columns: 2 16em; column-gap: 24px; }
.wf-steps li { margin: 0 0 10px; }
.wf-who { font-weight: 700; }
.wf-you { color: var(--fg); font-weight: 700; border: 1px dashed var(--dim); border-radius: 4px; padding: 0 6px; }
.wf-why { display: block; }
.wf-human .wf-why { color: var(--dim); }

/* skills map: /map page (site_map.py); graphs reuse .flow above */
.map-group h2 .n { color: var(--dim); font-weight: 400; }
.map-list { list-style: none; padding-left: 0 !important; }
.map-list > li { margin: 0 0 12px; }
.map-list > li > a { font-weight: 700; }
.map-list > li > .dim { display: block; }
.map-out { font-size: 0.85em; margin: 2px 0 0 !important; }

/* detail page: back to the list (Esc on a bare prompt goes there too) */
.back { display: inline-block; margin: 4px 0 0; text-decoration: none; }
.back:hover { text-decoration: underline; }

.pn {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.pn a { text-decoration: none; overflow-wrap: anywhere; }
.pn .next { margin-left: auto; text-align: right; }
.comments {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.comments-h { margin: 0 0 12px; font-size: 1em; color: var(--accent); }

@media (max-width: 600px) {
  html, body { font-size: 14px; }
  .skill-list a { flex-direction: column; gap: 0; }
  .skill-list .nm { flex-basis: auto; }
  .topbar { padding: 8px 10px; }
  .page-home .feed { padding-top: 80px; }
  .dock .keys { display: none; }
  .topbar-in { padding: 4px 6px; gap: 8px; position: relative; }
  /* the narrow prompt can't hold the dropdown: span the whole bar instead */
  .topbar .prompt-wrap { position: static; }
  .topbar .menu { top: calc(100% + 4px); }
  .home { font-size: 0.85rem; }
  .me-fixed { left: 10px; }
  /* opaque strip behind the fixed corner links: feed text scrolls under it, never beside them */
  body:not(.detail)::before {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 66px;
    background: var(--band);
    border-bottom: 1px solid var(--border);
    z-index: 15;
  }
  body:not(.detail) .wrap { padding-top: 80px; }
  /* two lines per option (name + kind, then a one-line summary), >=44px tap target */
  .menu { --row: 48px; }
  .menu li[role="option"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 8px;
    align-content: center;
    padding: 3px 10px;
  }
  .menu li .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .menu li .kd { text-align: right; }
  .menu li .ds { grid-column: 1 / -1; font-size: 0.9em; }
}

/* intro: only when the inline head script adds html.intro (JS on, motion ok).
   Every keyframe ends at the normal state, so content never stays hidden. */
.intro .welcome { animation: draw-in 0.55s cubic-bezier(.2, .7, .2, 1) both; }
.intro .welcome p { animation: fade-in 0.35s ease-out 0.3s both; }
.intro .spark { display: inline-block; animation: pulse 1.1s ease-in-out 0.1s both; }
.intro .catalog, .intro .foot { animation: rise-in 0.45s ease-out 0.55s both; }
.intro .dock { animation: fade-in 0.4s ease-out 0.35s both; }
.intro .me-fixed, .intro .gh-fixed { animation: fade-in 0.4s ease-out 0.7s both; }
@keyframes draw-in {
  from { clip-path: inset(0 100% 0 0 round 8px); }
  to { clip-path: inset(0 0 0 0 round 8px); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { transform: scale(0.4) rotate(-90deg); opacity: 0; }
  35% { transform: scale(1.35) rotate(0deg); opacity: 1; }
  60% { transform: scale(0.9); }
  80% { transform: scale(1.12); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .intro *, .intro *::before { animation: none !important; }
}
