/* Intrapid portal. Mobile first; the desktop layout starts at 820px. */

:root {
  /* One token per color, with a light and a dark value. The page follows
     the device unless the person picked a scheme on the Account page, which
     sets data-theme on this element. */
  color-scheme: light dark;
  --bg: light-dark(#f6f6f7, #0e0f12);
  --surface: light-dark(#ffffff, #17181d);
  --surface-2: light-dark(#f1f1f3, #1f2027);
  --text: light-dark(#17171c, #ececf1);
  --muted: light-dark(#6b6b76, #9a9aa6);
  --line: light-dark(#e6e6ea, #2a2b33);
  /* The border of a field. It holds 3:1 on every surface a field sits on. */
  --field-line: light-dark(#85858f, #70717e);
  --accent: light-dark(#4356e4, #7ea4ff);
  --accent-text: light-dark(#ffffff, #0e0f12);
  --accent-soft: light-dark(#e9edff, #1b2a4e);
  --ok: light-dark(#15803d, #4ade80);
  --ok-soft: light-dark(#e9f8ee, #12261a);
  --warn: light-dark(#a15c07, #fbbf24);
  --warn-soft: light-dark(#fff6e5, #2b2110);
  --danger: light-dark(#c02626, #f87171);
  --danger-soft: light-dark(#fdeeee, #2c1414);
  --go: light-dark(#c2410c, #fb923c);
  --go-text: light-dark(#ffffff, #1a0f05);
  --info: light-dark(#1d4ed8, #93b4ff);
  --info-soft: light-dark(#ecf2ff, #172038);
  --pane-bg: light-dark(#111216, #08090b);
  --pane-text: light-dark(#dfe1e6, #d7d9de);
  --shadow-near: light-dark(rgb(16 16 24 / 5%), rgb(0 0 0 / 40%));
  --shadow-far: light-dark(rgb(16 16 24 / 5%), transparent);
  --shadow: 0 1px 2px var(--shadow-near), 0 4px 16px var(--shadow-far);
  /* Two small sizes. xs: pills, tab labels, section and h4 labels, the
     stepper. sm: meta lines, hints, help, notices, facts. */
  --fs-xs: 0.78rem;
  --fs-sm: 0.875rem;
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* Side insets of a phone held sideways, kept clear of the content. */
  --edge-left: max(1rem, env(safe-area-inset-left, 0px));
  --edge-right: max(1rem, env(safe-area-inset-right, 0px));
  /* The action bar's height. The script measures it; this is the guess
     until it does. */
  --actionbar-h: 0px;
}
:root:has(.actionbar) { --actionbar-h: 76px; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Focus and anchors stop clear of the sticky top bar and the bottom bars. */
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 4.5rem);
  scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--actionbar-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--actionbar-h));
}

a { color: var(--accent); text-decoration: none; }
/* Typography. One family, a short scale. Headings sit tight, with the
   tracking pulled in as they grow. Labels are small spaced-out capitals.
   Numbers line up in columns wherever they are compared. Paragraphs avoid
   a single word on their last line. */
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
/* A heading that starts with an icon centers the icon on its text. */
h1:has(> .icon), h2:has(> .icon), h3:has(> .icon) { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
h4 { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1rem 0 0.35rem; }
p { margin: 0; text-wrap: pretty; }
li { text-wrap: pretty; }
.meta, .hint, .help, time, .pill, .chip b, .kv, .facts, .commits, .timeline, .people { font-variant-numeric: tabular-nums; }
code, pre, .path { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.84em; font-variant-ligatures: none; font-feature-settings: "zero"; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* The skip link shows only when it has focus. Main takes focus from it
   without a ring. */
.skip { position: absolute; z-index: 40; left: var(--edge-left); top: -4rem; padding: 0.6rem 1rem; border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font-weight: 650; box-shadow: var(--shadow); }
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 0.5rem); }
#main:focus { outline: none; }

.icon { width: 18px; height: 18px; flex: none; }
.icon.big { width: 40px; height: 40px; color: var(--muted); }

/* --- layout ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.6rem var(--edge-right) 0.6rem var(--edge-left);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--text); font-weight: 700; font-size: 1.05rem; }
/* The wordmark. A rounded face, heavy and friendly. The last i is dotless
   and wears the plane's red dot. Hovering the brand nudges the plane
   forward. */
.wordmark { display: inline-block; font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif; font-weight: 800; font-size: 1.4rem; letter-spacing: -0.02em; line-height: 1; }
.wordmark b { position: relative; font-weight: inherit; }
.wordmark b::after { content: ""; position: absolute; left: 50%; top: 0.2em; width: 0.19em; height: 0.19em; border-radius: 50%; background: #e8323f; transform: translateX(-50%); }
.brand-mark { flex: none; color: var(--text); transition: transform 0.2s ease; }
.topnav { display: none; margin-left: auto; align-items: center; gap: 0.25rem; }
.topnav a:not(.button) { color: var(--muted); padding: 0.45rem 0.75rem; border-radius: 999px; font-weight: 550; font-size: 0.95rem; }
.topnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.worker-dot { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-sm); color: var(--muted); padding: 0.3rem 0.6rem; border-radius: 999px; background: var(--surface-2); }
.worker-dot em { font-style: normal; }
.worker-dot span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.worker-dot.on span { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.worker-dot.off span { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

.page { max-width: 980px; margin: 0 auto; padding: 1rem var(--edge-right) 2rem var(--edge-left); }
.page-head { margin: 0.5rem 0 1rem; }
.section .page-head { margin: 0 0 0.75rem; }
.page-head .sub { color: var(--muted); margin-top: 0.3rem; font-size: 1.02rem; }
.page-head .notice { margin: 0.75rem 0 0; }
.section { margin-top: 2rem; }

.back { display: inline-flex; align-items: center; gap: 0.2rem; color: var(--muted); font-weight: 550; margin: 0.25rem 0 0.5rem -0.2rem; padding: 0.3rem 0; }

/* --- bottom tab bar (phones) -------------------------------------------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 max(0.5rem, env(safe-area-inset-right, 0px)) var(--safe-bottom) max(0.5rem, env(safe-area-inset-left, 0px));
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { position: relative; align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; padding: 0.4rem 0; }
.tabbar a .icon { width: 22px; height: 22px; }
/* The current tab: accent color, a bar along its top, and a heavier label,
   so it differs by more than hue. */
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

.fab {
  position: fixed;
  right: var(--edge-right);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 1rem);
  z-index: 26;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
}
.fab .icon { width: 26px; height: 26px; }
.fab:active { transform: scale(0.96); }
/* The last row of a page clears the + button. */
body:has(> .fab) { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 56px + 1rem); }

/* --- sticky action bar (idea page) -------------------------------------- */

.actionbar {
  position: fixed;
  inset: auto 0 calc(var(--tabbar-h) + var(--safe-bottom)) 0;
  z-index: 25;
  padding: 0.65rem var(--edge-right) 0.65rem var(--edge-left);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.actionbar-inner { max-width: 980px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 0.6rem; }
/* Each action needs room for its label. When the row cannot give it, the row
   wraps and the last action, the primary one, takes the next line. */
.actionbar form { flex: 1 1 8rem; display: flex; min-width: 0; }
.actionbar-note { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0; padding: 0.3rem 0; flex: 1 1 100%; order: -1; min-width: 0; }
.actionbar-note .icon { flex: none; margin-top: 0.15rem; }
.actionbar form:last-child:not(:first-child) { flex-grow: 1.5; }
.actionbar .button { flex: 1; min-width: 0; padding: 0.5rem 0.75rem; white-space: normal; line-height: 1.2; }
/* With three actions on a phone, the labels need the room the icons take. */
.actionbar:has(form:nth-of-type(3)) .button .icon { display: none; }

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 46px;
  padding: 0 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.06s ease, opacity 0.15s ease, background 0.15s ease;
}
.button:active { transform: scale(0.98); }
.button.secondary { background: var(--accent-soft); color: var(--accent); }
.button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
/* The one action that sets a build going. */
.button.go { background: var(--go); color: var(--go-text); }
.button.ghost.danger { color: var(--danger); }
.button.small { min-height: 36px; padding: 0 0.8rem; font-size: 0.9rem; border-radius: 10px; }
/* Busy: the pressed control dims and shows a ring. The ring turns a few
   times and holds still when motion is reduced. A link whose page is loading
   is busy too; a tab bar link only dims, to keep its icon over its label. */
.button[aria-busy="true"], .menu-item[aria-busy="true"], .link[aria-busy="true"], .segments button[aria-busy="true"], .brand[aria-busy="true"], .back[aria-busy="true"], .topnav a[aria-busy="true"], .tabbar a[aria-busy="true"] { opacity: 0.6; pointer-events: none; }
.button[aria-busy="true"]::after, .menu-item[aria-busy="true"]::after, .link[aria-busy="true"]::after, .segments button[aria-busy="true"]::after,
.brand[aria-busy="true"]::after, .back[aria-busy="true"]::after, .topnav a:not(.button)[aria-busy="true"]::after {
  content: ""; display: inline-block; flex: none; width: 0.9em; height: 0.9em; margin-left: 0.35em; vertical-align: -0.1em;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear 12;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
/* A copy button swaps its icon for a check once it has copied. */
.icon-button .done { display: none; }
.icon-button.copied { color: var(--ok); }
.icon-button.copied .done { display: block; }
.icon-button.copied .icon:not(.done) { display: none; }
.link { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.link .icon { width: 15px; height: 15px; }

/* --- cards and lists ---------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
}
.nowrap { white-space: nowrap; }
/* A page that is one card, such as a preview, uses the card title as its h1. */
.card-head h1 { font-size: 1.4rem; letter-spacing: -0.02em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.cards > .card { margin: 0; }
.row { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
/* Inside a card, the title row and what follows it keep one gap, and a
   copy box keeps a smaller one before the line that explains it. */
.card > .row:first-child { margin-bottom: 0.6rem; }
.card > .row:first-child + .path { margin-top: 0; }
.copyline + .meta, .copyline + .help { margin-top: 0.45rem; }
.row.meta { justify-content: flex-start; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: var(--fs-sm); }
.hint { color: var(--muted); font-size: var(--fs-sm); margin-top: 0.35rem; }
.help { color: var(--muted); font-size: var(--fs-sm); margin-top: 0.35rem; }
.help a:not(.button) { text-decoration: underline; }
/* What follows a help line stands apart from it. */
.help + p, .help + table, .help + ul, .help + form, .help + .copyline, .help + .button { margin-top: 0.85rem; }
.prose + .meta { margin-top: 0.6rem; }
.help.strong { color: var(--warn); font-weight: 600; }
.hint.strong { color: var(--warn); font-weight: 600; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.ok-text { color: var(--ok); }

.idea-card a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; color: var(--text); box-shadow: var(--shadow); transition: border-color 0.15s ease, transform 0.06s ease; }
.idea-card a:active { transform: scale(0.995); background: var(--surface-2); }
.idea-card h3 { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.008em; overflow-wrap: anywhere; }
.idea-card .row.meta { margin-top: 0.45rem; gap: 0.4rem; }
.idea-card .chev { color: var(--muted); }
/* A closed idea: a flat, compact row. */
.idea-card.compact a { padding: 0.6rem 1rem; box-shadow: none; background: transparent; }
.idea-card.compact h3 { font-size: 0.95rem; font-weight: 550; }
.idea-card.compact .row.meta { margin-top: 0.25rem; }

/* Running: card titles are h3 under the section h2s, and a linked title
   looks like a link. */
.session-card h3 a, .server-row h3 a { font-weight: 650; }
.section.first { margin-top: 0; }
.stopped-sessions > .cards { margin-top: 0.75rem; }
.path { color: var(--muted); margin-top: 0.35rem; overflow-wrap: anywhere; }

.chips { display: flex; gap: 0.45rem; overflow-x: auto; padding: 0.1rem 0 0.8rem; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 0.45rem 0.85rem; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; min-height: 38px; }
.chip b { color: var(--muted); font-weight: 600; margin-left: 0.2rem; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] b { color: inherit; opacity: 0.7; }

/* The ideas page toolbar: status chips on the left, the source toggle on the right. */
.list-tools { display: flex; align-items: flex-start; column-gap: 0.75rem; }
.list-tools .chips { flex: 1 1 auto; min-width: 0; }
.source-toggle { flex: none; margin: 0 0 0.8rem auto; display: flex; align-items: center; gap: 0.5rem; }
.source-toggle > span { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.segments { display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.segments button { flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--fs-sm); font-weight: 600; padding: 0 0.85rem; border-radius: 999px; cursor: pointer; min-height: 32px; }
.segments button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.list-tools button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-picker { width: max-content; max-width: 100%; }
.theme-picker button { min-height: 38px; padding: 0 1.1rem; }

/* Phones: the source toggle takes its own row above the chips. The chips fade
   at the right edge while the row can scroll further. */
@media (max-width: 819px) {
  .list-tools { flex-direction: column; align-items: stretch; }
  .source-toggle { order: -1; margin: 0 0 0.6rem; }
  .segments { flex: 1; }
  .segments button { min-height: 40px; }
  .list-tools .chips[data-more] { mask-image: linear-gradient(to right, #000 85%, transparent); }
}

/* One section per group on the ideas page. */
.stage:not([hidden]) ~ .stage { margin-top: 1.5rem; }
.stage-head { display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0 0.6rem; }
.stage-head h2 { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-wrap: nowrap; }
.stage-head h2 b { font-weight: 600; margin-left: 0.2rem; }
.stage-head p { color: var(--muted); font-size: var(--fs-sm); }
.empty[data-empty] { display: grid; justify-items: center; gap: 0.8rem; }
.empty[data-empty][hidden] { display: none; }

/* --- pills -------------------------------------------------------------- */

.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* One meaning per color. Accent: work in progress. Green: a good outcome.
   Amber: waits on the person. Red: a problem. Gray: idle, queued, or ended.
   A progress dot pulses three times, then rests. */
.s-draft { background: var(--surface-2); color: var(--muted); }
.s-distilled, .s-review, .s-waiting { background: var(--warn-soft); color: var(--warn); }
/* Queued: gray with a ring for a dot. */
.s-ready, .s-requested { background: var(--surface-2); color: var(--muted); }
.s-ready::before, .s-requested::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.s-distilling, .s-building, .s-live { background: var(--accent-soft); color: var(--accent); }
.s-distilling::before, .s-building::before, .s-live::before { animation: pulse 1.2s ease-in-out 3; }
.s-done { background: var(--ok-soft); color: var(--ok); }
.s-failed { background: var(--danger-soft); color: var(--danger); }
.s-current { background: var(--info-soft); color: var(--info); }
.s-dropped { background: var(--surface-2); color: var(--muted); }
@keyframes pulse { 50% { opacity: 0.25; } }

/* --- notices and toasts ------------------------------------------------- */

.notice, .toast { display: flex; gap: 0.7rem; align-items: flex-start; border-radius: var(--radius-sm); padding: 0.8rem 0.9rem; margin-bottom: 0.9rem; background: var(--info-soft); color: var(--info); font-size: var(--fs-sm); }
.toast .icon { margin-top: 0.15rem; }
.toast > p { flex: 1; }
.toast .icon-button { margin: -0.45rem -0.5rem -0.45rem 0; color: inherit; }
.toast .icon-button .icon { margin: 0; }
/* A notice's icon floats beside its first line only. Later lines and
   paragraphs start at the notice's edge instead of in a column past it. */
.notice { display: block; }
.notice > .icon { float: left; margin: 0.15rem 0.7rem 0 0; }
.notice p + p { margin-top: 0.2rem; }
.notice > div, .toast > div, .notice p, .toast p { min-width: 0; overflow-wrap: anywhere; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice code { background: transparent; color: inherit; }
/* A copy box inside a notice keeps its gray fill but hugs the text. */
.notice .copyline { margin-top: 0.5rem; padding: 0 0.1rem 0 0.5rem; }
.notice .copyline code, .notice .copyline a { padding: 0.2rem 0; }
.notice .icon-button { width: 30px; height: 30px; }
.notice a, .toast a { color: inherit; text-decoration: underline; font-weight: 600; }
.toast.error { background: var(--danger-soft); color: var(--danger); }
.toast.ok { background: var(--ok-soft); color: var(--ok); }
/* "This idea changed" floats above the bottom bars, where the eye is. */
.changed .toast { position: fixed; z-index: 27; left: 1rem; right: 1rem; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--actionbar-h) + 0.75rem); max-width: 30rem; margin: 0 auto; box-shadow: var(--shadow); }
.toast { animation: drop 0.25s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

/* --- idea page ---------------------------------------------------------- */

.idea-head { margin-bottom: 1rem; }
.idea-head h1 { margin: 0.5rem 0 0.9rem; overflow-wrap: anywhere; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.stepper li { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.stepper .bar { height: 4px; border-radius: 4px; background: var(--line); }
.stepper li.done .bar, .stepper li.current .bar { background: var(--accent); }
.stepper li.current, .stepper li.done { color: var(--text); }
.stepper li.current { font-weight: 700; }
/* Narrow phones: only the current step keeps a visible label. The others
   stay for screen readers. */
@media (max-width: 479px) {
  .stepper li:not(.current) .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stepper li.current { overflow: visible; white-space: nowrap; }
}

.brief h3 { font-size: 1.15rem; }
/* A brief part reads as a small label at either heading level. */
.brief .part { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1rem 0 0.35rem; }
.kv.branch-kept { margin-top: 0.75rem; }
.brief .meta { margin-top: 0.2rem; }
.list { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; }
.inline-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

.pane { margin: 0 0 0.9rem; background: var(--pane-bg); color: var(--pane-text); border-radius: var(--radius-sm); padding: 0.8rem; height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-xs); line-height: 1.4; overscroll-behavior: contain; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.75rem; align-items: center; font-size: var(--fs-sm); }
.kv > span { color: var(--muted); }
.copyline { display: flex; align-items: center; gap: 0.25rem; background: var(--surface-2); border-radius: 9px; padding: 0 0.15rem 0 0.6rem; min-width: 0; }
.copyline code { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; padding: 0.45rem 0; }
.copyline code::-webkit-scrollbar { display: none; }
.copyline a { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 0.45rem 0; }

.disclosure { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.disclosure.flush { margin: 0; border: 0; padding: 0; }
/* A whole card that folds, such as a stopped session in review. */
.card.disclosure { margin-top: 0; border-top: 1px solid var(--line); padding-top: 1rem; }
.card.disclosure > summary { gap: 0.6rem; }
.disclosure > summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 0.5rem; min-height: 32px; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s ease; }
.disclosure[open] > summary::after { transform: rotate(-135deg); }
.disclosure > *:not(summary) { margin-top: 0.75rem; }
.version { border-top: 1px dashed var(--line); padding-top: 0.75rem; }
.version:first-of-type { border-top: 0; padding-top: 0; }
.version h3 { margin: 0.3rem 0; font-size: 1rem; }

.decisions { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.decisions li { border-left: 3px solid var(--accent-soft); padding-left: 0.75rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; font-size: var(--fs-sm); }
.timeline li { display: grid; gap: 0.1rem; }
.danger-zone { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

.comments { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.8rem; }
.comment { border-left: 3px solid var(--warn-soft); padding-left: 0.75rem; display: grid; gap: 0.25rem; }
.comment.resolved { border-left-color: var(--ok-soft); }
.comment.resolved > .prose { color: var(--muted); }
.comment .row.meta { gap: 0.35rem; }
.comment-close .link { background: none; border: 0; padding: 0.2rem 0; cursor: pointer; font: inherit; font-size: var(--fs-sm); color: var(--muted); }
.comment-form { margin-top: 0.5rem; }
.comment-form .form-actions { margin-top: 0.6rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- forms -------------------------------------------------------------- */

.form h2 { margin-bottom: 0.25rem; }
/* A page that is one card form, such as sign in, keeps its h1 small. */
.form.card h1 { font-size: 1.4rem; letter-spacing: -0.02em; }
.auth-card { max-width: 26rem; margin: 1rem auto; }
.field { display: grid; gap: 0.35rem; margin-top: 1rem; }
.field label, .field > .label { font-weight: 650; font-size: 0.92rem; }
/* The Details group of a form: its summary names the choices inside. */
.form .disclosure { margin-top: 1.25rem; }
.details-summary { font-weight: 400; min-width: 0; overflow-wrap: anywhere; }
/* A visible label above a field that sits outside a .field block. */
.field-label { display: block; font-weight: 650; font-size: 0.92rem; margin: 0.75rem 0 0.35rem; }
.setting-actions .field-label { flex: 1 1 100%; margin: 0; }
input, textarea, select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming into fields */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  min-height: 48px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; line-height: 1.45; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; }
.form-actions .button { flex: 1; }
.split { display: grid; gap: 0.9rem; margin-top: 1.25rem; }
.split .card { margin: 0; }

pre.config { margin: 0.5rem 0 0; padding: 0.6rem 0.75rem; border-radius: 9px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.tokens .meta { display: block; margin-top: 0.1rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.9rem; margin: 0.75rem 0 0; font-size: var(--fs-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* --- empty states ------------------------------------------------------- */

.empty-state { text-align: center; padding: 3rem 1rem; display: grid; justify-items: center; gap: 0.6rem; }
.empty-state.small { padding: 1.5rem 1rem; }
.empty-state p { color: var(--muted); max-width: 32ch; }
.empty-state .button { margin-top: 0.5rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }

/* --- desktop ------------------------------------------------------------ */

@media (min-width: 820px) {
  html { scroll-padding-bottom: calc(var(--actionbar-h) + 1rem); }
  body, body:has(> .fab) { padding-bottom: var(--actionbar-h); }
  .tabbar, .fab { display: none; }
  .topnav { display: flex; }
  .worker-dot { margin-left: 0.5rem; }
  /* The bar's content lines up with the page column, actions at its end. */
  .actionbar { inset: auto 0 0 0; padding-left: 0; padding-right: 0; }
  .actionbar-inner { justify-content: flex-end; padding: 0 max(1.5rem, env(safe-area-inset-right, 0px)) 0 max(1.5rem, env(safe-area-inset-left, 0px)); }
  .actionbar form, .actionbar .button { flex: none; }
  .actionbar form:last-child:not(:first-child) { flex-grow: 0; }
  .actionbar .button { white-space: nowrap; padding: 0 1.1rem; }
  .actionbar:has(form:nth-of-type(3)) .button .icon { display: inline; }
  .actionbar-inner { flex-wrap: nowrap; align-items: center; }
  .actionbar-note { flex: 0 1 auto; order: 0; margin-right: auto; }
  .page { padding: 1.5rem max(1.5rem, env(safe-area-inset-right, 0px)) 3rem max(1.5rem, env(safe-area-inset-left, 0px)); }
  h1 { font-size: 2.1rem; letter-spacing: -0.03em; }
  .split { grid-template-columns: 1fr 1fr; }
  .form-actions .button { flex: none; }
  .pane { height: 380px; font-size: var(--fs-sm); }
  .changed .toast { bottom: calc(var(--actionbar-h) + 0.75rem); }
}

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

/* --- scouting, builds, and project settings ------------------------------ */

/* Where an idea came from: a plain gray tag with no dot. */
.s-proposed, .s-ci { background: var(--surface-2); color: var(--muted); }
.s-proposed::before, .s-ci::before { display: none; }
.s-bug { background: var(--danger-soft); color: var(--danger); }
.s-bug::before { display: none; }
.danger-text { color: var(--danger); }
.pane.small { height: auto; max-height: 240px; margin: 0; }
.commits { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.45rem; font-size: var(--fs-sm); }
.commits li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: baseline; }
.commits code { color: var(--muted); }
.commits span { overflow-wrap: anywhere; }
.commits time { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.project-card { min-width: 0; }
.project-card .row h2 { margin-right: auto; }
.project-card .row > * { min-width: 0; }
.project-card .row .meta { flex: none; white-space: nowrap; }
.project-card h2 { overflow-wrap: anywhere; }
.about { margin-bottom: 0.9rem; font-size: 0.9rem; }
.about .facts { margin-top: 0.6rem; }
.setting { display: grid; gap: 0.5rem; margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--line); min-width: 0; }
.setting > * { min-width: 0; }
.setting-text { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }
.setting-text b { font-size: var(--fs-sm); }
.setting-text .meta { font-size: var(--fs-sm); }
.meta.wrap { overflow-wrap: anywhere; }
.setting-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.setting-actions.grow input { flex: 1 1 8rem; width: 100%; min-width: 0; }
.setting-actions select { padding: 0.45rem 0.6rem; border: 1px solid var(--field-line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; min-height: 38px; max-width: 100%; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.setting-actions input { padding: 0.5rem 0.65rem; border: 1px solid var(--field-line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--fs-sm); min-height: 38px; }
.button[disabled] { opacity: 0.55; cursor: default; }
@media (min-width: 820px) {
  .setting { grid-template-columns: 1fr auto; align-items: center; }
  .setting-actions.grow { min-width: 24rem; }
}

/* --- development servers ------------------------------------------------- */

.server-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0 0 0.75rem; }
.server-actions .button { min-width: 0; max-width: 100%; overflow-wrap: anywhere; white-space: normal; text-align: left; }
.server-actions form { margin: 0; }
.button.disabled { opacity: 0.55; pointer-events: none; }
code.wrap { overflow-wrap: anywhere; white-space: normal; }
.setting-text .pill { margin-left: 0.4rem; vertical-align: middle; }

.checkline { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.9rem; line-height: 1.4; margin: 0.2rem 0 0.9rem; min-width: 0; }
.checkline span { min-width: 0; overflow-wrap: anywhere; }
input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0.1rem 0 0; flex: none;
  border-radius: 6px; accent-color: var(--accent);
}
.project-card .link { margin: 0.4rem 0 0.6rem; }

/* The "More actions" menu on a project card. */
.menu { position: relative; flex: none; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-2); color: var(--text); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 0.3rem); z-index: 20;
  width: min(21rem, calc(100vw - 2rem)); padding: 0.35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgb(16 16 24 / 18%);
}
.menu-panel form { margin: 0; }
.menu-item {
  display: flex; gap: 0.6rem; align-items: flex-start; width: 100%; padding: 0.55rem 0.6rem;
  border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer;
}
.menu-item:focus-visible { background: var(--surface-2); }
.menu-item .icon { width: 17px; height: 17px; flex: none; margin-top: 0.1rem; color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item span, .menu-form label { display: grid; gap: 0.1rem; min-width: 0; }
.menu-panel small { color: var(--muted); font-size: var(--fs-sm); line-height: 1.35; overflow-wrap: anywhere; }
.menu-form { padding: 0.55rem 0.6rem; border-top: 1px solid var(--line); font-size: 0.9rem; }
.menu-form + form:not(.menu-form) { border-top: 1px solid var(--line); padding-top: 0.25rem; }
.menu-row { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.menu-row input, .menu-row select {
  flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 0.4rem 0.6rem;
  border: 1px solid var(--field-line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm);
}
.menu-row input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* The knowledge graph of one project. */
.kb-view { display: grid; gap: 0.9rem; }
.kb-view > .card { margin: 0; min-width: 0; }
.kb-graph svg { display: block; width: 100%; height: auto; max-height: 75vh; }
.kb-tree { stroke: var(--field-line); stroke-width: 2; }
.kb-link { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 5 4; opacity: 1; }
.kb-node circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.kb-node.depth-0 circle { fill: var(--accent); }
.kb-node.depth-2 circle { stroke: var(--muted); stroke-width: 2; }
.kb-node text { fill: var(--text); font-size: 22px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.kb-node.depth-0 text { font-weight: 700; font-size: 25px; }
.kb-node:focus-visible circle { stroke-width: 4; }
.kb-node.picked circle { fill: var(--accent); stroke: var(--accent); stroke-width: 5; }
.kb-node.picked text { font-weight: 700; }
.kb-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.6rem; color: var(--muted); font-size: var(--fs-sm); }
.kb-key { display: inline-block; width: 22px; height: 0; vertical-align: middle; border-top: 2px solid var(--field-line); }
.kb-key.link { border-top: 2px dashed var(--accent); }
.kb-reader h2 { overflow-wrap: anywhere; }
.kb-text { overflow-wrap: anywhere; font-size: 0.92rem; line-height: 1.55; margin-top: 0.5rem; }
.kb-text h3 { font-size: 0.98rem; margin: 1rem 0 0.35rem; }
.kb-text p { margin: 0.5rem 0; }
.kb-text ul { margin: 0.4rem 0; padding-left: 1.2rem; }
.kb-text pre { white-space: pre-wrap; background: var(--surface-2); padding: 0.6rem; border-radius: 8px; font-size: var(--fs-sm); }
.kb-away { color: var(--muted); }
@media (min-width: 820px) {
  .kb-view { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .kb-reader { position: sticky; top: 5rem; max-height: calc(100vh - 6rem); overflow: auto; }
}

/* Sharing: the workspace in use, and the people on a workspace or an idea. */
.workspace-tag { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; max-width: 14rem; font-size: var(--fs-sm); color: var(--muted); padding: 0.3rem 0.6rem; border-radius: 999px; background: var(--surface-2); }
.workspace-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tag .icon { width: 14px; height: 14px; flex: none; }
.people { list-style: none; margin: 0.5rem 0 0.75rem; padding: 0; }
.people li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.people li:first-child { border-top: 0; }
.people form { flex: none; }
.people .row-actions { flex: none; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

/* Check preview */
.check-steps { margin: 0 0 0.9rem; padding-left: 1.2rem; display: grid; gap: 0.6rem; }
.check-step.skipped { color: var(--muted); }

/* The stable preview link and its QR code */
.preview-link { display: flex; gap: 0.9rem; align-items: flex-start; margin-bottom: 0.9rem; }
.preview-link > div:first-child { flex: 1; min-width: 0; }
.qr { flex: none; width: 132px; }
.qr svg { display: block; width: 100%; height: auto; shape-rendering: crispEdges; border-radius: var(--radius-sm); }
@media (max-width: 520px) { .preview-link { flex-direction: column; } }

/* --- hover and press ------------------------------------------------------ */

/* Hover styles apply only where a pointer can hover, so they do not stick
   after a tap on a phone. */
@media (hover: hover) {
  a:hover { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
  .brand:hover { text-decoration: none; }
  .brand:hover .brand-mark { transform: translateX(3px); }
  .topnav a:not(.button):hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
  .worker-dot:hover { text-decoration: none; }
  .back:hover { color: var(--text); text-decoration: none; }
  .tabbar a:hover { text-decoration: none; }
  .button:hover { text-decoration: none; filter: brightness(1.05); }
  .icon-button:hover { background: var(--surface-2); color: var(--text); }
  .idea-card a:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
  .segments button:hover { color: var(--text); }
  .comment-close .link:hover { color: var(--text); }
  .workspace-tag:hover { text-decoration: none; color: var(--text); }
  .menu-item:hover { background: var(--surface-2); text-decoration: none; }
  .kb-node:hover circle { stroke-width: 4; }
}

/* A press fills the control, so a tap shows on a phone. */
.chip:active, .tabbar a:active, .topnav a:not(.button):active, .icon-button:active, .menu-item:active { background: var(--surface-2); }
.chip[aria-pressed="true"]:active { background: color-mix(in srgb, var(--text) 85%, var(--bg)); }
.segments button:active { background: var(--surface); }
.idea-card.compact a:active { background: var(--surface-2); }
