/* ============================================================
   Goodie Hoops — Chainlit custom stylesheet
   Brand: gold #EEAA11→#FFCE60, magenta #BB3382→#E01F8F
   ============================================================ */

/* Reusable gradient helpers */
:root {
  --gh-gradient-primary: linear-gradient(
    135deg,
    hsl(var(--gh-magenta-start)) 0%,
    hsl(var(--gh-magenta-end)) 100%
  );
  --gh-gradient-accent: linear-gradient(
    135deg,
    hsl(var(--gh-gold-start)) 0%,
    hsl(var(--gh-gold-end)) 100%
  );
  --gh-gradient-duo: linear-gradient(
    135deg,
    hsl(var(--gh-gold-end)) 0%,
    hsl(var(--gh-gold-start)) 40%,
    hsl(var(--gh-magenta-start)) 70%,
    hsl(var(--gh-magenta-end)) 100%
  );
}

/* --- Brand wordmark on welcome / header ------------------- */
h1, h2 {
  letter-spacing: -0.01em;
}

/* Gradient text for primary headings on the welcome screen */
.welcome-screen h1,
[data-testid="welcome-screen"] h1 {
  background: var(--gh-gradient-duo);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

/* --- Primary buttons: magenta → magenta gradient --------- */
button[data-variant="default"],
.bg-primary,
button.bg-primary {
  background: var(--gh-gradient-primary) !important;
  border: none;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button[data-variant="default"]:hover,
.bg-primary:hover,
button.bg-primary:hover {
  filter: brightness(1.08) saturate(1.05);
}

button[data-variant="default"]:active,
.bg-primary:active {
  transform: translateY(1px);
}

/* --- Starter cards: subtle gold border hover ------------- */
.starter-button,
button[class*="starter"] {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.starter-button:hover,
button[class*="starter"]:hover {
  border-color: hsl(var(--accent)) !important;
  box-shadow: 0 4px 20px -8px hsl(var(--gh-gold-start) / 0.35),
              0 2px 10px -6px hsl(var(--gh-magenta-end) / 0.25);
}

/* --- Strip composer chrome ------------------------------- */
/* Slash commands and the tools menu are removed in app.py — also hide their
   trigger buttons so the composer is a clean textbox. */
button[aria-label="Tools"],
button[data-testid="tools-button"],
button:has(svg.lucide-tool-case),
button:has(svg.lucide-wrench),
button[aria-label*="Commands"],
[data-command-button] {
  display: none !important;
}

/* --- Sidebar active thread: magenta accent --------------- */
[data-state="active"][data-sidebar="menu-button"],
.bg-sidebar-accent[data-active="true"] {
  background: linear-gradient(
    90deg,
    hsl(var(--gh-magenta-end) / 0.12) 0%,
    hsl(var(--gh-magenta-end) / 0.04) 100%
  ) !important;
  border-left: 2px solid hsl(var(--primary));
}

/* --- Message author avatar fallback: gradient ring ------ */
.bg-primary\/10,
[data-avatar] {
  background-image: var(--gh-gradient-primary);
}

/* --- Login page polish ----------------------------------
   Chainlit 2.11 renders the login route as a two-column grid with the
   signature `.grid.min-h-svh.lg:grid-cols-2`. The first child is the
   form column; the second is the marketing image. There is no
   `data-login-page` attribute — selectors below target the grid directly. */

/* Soft gradient tint on the image column so it reads with the brand. */
div.grid.min-h-svh.lg\:grid-cols-2 > div:nth-child(2) {
  position: relative;
}

div.grid.min-h-svh.lg\:grid-cols-2 > div:nth-child(2)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
      ellipse at top left,
      hsl(var(--gh-gold-end) / 0.18) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse at bottom right,
      hsl(var(--gh-magenta-end) / 0.22) 0%,
      transparent 55%
    );
}

/* --- Feedback thumbs: hidden (not used in this app) ------ */
button[class*="positive-feedback"],
button[class*="negative-feedback"],
button[aria-label*="positive feedback"],
button[aria-label*="negative feedback"] {
  display: none !important;
}

/* --- Scrollbars ----------------------------------------- */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: hsl(var(--muted));
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--primary) / 0.55);
}

/* --- Chain-of-thought (Steps) header accent ------------- */
[data-step] > div:first-child,
.step-header {
  border-left: 2px solid hsl(var(--accent));
}

/* --- User profile dropdown (settings / theme / readme) -- */
/* Chainlit lacks an API to add items to the profile menu, so instead we
   brand the existing surface so it reads as part of the Goodie Hoops UI. */
[role="menu"][data-side],
[data-radix-popper-content-wrapper] [role="menu"] {
  border: 1px solid hsl(var(--gh-magenta-end) / 0.25) !important;
  box-shadow:
    0 8px 24px -10px hsl(var(--gh-magenta-end) / 0.35),
    0 4px 12px -6px hsl(var(--gh-gold-end) / 0.18) !important;
}

[role="menu"] [role="menuitem"]:hover,
[role="menu"] [role="menuitem"][data-highlighted] {
  background: linear-gradient(
    90deg,
    hsl(var(--gh-magenta-end) / 0.08) 0%,
    hsl(var(--gh-gold-end) / 0.05) 100%
  ) !important;
}

[role="menu"] [role="menuitem"] svg {
  color: hsl(var(--primary));
}

/* --- Login page: back link + brand text + logo polish ---
   `#gh-back-link` and `#gh-login-title` are injected by /public/custom.js
   into the left column of the login grid. */

#gh-back-link {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground) / 0.85);
  background: hsl(var(--background) / 0.6);
  border: 1px solid hsl(var(--border) / 0.6);
  backdrop-filter: blur(8px);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

#gh-back-link:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-back-link:active {
  transform: translateY(1px);
}

/* Goodie Hoops Admin wordmark, painted under the logo. */
#gh-login-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  background: var(--gh-gradient-duo);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (min-width: 768px) {
  #gh-login-title {
    text-align: left;
  }
}

/* Brand the login logo. Chainlit's `/auth/config` endpoint strips
   `logo_file_url` from the unauthenticated payload, so the login page
   always falls back to `/logo?theme=...` (the default Chainlit mark).
   We swap the rendered image via `content: url(...)` and resize the
   square IconNew.svg to a brand chip (default is a 150px rectangle). */
div.grid.min-h-svh.lg\:grid-cols-2 img.logo {
  content: url("/public/IconNew.svg");
  width: 64px !important;
  height: 64px !important;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px hsl(var(--gh-magenta-end) / 0.35));
}

/* --- Chat-profile (admin) dropdown -----------------------
   Trigger lives at `#chat-profiles` (Radix SelectTrigger) inside the
   chainlit top bar. We do NOT relocate it in the DOM — moving a
   React-managed node into a sibling subtree corrupts React's reconciler.
   Instead, custom.js renders a sibling proxy button (#gh-admin-proxy) in
   the sidebar and parks the original trigger on top of the proxy with
   opacity:0 + pointer-events:none, so Radix's portal opens the menu where
   the user expects it. */

/* Strip the per-item avatar from the open menu — all three admins share
   the same IconNew.svg, so the row of identical avatars is just noise.

   Chainlit 2.11 renders each item as:
     <SelectItem data-test="select-item:Brian" …>
       <span>…checkmark…</span>
       <SelectItemText>
         <div class="flex items-center gap-2">
           <img class="w-6 h-6 rounded-md object-cover" src=".../IconNew.svg">
           <span>Brian</span>
         </div>
       </SelectItemText>
     </SelectItem>

   SelectItemText can also re-render children inside the trigger's value
   portal, so we additionally match any IconNew image inside the Radix
   popper wrapper — a belt-and-suspenders rule that catches both places. */
[data-test^="select-item:"] img,
[data-test^="select-item:"] [data-radix-avatar-image],
[data-test^="select-item:"] [class*="avatar"],
[data-radix-popper-content-wrapper] img[src*="IconNew"],
[role="option"] img[src*="IconNew"],
#chat-profile-description img {
  display: none !important;
}

/* Collapse the now-empty flex gap so the name hugs the left edge. */
[data-test^="select-item:"] div.flex.items-center.gap-2,
[role="option"] div.flex.items-center.gap-2 {
  gap: 0 !important;
}

/* Hide the icon logo inside the trigger itself (collapsed selector state). */
#chat-profiles img,
#chat-profiles svg.lucide-image,
#chat-profiles [data-radix-avatar-image],
#chat-profiles [class*="avatar"] {
  display: none !important;
}

/* Sidebar admin selector proxy. Mirrors the active admin name and forwards
   clicks to the hidden top-bar Radix trigger. */
button#gh-admin-proxy {
  margin: 0.5rem 0.5rem 0.25rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: calc(100% - 1rem);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: hsl(var(--sidebar-foreground, var(--foreground)));
  background: transparent;
  border: 1px solid hsl(var(--sidebar-border, var(--border)) / 0.6);
  cursor: pointer;
  text-align: left;
  flex-shrink: 0;
}

button#gh-admin-proxy:hover {
  background: hsl(var(--sidebar-accent, var(--accent)));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

button#gh-admin-proxy .gh-admin-proxy-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

button#gh-admin-proxy .gh-admin-proxy-chevron {
  flex-shrink: 0;
  display: inline-flex;
  opacity: 0.7;
}

/* When the sidebar collapses to a thin rail, hide the proxy entirely
   (chainlit collapses the content area; we leave room for the rail icons). */
[data-sidebar="sidebar"][data-state="collapsed"] button#gh-admin-proxy,
[data-sidebar="sidebar"][data-collapsible="icon"][data-state="collapsed"] button#gh-admin-proxy {
  display: none !important;
}

/* --- Sidebar nav grid ------------------------------------
   Five action buttons (Skills, Projects, Forecast, Knowledge, Performance)
   live in a 2-column grid of square tiles pinned to the bottom of the
   sidebar shell. custom.js injects `#gh-nav-grid` as the LAST child of
   `[data-sidebar="sidebar"]` so the thread-history content area scrolls
   above it while the nav stays visible. */

/* Force the shell into a flex column so the nav grid can pin visually
   to the bottom via `order: 9999` while `[data-sidebar="content"]`
   fills the remaining space and scrolls independently. Scoped with a
   data-attr set by custom.js (avoids `:has()` — which can be slow in
   mobile WebKit with our mutation observer). */
[data-sidebar="sidebar"][data-gh-nav="1"] {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

[data-sidebar="sidebar"][data-gh-nav="1"] > [data-sidebar="content"] {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

#gh-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.75rem;
  flex-shrink: 0;
  order: 9999; /* always render visually last in the flex-column shell */
  border-top: 1px solid hsl(var(--sidebar-border, var(--border)) / 0.5);
  background: inherit;
}

/* Explicit display order regardless of injection race. */
#gh-nav-grid > button#gh-skills-button { order: 1; }
#gh-nav-grid > button#gh-apps-button { order: 2; }
#gh-nav-grid > button#gh-projects-button { order: 3; }
#gh-nav-grid > button#gh-forecast-button { order: 4; }
#gh-nav-grid > button#gh-kb-button { order: 5; }
#gh-nav-grid > button#gh-perf-button { order: 6; }

#gh-nav-grid > button {
  aspect-ratio: 2 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem;
  margin: 0;
  width: 100%;
  border-radius: 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.1;
  color: hsl(var(--sidebar-foreground, var(--foreground)));
  background: transparent;
  border: 1px solid hsl(var(--sidebar-border, var(--border)) / 0.6);
  cursor: pointer;
  text-align: center;
  transition: background-color 0.12s ease, border-color 0.12s ease,
    transform 0.12s ease;
}

#gh-nav-grid > button:hover {
  background: hsl(var(--sidebar-accent, var(--accent)));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
  transform: translateY(-1px);
}

#gh-nav-grid > button:active {
  transform: translateY(0);
}

#gh-nav-grid > button .gh-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  color: inherit;
}

#gh-nav-grid > button .gh-nav-icon svg {
  width: 100%;
  height: 100%;
}

#gh-nav-grid > button .gh-nav-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Collapse nav grid on rail (icon-only) mode — the tiles are too wide. */
[data-sidebar="sidebar"][data-state="collapsed"] #gh-nav-grid,
[data-sidebar="sidebar"][data-collapsible="icon"][data-state="collapsed"] #gh-nav-grid {
  display: none !important;
}

/* Mobile: Chainlit renders the sidebar inside a Radix Sheet. Only the
   mobile sheet variant (`[data-mobile="true"]`) gets the flex-column
   layout so the content area scrolls and the nav grid stays pinned.
   We do NOT touch `[role="dialog"]` — that's too broad and was clipping
   unrelated Chainlit dialogs. */
@media (max-width: 767px) {
  [data-sidebar="sidebar"][data-mobile="true"][data-gh-nav="1"] {
    height: 100%;
    max-height: 100dvh;
  }

  #gh-nav-grid {
    gap: 0.4rem;
    padding: 0.4rem 0.4rem calc(env(safe-area-inset-bottom, 0px) + 0.6rem);
  }

  #gh-nav-grid > button {
    font-size: 0.65rem;
    padding: 0.3rem;
  }
}

/* --- Projects overlay ----------------------------------- */
#gh-projects-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: hsl(var(--background));
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 1.5rem 3rem;
}

.gh-projects-scroll {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin: 0 auto;
}

#gh-projects-back {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

#gh-projects-back:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-projects-back:active {
  transform: translateY(1px);
}

#gh-projects-refresh {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  color: hsl(var(--foreground));
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

#gh-projects-refresh:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-projects-refresh:active {
  transform: rotate(180deg);
}

.gh-projects-header {
  text-align: left;
}

.gh-projects-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.gh-projects-title {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.gh-projects-meta {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.75;
}

.gh-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.gh-project-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 1.5rem;
  border-radius: 1rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card, var(--background)));
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.gh-project-card:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.45);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -18px rgba(0, 0, 0, 0.5);
}

.gh-project-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  opacity: 0.9;
}

.gh-project-card-count {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--gh-gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.gh-project-card-sub {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.7;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.gh-project-card-error .gh-project-card-count {
  background: none;
  -webkit-text-fill-color: hsl(var(--destructive, 0 70% 50%));
  color: hsl(var(--destructive, 0 70% 50%));
}

.gh-project-card-error .gh-project-card-sub {
  color: hsl(var(--destructive, 0 70% 50%));
  opacity: 0.85;
  text-transform: none;
}

.gh-projects-empty {
  grid-column: 1 / -1;
  padding: 2rem;
  text-align: center;
  border-radius: 0.75rem;
  border: 1px dashed hsl(var(--border));
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.75;
}

.gh-projects-empty.gh-projects-error {
  color: hsl(var(--destructive, 0 70% 50%));
  border-color: hsl(var(--destructive, 0 70% 50%) / 0.4);
  opacity: 1;
}

/* --- Projects header title row + Audit button --------------------------- */
.gh-projects-titlerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.gh-projects-titlerow .gh-projects-title {
  margin: 0;
}

button.gh-projects-audit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--gh-gradient-primary);
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, 0.5);
}

button.gh-projects-audit-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button.gh-projects-audit-btn:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

/* --- Audit picker modal ------------------------------------------------- */
.gh-audit-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.gh-audit-modal-card {
  width: min(520px, 100%);
  background: hsl(var(--card, var(--background)));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}

.gh-audit-modal-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.75;
  margin-bottom: 0.5rem;
}

.gh-audit-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.gh-audit-modal-sub {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.8;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.gh-audit-modal-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

button.gh-audit-pick {
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.gh-audit-pick:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
  background: hsl(var(--accent, var(--background)));
}

.gh-audit-modal-footer {
  display: flex;
  justify-content: flex-end;
}

button.gh-audit-cancel {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)));
  cursor: pointer;
}

button.gh-audit-cancel:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

/* --- Audit report panel ------------------------------------------------- */
.gh-audit-panel {
  margin-top: 1.5rem;
  border-radius: 1rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card, var(--background)));
  overflow: hidden;
  box-shadow: 0 16px 50px -28px rgba(0, 0, 0, 0.4);
}

.gh-audit-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: linear-gradient(180deg, hsl(var(--accent, var(--background))) 0%, transparent 100%);
}

.gh-audit-panel-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 0.4rem;
}

.gh-audit-panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
  background: var(--gh-gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.gh-audit-panel-meta {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.8;
}

button.gh-audit-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground, var(--foreground)));
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

button.gh-audit-close:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-audit-panel-body {
  padding: 1.5rem;
}

.gh-audit-loading {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  border-radius: 0.75rem;
  border: 1px dashed hsl(var(--border));
  color: hsl(var(--muted-foreground, var(--foreground)));
}

.gh-audit-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--gh-magenta-end));
  animation: gh-audit-spin 0.9s linear infinite;
}

@keyframes gh-audit-spin {
  to { transform: rotate(360deg); }
}

.gh-audit-loading-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

.gh-audit-loading-hint {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  opacity: 0.7;
}

.gh-audit-error {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--destructive, 0 70% 50%) / 0.5);
  background: hsl(var(--destructive, 0 70% 50%) / 0.08);
  color: hsl(var(--destructive, 0 70% 50%));
  font-size: 0.875rem;
}

.gh-audit-report-md {
  font-size: 0.95rem;
  line-height: 1.65;
  color: hsl(var(--foreground));
}

.gh-audit-report-md h1,
.gh-audit-report-md h2,
.gh-audit-report-md h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.gh-audit-report-md h1 { font-size: 1.4rem; }
.gh-audit-report-md h2 { font-size: 1.15rem; }
.gh-audit-report-md h3 { font-size: 1rem; opacity: 0.85; }

.gh-audit-report-md ul,
.gh-audit-report-md ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0 1rem;
}

.gh-audit-report-md li {
  margin-bottom: 0.35rem;
}

.gh-audit-report-md p {
  margin: 0.5rem 0 1rem;
}

.gh-audit-report-md code {
  background: hsl(var(--accent, var(--background)));
  border: 1px solid hsl(var(--border));
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

.gh-audit-report-md strong {
  color: hsl(var(--foreground));
  font-weight: 700;
}

.gh-audit-report-md hr {
  border: none;
  border-top: 1px solid hsl(var(--border));
  margin: 1.5rem 0;
}

/* --- Forecast overlay ----------------------------------- */
#gh-forecast-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: hsl(var(--background));
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 1.5rem 3rem;
}

.gh-forecast-scroll {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: auto 0;
}

#gh-forecast-back {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

#gh-forecast-back:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-forecast-back:active {
  transform: translateY(1px);
}

.gh-forecast-card {
  width: 100%;
  border-radius: 1.25rem;
  padding: 2.5rem 2rem;
  text-align: center;
  color: #ffffff;
  box-shadow:
    0 20px 60px -20px rgba(0, 0, 0, 0.35),
    0 8px 24px -12px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
}

.gh-forecast-card[data-tone="yellow"] {
  background: var(--gh-gradient-accent);
  color: #1a1208;
}

.gh-forecast-card[data-tone="magenta"] {
  background: var(--gh-gradient-primary);
  color: #ffffff;
}

.gh-forecast-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.gh-forecast-amount {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1rem;
}

.gh-forecast-status {
  font-size: 1rem;
  font-weight: 500;
  opacity: 0.95;
  min-height: 1.25rem;
}

.gh-forecast-advisory {
  margin-top: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.3;
  color: #ffffff;
}

.gh-forecast-recent-notice {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.85rem;
  line-height: 1.45;
  color: #ffffff;
  max-width: 36rem;
}

.gh-forecast-cta {
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: hsl(var(--gh-magenta-end));
  background: #ffffff;
  border: 0;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.25);
}

.gh-forecast-cta:hover {
  box-shadow: 0 6px 18px -4px rgba(0, 0, 0, 0.3);
}

.gh-forecast-cta:active {
  transform: translateY(1px);
}

.gh-forecast-cta[disabled] {
  opacity: 0.7;
  cursor: wait;
}

/* Analysis panel — LLM-generated findings rendered below the headline card. */
.gh-forecast-analysis {
  width: 100%;
  border-radius: 1rem;
  background: hsl(var(--card, var(--background)));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.3);
  color: hsl(var(--foreground));
}

.gh-forecast-analysis-inner {
  padding: 1.75rem 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.gh-fa-loading {
  font-size: 0.95rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.gh-fa-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid hsl(var(--gh-magenta-end) / 0.25);
  border-top-color: hsl(var(--gh-magenta-end));
  animation: gh-fa-spin 0.8s linear infinite;
}

@keyframes gh-fa-spin {
  to { transform: rotate(360deg); }
}

.gh-fa-error {
  color: hsl(var(--destructive, 0 70% 50%));
  font-size: 0.9rem;
}

.gh-fa-headline {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  background: var(--gh-gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gh-fa-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gh-fa-section h3 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.85;
  margin: 0;
}

.gh-fa-section p {
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0;
  color: hsl(var(--foreground));
}

.gh-fa-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gh-fa-list li {
  font-size: 0.925rem;
  line-height: 1.5;
  padding-left: 1rem;
  position: relative;
}

.gh-fa-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gh-gradient-primary);
}

.gh-fa-list strong {
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* --- Forecast: action buttons (Start / Confirm / Exit / etc.) --- */
.gh-fa-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.gh-forecast-action-btn {
  appearance: none;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s ease;
}

.gh-forecast-action-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px hsl(var(--foreground) / 0.08); }
.gh-forecast-action-btn:active { transform: translateY(0); }
.gh-forecast-action-btn[disabled] { opacity: 0.5; cursor: default; }

.gh-forecast-action-primary {
  background: var(--gh-gradient-primary);
  color: #fff;
  border-color: transparent;
}

/* --- Progress steps (shadcn-aligned CoT visual) ------------------------ */
/* Used by the forecast / projects-audit overlays AND mirrors the in-chat
   chain_of_thought.jsx CustomElement so both surfaces share visual DNA:
   left icon rail, status-coded text, complete = check, active = spinner,
   pending = faint dot.                                                    */
.gh-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.35rem 0;
}

.gh-step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.875rem;
  line-height: 1.35;
  color: hsl(var(--muted-foreground, var(--foreground) / 0.6));
  transition: color 0.2s ease;
  padding-bottom: 0.1rem;
}

/* Vertical rail connecting consecutive steps (positioned through the icon). */
.gh-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 1.1rem;
  bottom: -0.55rem;
  width: 1px;
  background: hsl(var(--border));
}

.gh-step-icon {
  position: relative;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 0.05rem;
  border-radius: 50%;
  border: 1.5px solid hsl(var(--border));
  background: transparent;
  z-index: 1;
}

.gh-step-label {
  flex: 1 1 auto;
  min-width: 0;
}

/* Pending: faint dot, dimmed text. */
.gh-step-pending {
  color: hsl(var(--muted-foreground, var(--foreground) / 0.45)) !important;
  opacity: 0.7;
}

.gh-step-pending .gh-step-icon {
  border-color: hsl(var(--border) / 0.6);
}

.gh-step-pending .gh-step-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: hsl(var(--muted-foreground, var(--foreground) / 0.4));
  transform: translate(-50%, -50%);
}

/* Active: spinner ring, full-strength text + medium weight. */
.gh-step-active {
  color: hsl(var(--foreground));
  font-weight: 500;
}

.gh-step-active .gh-step-icon {
  border-color: var(--gh-magenta-end, #d946ef);
  border-top-color: transparent;
  animation: gh-fa-spin 0.8s linear infinite;
}

/* Complete: gradient fill + check, muted-foreground text. */
.gh-step-done {
  color: hsl(var(--muted-foreground, var(--foreground) / 0.7));
}

.gh-step-done .gh-step-icon {
  background: var(--gh-gradient-primary);
  border-color: transparent;
}

.gh-step-done .gh-step-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center/10px no-repeat;
}

/* --- Forecast: preview table --- */
.gh-fa-write-meta {
  font-size: 0.875rem;
  color: hsl(var(--foreground) / 0.7);
  margin: 0.25rem 0 0.75rem;
}

.gh-fa-write-meta strong {
  color: hsl(var(--foreground));
  font-weight: 600;
}

.gh-preview-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--background));
}

.gh-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.gh-preview-table thead th {
  position: sticky;
  top: 0;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.55rem 0.75rem;
  text-align: right;
  font-weight: 600;
  color: hsl(var(--foreground) / 0.7);
}

.gh-preview-table thead th:first-child {
  text-align: left;
}

.gh-preview-table tbody td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
  text-align: right;
  color: hsl(var(--foreground));
}

.gh-preview-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
  color: hsl(var(--foreground) / 0.85);
}

.gh-preview-table tbody tr:last-child td {
  border-bottom: none;
}

.gh-preview-table tbody tr:hover td {
  background: hsl(var(--foreground) / 0.04);
}

/* --- Forecast: done summary --- */
.gh-forecast-done .gh-forecast-summary-md {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border-radius: 16px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  font-size: 0.925rem;
  line-height: 1.55;
  color: hsl(var(--foreground));
}

.gh-forecast-summary-md h1,
.gh-forecast-summary-md h2,
.gh-forecast-summary-md h3 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}

.gh-forecast-summary-md h1 { font-size: 1.25rem; }
.gh-forecast-summary-md h2 { font-size: 1.1rem; }
.gh-forecast-summary-md h3 { font-size: 0.975rem; color: hsl(var(--foreground) / 0.85); }

.gh-forecast-summary-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  font-variant-numeric: tabular-nums;
}

.gh-forecast-summary-md th,
.gh-forecast-summary-md td {
  border-bottom: 1px solid hsl(var(--border) / 0.6);
  padding: 0.4rem 0.6rem;
  text-align: right;
}

.gh-forecast-summary-md th:first-child,
.gh-forecast-summary-md td:first-child {
  text-align: left;
}

.gh-forecast-summary-md code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: hsl(var(--foreground) / 0.06);
}

/* --- Knowledge browser overlay --------------------------- */
#gh-kb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: block;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

#gh-kb-back,
#gh-kb-toggle {
  position: fixed;
  top: 1rem;
  z-index: 10001;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(10px);
  cursor: pointer;
}

#gh-kb-back {
  right: 1rem;
}

#gh-kb-toggle {
  left: 1rem;
  padding: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
}

#gh-kb-back:hover,
#gh-kb-toggle:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-kb-tree {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  font-size: 0.875rem;
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.gh-kb-sidebar-header {
  padding: 4rem 0.75rem 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gh-kb-reindex {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  cursor: pointer;
}

.gh-kb-reindex:hover:not(:disabled) {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-kb-reindex:disabled {
  opacity: 0.55;
  cursor: progress;
}

.gh-kb-status {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

.gh-kb-tree-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.5rem 1rem;
}

/* Bottom nav tiles inside the knowledge sidebar — mirrors the main
   #gh-nav-grid layout so the two places feel consistent. */
.gh-kb-nav-grid {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
  border-top: 1px solid hsl(var(--border) / 0.6);
  background: inherit;
}

.gh-kb-nav-grid > button {
  aspect-ratio: 2 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem;
  margin: 0;
  width: 100%;
  border-radius: 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.1;
  color: hsl(var(--foreground));
  background: transparent;
  border: 1px solid hsl(var(--border) / 0.6);
  cursor: pointer;
  text-align: center;
  transition: background-color 0.12s ease, border-color 0.12s ease,
    transform 0.12s ease;
}

.gh-kb-nav-grid > button:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
  transform: translateY(-1px);
}

.gh-kb-nav-grid > button:active {
  transform: translateY(0);
}

.gh-kb-nav-grid > button .gh-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  color: inherit;
}

.gh-kb-nav-grid > button .gh-nav-icon svg {
  width: 100%;
  height: 100%;
}

.gh-kb-nav-grid > button .gh-nav-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Coming-soon dialog launched from knowledge sidebar tiles. */
.gh-kb-soon-overlay {
  position: fixed;
  inset: 0;
  z-index: 10010;
  background: hsl(var(--background) / 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.gh-kb-soon-modal {
  width: min(380px, 100%);
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 1.5rem 1.25rem 1.25rem;
  box-shadow: 0 20px 50px -20px hsl(0 0% 0% / 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}

.gh-kb-soon-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.gh-kb-soon-body {
  margin: 0;
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
}

.gh-kb-soon-close {
  align-self: center;
  margin-top: 0.5rem;
  padding: 0.45rem 1.1rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.gh-kb-soon-close:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-kb-overlay[data-sidebar="closed"] .gh-kb-tree {
  transform: translateX(-100%);
}

.gh-kb-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gh-kb-row:hover {
  background: hsl(var(--accent));
}

.gh-kb-folder {
  font-weight: 600;
  color: hsl(var(--foreground));
}

.gh-kb-file {
  color: hsl(var(--foreground) / 0.85);
}

.gh-kb-caret {
  display: inline-block;
  width: 0.75rem;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
}

.gh-kb-content {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 4rem 3rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gh-kb-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.gh-kb-crumb {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.02em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-kb-crumb:empty {
  display: none;
}

.gh-kb-download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  cursor: pointer;
  flex: 0 0 auto;
}

.gh-kb-download:hover:not(:disabled) {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-kb-download:disabled {
  opacity: 0.55;
  cursor: progress;
}

.gh-kb-preview {
  max-width: 760px;
  line-height: 1.6;
}

.gh-kb-preview h1,
.gh-kb-preview h2,
.gh-kb-preview h3 {
  letter-spacing: -0.01em;
  margin-top: 1.5em;
}

.gh-kb-preview h1:first-child {
  margin-top: 0;
}

.gh-kb-preview p,
.gh-kb-preview ul,
.gh-kb-preview ol {
  margin: 0.75em 0;
}

.gh-kb-preview code {
  background: hsl(var(--muted));
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.gh-kb-preview pre {
  background: hsl(var(--muted));
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}

.gh-kb-preview pre code {
  background: transparent;
  padding: 0;
}

.gh-kb-preview a.gh-kb-wikilink {
  color: hsl(var(--primary));
  text-decoration: none;
  border-bottom: 1px dashed hsl(var(--primary) / 0.5);
  cursor: pointer;
}

.gh-kb-preview a.gh-kb-wikilink:hover {
  border-bottom-style: solid;
}

.gh-kb-empty,
.gh-kb-loading {
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.gh-kb-error,
.gh-kb-miss {
  color: hsl(var(--destructive, var(--primary)));
  background: hsl(var(--destructive, var(--primary)) / 0.1);
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

button#gh-perf-button svg {
  color: currentColor;
  flex-shrink: 0;
}

#gh-perf-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: hsl(var(--background));
}

#gh-perf-overlay iframe {
  width: 100vw;
  height: 100vh;
  border: 0;
  display: block;
  background: hsl(var(--background));
}

#gh-perf-back {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

#gh-perf-back:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

#gh-perf-back:active {
  transform: translateY(1px);
}


/* ===========================================================================
   Initiate PM — staged planning, HITL, change-set preview, apply log
   =========================================================================== */

.gh-pm-cta-row {
  margin-top: 1.5rem;
  justify-content: flex-start;
  gap: 0.6rem;
}

.gh-pm-initiate-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(
    90deg,
    hsl(var(--gh-magenta-start, 312 92% 47%)),
    hsl(var(--gh-magenta-end, 282 92% 50%))
  );
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}

.gh-pm-initiate-btn:hover { filter: brightness(1.07); }
.gh-pm-initiate-btn:active { transform: translateY(1px); }
.gh-pm-initiate-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.gh-pm-cancel-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.gh-pm-cancel-btn:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.45);
  color: hsl(var(--primary));
}

.gh-pm-meta {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}

.gh-pm-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gh-pm-thought {
  font-size: 0.83rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
  min-height: 1.1em;
}

.gh-pm-substeps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gh-pm-substep {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  font-size: 0.83rem;
  color: hsl(var(--muted-foreground));
}

.gh-pm-substep-icon {
  flex-shrink: 0;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid hsl(var(--muted-foreground) / 0.5);
}

.gh-pm-substep-active {
  color: hsl(var(--foreground));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-pm-substep-active .gh-pm-substep-icon {
  border-color: hsl(var(--gh-magenta-end));
  border-top-color: transparent;
  animation: gh-pm-spin 0.9s linear infinite;
}

.gh-pm-substep-done .gh-pm-substep-icon {
  background: hsl(var(--gh-magenta-end));
  border-color: hsl(var(--gh-magenta-end));
}

.gh-pm-substep-failed .gh-pm-substep-icon {
  background: #d44;
  border-color: #d44;
}

.gh-pm-substep-brief {
  color: hsl(var(--muted-foreground));
  font-size: 0.78rem;
}

@keyframes gh-pm-spin {
  to { transform: rotate(360deg); }
}

/* HITL prompt card */
.gh-pm-hitl-card {
  margin-top: 0.8rem;
  padding: 1rem;
  border-radius: 14px;
  background: hsl(var(--muted) / 0.35);
  border: 1px solid hsl(var(--gh-magenta-end) / 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.gh-pm-hitl-prompt {
  font-size: 0.93rem;
  color: hsl(var(--foreground));
  font-weight: 500;
}

.gh-pm-hitl-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.gh-pm-hitl-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.6);
  color: hsl(var(--foreground));
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.gh-pm-hitl-chip:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
}

.gh-pm-hitl-input {
  width: 100%;
  min-height: 4.4rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
}

.gh-pm-hitl-input:focus {
  outline: 0;
  border-color: hsl(var(--gh-magenta-end) / 0.6);
}

.gh-pm-hitl-skip {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 0.83rem;
}

/* Preview UI */
.gh-pm-preview {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.gh-pm-preview-loading {
  padding: 2rem 0;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.88rem;
}

.gh-pm-preview-summary {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: hsl(var(--muted) / 0.35);
  border: 1px solid hsl(var(--border));
  font-size: 0.9rem;
  color: hsl(var(--foreground));
  line-height: 1.5;
}

.gh-pm-group {
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--background));
  overflow: hidden;
}

.gh-pm-group[open] {
  border-color: hsl(var(--gh-magenta-end) / 0.35);
}

.gh-pm-group-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  list-style: none;
  background: hsl(var(--muted) / 0.45);
  font-size: 0.9rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.gh-pm-group-summary::-webkit-details-marker { display: none; }

.gh-pm-group-toggle {
  width: 16px;
  height: 16px;
  accent-color: hsl(var(--gh-magenta-end));
  cursor: pointer;
}

.gh-pm-group-label { flex: 1 1 auto; }

.gh-pm-changes {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gh-pm-change {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: hsl(var(--muted) / 0.25);
  border: 1px solid hsl(var(--border));
}

.gh-pm-change-cb {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  accent-color: hsl(var(--gh-magenta-end));
  cursor: pointer;
}

.gh-pm-change-body { min-width: 0; }

.gh-pm-change-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.35rem;
}

.gh-pm-change-meta {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.35rem;
}

.gh-pm-change-notes {
  font-size: 0.83rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
  line-height: 1.45;
}

.gh-pm-change-rationale {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
  border-left: 2px solid hsl(var(--gh-magenta-end) / 0.4);
  padding-left: 0.55rem;
}

.gh-pm-diff {
  width: 100%;
  border-collapse: collapse;
  margin: 0.3rem 0 0.5rem;
  font-size: 0.8rem;
}

.gh-pm-diff th,
.gh-pm-diff td {
  border-bottom: 1px solid hsl(var(--border) / 0.55);
  padding: 0.3rem 0.4rem;
  text-align: left;
  vertical-align: top;
  color: hsl(var(--foreground));
}

.gh-pm-diff thead th {
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.04em;
}

.gh-pm-diff tbody th {
  width: 7rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.gh-pm-diff-before { color: hsl(var(--muted-foreground)); }
.gh-pm-diff-after  { color: hsl(var(--foreground)); font-weight: 500; }

.gh-pm-diff-empty {
  color: hsl(var(--muted-foreground));
  font-style: italic;
  text-align: center;
}

.gh-pm-confirm-row {
  margin-top: 0.5rem;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Apply phase */
.gh-pm-apply-header {
  font-size: 0.93rem;
  color: hsl(var(--foreground));
  margin-bottom: 0.7rem;
}

.gh-pm-apply-bar {
  height: 6px;
  border-radius: 999px;
  background: hsl(var(--muted) / 0.6);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.gh-pm-apply-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    hsl(var(--gh-magenta-start, 312 92% 47%)),
    hsl(var(--gh-magenta-end, 282 92% 50%))
  );
  transition: width 0.25s ease;
}

.gh-pm-apply-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 360px;
  overflow-y: auto;
}

.gh-pm-apply-row {
  display: grid;
  grid-template-columns: 1.2rem 6rem 1fr;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  background: hsl(var(--muted) / 0.3);
  border: 1px solid hsl(var(--border));
  font-size: 0.83rem;
  color: hsl(var(--foreground));
}

.gh-pm-apply-icon {
  font-weight: 600;
  text-align: center;
}

.gh-pm-apply-kind {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
}

.gh-pm-apply-msg {
  color: hsl(var(--muted-foreground));
}

.gh-pm-apply-running { border-color: hsl(var(--gh-magenta-end) / 0.45); }
.gh-pm-apply-running .gh-pm-apply-icon { color: hsl(var(--gh-magenta-end)); }

.gh-pm-apply-ok .gh-pm-apply-icon { color: #22c55e; }
.gh-pm-apply-failed .gh-pm-apply-icon { color: #ef4444; }
.gh-pm-apply-failed { border-color: #ef4444 / 0.55; }

.gh-pm-apply-done {
  margin-bottom: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: hsl(var(--muted) / 0.35);
  border: 1px solid hsl(var(--border));
}

.gh-pm-apply-meta {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.gh-pm-apply-failures {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}

.gh-pm-apply-failures ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

.gh-pm-asana-link {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.85rem;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.gh-pm-asana-link:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
  color: hsl(var(--primary));
}

/* --- Skills modal ------------------------------------------------------- */
.gh-skill-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.gh-skill-modal {
  width: min(720px, 100%);
  max-height: min(86vh, 880px);
  display: flex;
  flex-direction: column;
  background: hsl(var(--card, var(--background)));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}

.gh-skill-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.gh-skill-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.75;
  margin-bottom: 0.5rem;
}

.gh-skill-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

.gh-skill-sub {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.8;
  line-height: 1.5;
}

.gh-skill-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

button.gh-skill-new {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--accent, var(--background)));
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.gh-skill-new:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
}

button.gh-skill-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)));
  cursor: pointer;
  font-size: 0.95rem;
}

button.gh-skill-close:hover {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.gh-skill-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.gh-skill-row {
  border: 1px solid hsl(var(--border));
  border-radius: 0.625rem;
  padding: 0.7rem 0.85rem;
  background: transparent;
  transition: border-color 0.15s ease;
}

.gh-skill-row:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-skill-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.gh-skill-row-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gh-skill-badge {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: hsl(var(--accent, var(--background)));
  color: hsl(var(--muted-foreground, var(--foreground)));
  border: 1px solid hsl(var(--border));
  font-weight: 600;
}

.gh-skill-row-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

button.gh-skill-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  height: 1.85rem;
  padding: 0 0.4rem;
  font-size: 0.7rem;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)));
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

button.gh-skill-action:hover {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
  background: hsl(var(--accent, var(--background)));
}

button.gh-skill-action.gh-skill-action-flash {
  color: hsl(var(--primary));
  border-color: hsl(var(--gh-magenta-end) / 0.5);
}

.gh-skill-row-prompt {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  opacity: 0.85;
  line-height: 1.45;
  white-space: pre-wrap;
}

.gh-skill-confirm {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  color: hsl(var(--foreground));
}

button.gh-skill-confirm-yes,
button.gh-skill-confirm-no {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
}

button.gh-skill-confirm-yes {
  border-color: hsl(0, 70%, 55%);
  color: hsl(0, 70%, 60%);
}

button.gh-skill-confirm-yes:hover {
  background: hsl(0, 70%, 55% / 0.1);
}

.gh-skill-form {
  border: 1px solid hsl(var(--gh-magenta-end) / 0.45);
  border-radius: 0.625rem;
  padding: 0.85rem;
  background: hsl(var(--accent, var(--background)) / 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.gh-skill-form-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
}

.gh-skill-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: hsl(var(--muted-foreground, var(--foreground)));
}

.gh-skill-input,
.gh-skill-textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 400;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.4rem;
  letter-spacing: normal;
  text-transform: none;
}

.gh-skill-textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.45;
}

.gh-skill-input:focus,
.gh-skill-textarea:focus {
  outline: none;
  border-color: hsl(var(--gh-magenta-end) / 0.65);
}

.gh-skill-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

button.gh-skill-cancel,
button.gh-skill-save {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  border-radius: 0.45rem;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  font-weight: 600;
}

button.gh-skill-save {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: transparent;
}

button.gh-skill-save:hover:not(:disabled) {
  filter: brightness(1.08);
}

button.gh-skill-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.gh-skill-cancel:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-skill-error {
  font-size: 0.78rem;
  color: hsl(0, 70%, 60%);
}

.gh-skill-empty,
.gh-skill-loading {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground, var(--foreground)));
  text-align: center;
  padding: 1.5rem;
}

/* Scope toggle (All / Mine) inside the Skills dialog header. */
.gh-skill-scope {
  display: inline-flex;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 0.15rem;
  background: hsl(var(--accent, var(--background)) / 0.4);
}

button.gh-skill-scope-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)));
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  min-width: 3rem;
}

button.gh-skill-scope-btn:hover {
  color: hsl(var(--foreground));
}

button.gh-skill-scope-btn.is-active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Group headers dividing Daily / Weekly / Monthly / Ad-hoc sections. */
.gh-skill-group-header {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.25rem 0.35rem;
  border-bottom: 1px solid hsl(var(--border));
  margin: 0.5rem 0 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: hsl(var(--muted-foreground, var(--foreground)));
}

.gh-skill-group-header:first-child {
  margin-top: 0;
}

.gh-skill-group-label {
  color: hsl(var(--foreground));
}

.gh-skill-group-count {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: hsl(var(--accent, var(--background)));
  border: 1px solid hsl(var(--border));
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

/* Per-row metadata pills (assignee + frequency). */
.gh-skill-row-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.gh-skill-pill {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--accent, var(--background)));
  color: hsl(var(--muted-foreground, var(--foreground)));
}

.gh-skill-pill-brian {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
  color: hsl(var(--gh-magenta-end));
  background: hsl(var(--gh-magenta-end) / 0.08);
}

.gh-skill-pill-taren {
  border-color: hsl(140 55% 50% / 0.55);
  color: hsl(140 55% 48%);
  background: hsl(140 55% 50% / 0.08);
}

.gh-skill-pill-wyatt {
  border-color: hsl(210 75% 55% / 0.55);
  color: hsl(210 75% 55%);
  background: hsl(210 75% 55% / 0.08);
}

.gh-skill-pill-daily {
  border-color: hsl(30 85% 55% / 0.55);
  color: hsl(30 85% 50%);
  background: hsl(30 85% 55% / 0.08);
}

.gh-skill-pill-weekly {
  border-color: hsl(260 65% 65% / 0.55);
  color: hsl(260 65% 60%);
  background: hsl(260 65% 65% / 0.08);
}

.gh-skill-pill-monthly {
  border-color: hsl(190 70% 50% / 0.55);
  color: hsl(190 70% 45%);
  background: hsl(190 70% 50% / 0.08);
}

.gh-skill-pill-adhoc {
  border-color: hsl(var(--border));
  color: hsl(var(--muted-foreground, var(--foreground)));
}

/* Side-by-side Assignee + Frequency selects in the edit form. */
.gh-skill-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@media (max-width: 520px) {
  .gh-skill-form-row {
    grid-template-columns: 1fr;
  }
  .gh-skill-header-actions {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}

select.gh-skill-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1rem 1rem;
}

/* Composer button (next to attach), best-effort placement */
button#gh-skills-composer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)));
  cursor: pointer;
  margin-left: 0.15rem;
  transition: color 0.15s ease, background 0.15s ease;
}

button#gh-skills-composer-button:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent, var(--background)));
}

/* ===== Apps overlay (CRUD-backed bookmarks) ============================== */
.gh-app-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: hsl(var(--background) / 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3.5rem 1rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.gh-app-modal {
  width: 100%;
  max-width: 56rem;
  background: hsl(var(--card, var(--background)));
  border: 1px solid hsl(var(--border, 0 0% 15%));
  border-radius: 0.9rem;
  box-shadow: 0 20px 60px -10px hsl(0 0% 0% / 0.5);
  padding: 1.25rem 1.25rem 1rem;
  color: hsl(var(--foreground));
}

.gh-app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border, 0 0% 90%) / 0.5);
  margin-bottom: 0.9rem;
}

.gh-app-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.75);
}

.gh-app-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.1rem 0 0.25rem;
}

.gh-app-sub {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.75);
  max-width: 40rem;
}

.gh-app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

button.gh-app-new {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 0.45rem;
  border: 1px solid hsl(var(--gh-magenta-end, var(--border)) / 0.6);
  background: hsl(var(--gh-magenta-end, var(--accent)) / 0.12);
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

button.gh-app-new:hover {
  background: hsl(var(--gh-magenta-end, var(--accent)) / 0.22);
  border-color: hsl(var(--gh-magenta-end, var(--accent)) / 0.9);
}

button.gh-app-close {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.45rem;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 0.9rem;
}

button.gh-app-close:hover {
  background: hsl(var(--accent, var(--background)));
}

.gh-app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.6rem;
}

.gh-app-loading,
.gh-app-empty,
.gh-app-error {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.75);
  padding: 2rem 0.5rem;
}

.gh-app-error {
  color: hsl(var(--destructive, 0 70% 55%));
}

.gh-app-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid hsl(var(--border, 0 0% 90%) / 0.7);
  border-radius: 0.75rem;
  background: hsl(var(--background));
  overflow: hidden;
  transition: border-color 0.12s ease, transform 0.12s ease,
    box-shadow 0.12s ease;
}

.gh-app-tile:hover {
  border-color: hsl(var(--gh-magenta-end, var(--accent)) / 0.65);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -8px hsl(0 0% 0% / 0.35);
}

.gh-app-tile-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  height: 100%;
  padding: 0.55rem 0.4rem;
  text-decoration: none;
  color: hsl(var(--foreground));
}

.gh-app-tile-link:hover {
  text-decoration: none;
}

.gh-app-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.45rem;
  background: hsl(var(--muted, var(--background)) / 0.35);
  overflow: hidden;
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.gh-app-tile-icon img {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
}

.gh-app-tile-icon-fallback {
  background: hsl(var(--gh-magenta-end, var(--accent)) / 0.18);
}

.gh-app-tile-label {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.gh-app-tile-actions {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.gh-app-tile:hover .gh-app-tile-actions,
.gh-app-tile:focus-within .gh-app-tile-actions {
  opacity: 1;
}

button.gh-app-action {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.35rem;
  border: 1px solid hsl(var(--border, 0 0% 90%) / 0.8);
  background: hsl(var(--background) / 0.95);
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

button.gh-app-action:hover {
  background: hsl(var(--accent, var(--background)));
  border-color: hsl(var(--gh-magenta-end, var(--border)));
}

button.gh-app-action.gh-app-delete:hover {
  color: hsl(var(--destructive, 0 70% 55%));
  border-color: hsl(var(--destructive, 0 70% 55%) / 0.65);
}

/* --- Inline form (create / edit) --- */
.gh-app-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 0.95rem;
  margin-bottom: 0.9rem;
  border: 1px solid hsl(var(--border, 0 0% 90%));
  border-radius: 0.6rem;
  background: hsl(var(--muted, var(--background)) / 0.25);
}

.gh-app-form-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.gh-app-form-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.85);
}

.gh-app-form-label input {
  font: inherit;
  font-size: 0.85rem;
  color: hsl(var(--foreground));
  padding: 0.45rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid hsl(var(--border, 0 0% 90%));
  background: hsl(var(--background));
}

.gh-app-form-label input:focus {
  outline: none;
  border-color: hsl(var(--gh-magenta-end, var(--accent)) / 0.8);
  box-shadow: 0 0 0 2px hsl(var(--gh-magenta-end, var(--accent)) / 0.18);
}

.gh-app-form-error {
  font-size: 0.75rem;
  color: hsl(var(--destructive, 0 70% 55%));
}

.gh-app-form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

button.gh-app-form-cancel,
button.gh-app-form-save {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid hsl(var(--border, 0 0% 90%));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
}

button.gh-app-form-save {
  border-color: hsl(var(--gh-magenta-end, var(--accent)) / 0.7);
  background: hsl(var(--gh-magenta-end, var(--accent)) / 0.18);
}

button.gh-app-form-save:hover {
  background: hsl(var(--gh-magenta-end, var(--accent)) / 0.28);
}

button.gh-app-form-save[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .gh-app-overlay {
    padding: 2rem 0.65rem 1.25rem;
  }
  .gh-app-modal {
    padding: 1rem 0.95rem 0.85rem;
    border-radius: 0.75rem;
  }
  .gh-app-modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .gh-app-header-actions {
    justify-content: space-between;
  }
  .gh-app-grid {
    grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
    gap: 0.5rem;
  }
  /* On touch devices hover doesn't fire — keep actions visible at low opacity. */
  .gh-app-tile-actions {
    opacity: 0.85;
  }
}

/* ---------------------------------------------------------------------------
   Persona avatar (Rive)
   - Replaces the static assistant avatar on the most recent assistant message.
   - Rive's view-model only exposes one solid color, so we paint the canvas in
     brand magenta and surround it with the duo (gold→magenta) gradient halo.
   - Idle is calm; listening pulses; thinking spins; speaking glows.
   --------------------------------------------------------------------------- */
.gh-persona-wrap {
  --gh-persona-size: 32px;
  position: relative;
  display: inline-block;
  width: var(--gh-persona-size);
  height: var(--gh-persona-size);
  border-radius: 50%;
  isolation: isolate;
  vertical-align: middle;
  overflow: visible;
}

.gh-persona-halo {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--gh-gradient-duo);
  opacity: 0.55;
  z-index: 0;
  filter: blur(2px);
  transition: opacity 220ms ease, filter 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.gh-persona-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: var(--gh-persona-size);
  height: var(--gh-persona-size);
  border-radius: 50%;
  background: hsl(var(--background));
  box-shadow: 0 0 0 1px hsl(var(--border));
}

.gh-persona-wrap[data-state="idle"] .gh-persona-halo {
  opacity: 0.4;
}

.gh-persona-wrap[data-state="listening"] .gh-persona-halo {
  opacity: 0.85;
  animation: gh-persona-pulse 1400ms ease-in-out infinite;
}

.gh-persona-wrap[data-state="thinking"] .gh-persona-halo {
  opacity: 0.75;
  animation: gh-persona-spin 2400ms linear infinite;
  filter: blur(3px);
}

.gh-persona-wrap[data-state="speaking"] .gh-persona-halo {
  opacity: 1;
  filter: blur(4px);
  animation: gh-persona-glow 900ms ease-in-out infinite alternate;
}

@keyframes gh-persona-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.95;
  }
}

@keyframes gh-persona-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes gh-persona-glow {
  from {
    transform: scale(1);
    opacity: 0.7;
  }
  to {
    transform: scale(1.06);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gh-persona-wrap[data-state="listening"] .gh-persona-halo,
  .gh-persona-wrap[data-state="thinking"] .gh-persona-halo,
  .gh-persona-wrap[data-state="speaking"] .gh-persona-halo {
    animation: none;
  }
}

/* mana variant ships its own native palette — let it speak for itself.
   Drop the gradient halo so we don't tint it with brand colors. */
.gh-persona-wrap[data-variant="mana"] .gh-persona-halo {
  background: hsl(var(--background));
  opacity: 0.25;
  filter: blur(6px);
}
.gh-persona-wrap[data-variant="mana"] .gh-persona-canvas {
  background: transparent;
  box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Voice mode — composer toggle + full voice-mode shell (overlay on composer).
   --------------------------------------------------------------------------- */
.gh-voice-mic-btn {
  position: relative;
}

.gh-voice-mic-btn[data-active="1"] {
  color: hsl(var(--gh-magenta-end));
}

.gh-voice-mic-btn[data-active="1"]::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--gh-gradient-duo);
  opacity: 0.18;
  z-index: -1;
  animation: gh-voice-mic-pulse 1600ms ease-in-out infinite;
  pointer-events: none;
}

@keyframes gh-voice-mic-pulse {
  0%, 100% { opacity: 0.18; transform: scale(1); }
  50%      { opacity: 0.42; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .gh-voice-mic-btn[data-active="1"]::after { animation: none; }
}

/* Shell — swaps in for the composer textarea+send row while voice mode is
   on. Keeps the same height envelope so the page doesn't reflow, but hosts
   the Persona canvas in the middle with contextual buttons flanking it. */
[data-gh-voice="1"] {
  position: relative;
}

[data-gh-voice="1"] textarea,
[data-gh-voice="1"] [role="textbox"],
[data-gh-voice="1"] button[type="submit"] {
  visibility: hidden;
  pointer-events: none;
}

#gh-voice-shell {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--background));
  border-radius: inherit;
}

.gh-voice-shell-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease,
    transform 0.12s ease;
}

.gh-voice-shell-btn:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--gh-magenta-end) / 0.45);
}

.gh-voice-shell-btn:active {
  transform: scale(0.96);
}

.gh-voice-shell-center {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  color: hsl(var(--foreground));
}

.gh-voice-persona-canvas {
  width: 4.5rem;
  height: 4.5rem;
  display: block;
  border-radius: 9999px;
  background: transparent;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.gh-voice-shell-center:hover .gh-voice-persona-canvas {
  transform: scale(1.04);
}

.gh-voice-shell-center:active .gh-voice-persona-canvas {
  transform: scale(0.97);
}

.gh-voice-center-label {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* State-specific accents for the center canvas. */
#gh-voice-shell[data-state="listening"] .gh-voice-persona-canvas {
  filter: drop-shadow(0 0 12px hsl(var(--gh-magenta-end) / 0.5));
}

#gh-voice-shell[data-state="thinking"] .gh-voice-persona-canvas {
  filter: drop-shadow(0 0 10px hsl(var(--foreground) / 0.3));
}

#gh-voice-shell[data-state="speaking"] .gh-voice-persona-canvas {
  filter: drop-shadow(0 0 14px hsl(var(--gh-magenta-end) / 0.6));
}

#gh-voice-shell[data-state="paused"] .gh-voice-persona-canvas {
  opacity: 0.6;
}

@media (max-width: 640px) {
  #gh-voice-shell {
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
  }
  .gh-voice-shell-btn {
    width: 2rem;
    height: 2rem;
  }
  .gh-voice-persona-canvas {
    width: 3.5rem;
    height: 3.5rem;
  }
  .gh-voice-center-label {
    font-size: 0.65rem;
  }
}

/* ---------------------------------------------------------------------------
   New-chat (welcome) screen — scroll + mobile responsiveness

   Chainlit renders #welcome-screen as a flex column with
   `-mt-[60px] flex-grow items-center justify-center`. When the rendered
   content (profile description + starters + injected Quick Links) exceeds
   the viewport, `justify-center` clips top/bottom and there is no scroll.
   On mobile the negative top margin also pushes content under the header,
   and the Quick Links grid cramps at narrow widths.
   --------------------------------------------------------------------------- */
#welcome-screen {
  /* Kill Chainlit's `-mt-[60px]` — the negative margin pulls the icon above
     the parent's top edge, where the parent clips it. Anchor to the top and
     let the parent (mKn) handle overflow scrolling; adding our own
     overflow:auto here fights flex-grow and makes the top of content
     unreachable. */
  margin-top: 0 !important;
  justify-content: flex-start !important;
  /* Don't flex-grow infinitely — let the content define the height so the
     outer scroll container handles overflow. */
  flex-grow: 0 !important;
  min-height: 0;
  padding: 2rem 1rem 1.5rem;
  box-sizing: border-box;
}

/* Logo + welcome-description wrapper: stack vertically with generous space
   between the icon and the greeting, and present the greeting inside a
   neutral card rather than as loose body text. */
#welcome-screen > div:first-child {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  width: 100%;
  max-width: 640px;
}

#welcome-screen > div:first-child > *:not(img) {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  width: 100%;
  box-shadow:
    0 1px 2px 0 hsl(0 0% 0% / 0.04),
    0 1px 3px 0 hsl(0 0% 0% / 0.06);
}

@media (max-width: 767px) {
  #welcome-screen {
    padding: 1.25rem 1rem 1rem;
    /* Reduce the gap slightly so the stack fits tighter on short screens. */
    gap: 0.75rem;
  }

  #welcome-screen > div:first-child {
    margin-bottom: 0.25rem;
    gap: 1.75rem;
  }
  #welcome-screen > div:first-child img {
    width: 3rem !important;
    height: 3rem !important;
  }
  #welcome-screen > div:first-child > *:not(img) {
    padding: 1rem 1.1rem;
  }
}

/* #starters is relocated above the composer on mobile by custom.js.
   Cap its height so starter cards can scroll within their own lane
   instead of pushing the composer off-screen. */
@media (max-width: 767px) {
  #starters {
    max-height: 38vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 0.75rem;
    width: 100%;
  }

  #starters .flex,
  #starters > div {
    flex-wrap: wrap;
  }
}

/* Some iOS browsers mis-calculate 100vh by including the address bar.
   Prefer 100dvh where the app already uses 100vh for full-screen overlays
   so mobile chrome retraction doesn't clip the bottom. */
@supports (height: 100dvh) {
  #gh-perf-overlay iframe {
    height: 100dvh;
  }
}

/* ---------------------------------------------------------------------------
   Markdown responsiveness — README dialog + knowledge preview
   The Chainlit README (opened from the profile menu) and the in-app
   knowledge browser both render GitHub-flavored markdown. Long URLs, code
   blocks, and tables don't wrap by default, forcing horizontal scroll or
   making the surrounding dialog/panel bloat past the mobile viewport.
   --------------------------------------------------------------------------- */

/* Long links in the knowledge preview always wrap — long-form docs with
   bare URLs are common. */
.gh-kb-preview a,
.gh-kb-preview code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.gh-kb-preview table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.gh-kb-preview img,
.gh-kb-preview video {
  max-width: 100%;
  height: auto;
}

@media (max-width: 767px) {
  /* Knowledge overlay — tighten padding so the doc body uses the full
     viewport width, and cap the tree width so it doesn't cover everything
     when opened. */
  .gh-kb-content {
    padding: 3.5rem 1rem 2rem;
  }

  .gh-kb-tree {
    width: min(85vw, 300px);
  }

  .gh-kb-preview {
    max-width: 100%;
  }

  .gh-kb-preview pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Chainlit's rendered markdown (README dialog, message bodies, element
     previews) — force long links / code / tables to wrap-or-scroll rather
     than stretching the surrounding container past the viewport. */
  .markdown-body,
  [class*="markdown-body"],
  [class*="prose"] {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-wrap: break-word;
  }

  .markdown-body a,
  [class*="markdown-body"] a,
  [class*="prose"] a {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .markdown-body pre,
  [class*="markdown-body"] pre,
  [class*="prose"] pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-body table,
  [class*="markdown-body"] table,
  [class*="prose"] table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-body img,
  [class*="markdown-body"] img,
  [class*="prose"] img {
    max-width: 100%;
    height: auto;
  }

  /* README dialog (opened from profile menu) — Chainlit's Radix Dialog
     doesn't size itself to the mobile viewport by default; the bundled
     Tailwind caps at ~600px which overflows on small phones. Narrow any
     centered dialog containing markdown to fit within the visual viewport,
     but SKIP the mobile sidebar Sheet (also a Radix dialog) — it owns its
     own full-height sizing. Heuristic: match dialogs whose descendant is
     a markdown body, not a sidebar shell. */
  [role="dialog"][data-state="open"]:has(.markdown-body),
  [role="dialog"][data-state="open"]:has([class*="markdown-body"]),
  [role="dialog"][data-state="open"]:has([class*="prose"]) {
    max-width: calc(100vw - 1rem);
    width: auto;
    max-height: calc(100dvh - 1.5rem);
    box-sizing: border-box;
    overflow: auto;
  }
}

/* ===== Apps dialog tabs + Software Status tab ============================ */
.gh-app-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border, 0 0% 90%) / 0.45);
  margin: -0.25rem 0 0.85rem;
}

button.gh-app-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.75);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
  margin-bottom: -1px;
}

button.gh-app-tab:hover {
  color: hsl(var(--foreground));
}

button.gh-app-tab.is-active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--gh-magenta-end, var(--accent)));
}

.gh-app-tab-panel[hidden] {
  display: none;
}

.gh-app-tab-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

button.gh-status-refresh-all {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 0.45rem;
  border: 1px solid hsl(var(--border, 0 0% 90%) / 0.6);
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

button.gh-status-refresh-all:hover {
  background: hsl(var(--accent, var(--background)));
}

.gh-status-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gh-status-group-header {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.6);
  padding: 0.75rem 0 0.3rem;
  border-bottom: 1px dashed hsl(var(--border, 0 0% 90%) / 0.4);
  margin-bottom: 0.1rem;
}

.gh-status-group-header:first-child {
  padding-top: 0.1rem;
}

.gh-status-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid hsl(var(--border, 0 0% 90%) / 0.55);
  border-radius: 0.55rem;
  background: hsl(var(--background) / 0.5);
}

.gh-status-indicator {
  flex: 0 0 0.6rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  background: hsl(0 0% 60%);
  box-shadow: 0 0 0 3px hsl(0 0% 60% / 0.15);
}

.gh-status-row[data-state="ok"] .gh-status-indicator {
  background: hsl(140 65% 45%);
  box-shadow: 0 0 0 3px hsl(140 65% 45% / 0.2);
}

.gh-status-row[data-state="error"] .gh-status-indicator {
  background: hsl(0 72% 55%);
  box-shadow: 0 0 0 3px hsl(0 72% 55% / 0.2);
}

.gh-status-row[data-state="not_configured"] .gh-status-indicator {
  background: hsl(0 0% 45%);
  box-shadow: 0 0 0 3px hsl(0 0% 45% / 0.15);
}

.gh-status-row[data-state="checking"] .gh-status-indicator {
  background: hsl(210 80% 55%);
  box-shadow: 0 0 0 3px hsl(210 80% 55% / 0.2);
  animation: gh-status-pulse 1.1s ease-in-out infinite;
}

.gh-status-row[data-state="pending"] .gh-status-indicator {
  background: hsl(45 80% 55%);
  box-shadow: 0 0 0 3px hsl(45 80% 55% / 0.2);
}

@keyframes gh-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.gh-status-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.gh-status-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.gh-status-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.7);
}

.gh-status-state {
  font-weight: 500;
}

.gh-status-row[data-state="ok"] .gh-status-state { color: hsl(140 55% 42%); }
.gh-status-row[data-state="error"] .gh-status-state { color: hsl(0 72% 55%); }
.gh-status-row[data-state="not_configured"] .gh-status-state,
.gh-status-row[data-state="pending"] .gh-status-state {
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.7);
}

.gh-status-latency {
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.65);
}

.gh-status-env {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.55);
}

.gh-status-error {
  font-size: 0.75rem;
  color: hsl(0 72% 55%);
  background: hsl(0 72% 55% / 0.08);
  border: 1px solid hsl(0 72% 55% / 0.25);
  border-radius: 0.4rem;
  padding: 0.35rem 0.5rem;
  word-break: break-word;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 0.15rem;
}

.gh-status-note {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.7);
  margin-top: 0.15rem;
}

button.gh-status-refresh {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.4rem;
  border: 1px solid hsl(var(--border, 0 0% 90%) / 0.6);
  background: transparent;
  color: hsl(var(--muted-foreground, var(--foreground)) / 0.8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

button.gh-status-refresh:hover {
  background: hsl(var(--accent, var(--background)));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border, 0 0% 90%));
}

button.gh-status-refresh[disabled] {
  opacity: 0.5;
  cursor: wait;
}

.gh-status-row[data-state="checking"] button.gh-status-refresh svg {
  animation: gh-status-spin 0.9s linear infinite;
}

@keyframes gh-status-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 520px) {
  .gh-status-row { padding: 0.55rem; gap: 0.55rem; }
  .gh-status-env { display: none; }
}

/* --- CoT header: command persona + shimmered active-step heading -------- */
/* The chain_of_thought.jsx CustomElement renders the command-variant Rive
   persona next to a dynamic heading that shows the active step's label.
   While the run is active, the heading shimmers (moving gradient through
   text). When complete, it falls back to the static title.                 */
.gh-cot-persona {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.gh-cot-persona canvas {
  width: 24px;
  height: 24px;
  display: block;
}

.gh-cot-persona-fallback {
  position: absolute;
  inset: 0;
  margin: auto;
  color: hsl(var(--muted-foreground, var(--foreground) / 0.6));
}

.gh-cot-persona-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  background: hsl(var(--background));
  border-radius: 999px;
  padding: 1px;
}

.gh-cot-shimmer {
  background: linear-gradient(
    90deg,
    hsl(var(--muted-foreground, var(--foreground) / 0.45)) 0%,
    hsl(var(--muted-foreground, var(--foreground) / 0.45)) 35%,
    hsl(var(--foreground)) 50%,
    hsl(var(--muted-foreground, var(--foreground) / 0.45)) 65%,
    hsl(var(--muted-foreground, var(--foreground) / 0.45)) 100%
  );
  background-size: 220% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: gh-cot-shimmer 2.4s linear infinite;
  font-weight: 500;
}

@keyframes gh-cot-shimmer {
  0%   { background-position: 120% 50%; }
  100% { background-position: -20% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .gh-cot-shimmer { animation: none; }
}

/* Ticker chip — brief pulse on value change so the user feels the number
   tick up instead of just seeing it mutate silently. */
.gh-cot-ticker-chip {
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.gh-cot-ticker-pulse {
  animation: gh-cot-ticker-pulse 520ms ease-out;
}

@keyframes gh-cot-ticker-pulse {
  0% {
    background-color: hsl(var(--primary) / 0.25);
    border-color: hsl(var(--primary) / 0.6);
    transform: translateY(-1px) scale(1.04);
  }
  60% {
    background-color: hsl(var(--primary) / 0.12);
    border-color: hsl(var(--primary) / 0.35);
  }
  100% {
    background-color: hsl(var(--muted) / 0.4);
    border-color: hsl(var(--border) / 0.6);
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gh-cot-ticker-pulse { animation: none; }
}

/* =========================================================
   Turn-level layout cohesion
   ---------------------------------------------------------
   A single assistant turn can emit three stacked blocks:
     1. Chain of Thought   (.gh-cot)         inside a cl.Message
     2. Artifacts          (.gh-artifacts)   inside one or more cl.Messages
     3. Final reply text   (pure markdown)   inside a cl.Message
   Chainlit renders each as its own message. Without explicit
   rules the three crowd one another because each wrapper sets
   its own internal spacing. The rules below give them a shared
   rhythm and matching left alignment so they read as one turn. */

/* 1. Width alignment: CoT and artifacts span the full message
      column (same width as the assistant's text bubble) instead
      of being pinned to the narrower prose measure. */
.gh-cot,
.gh-artifacts {
  width: 100%;
  max-width: none;
}

.gh-artifacts-body {
  max-width: none;
}

/* 2. Vertical rhythm: give every Crescent-authored custom-element
      message a consistent bottom gap so CoT → artifacts → reply
      never visually collide. The selector targets Chainlit's
      message wrapper when it contains one of our custom roots. */
.gh-cot,
.gh-artifacts {
  margin: 0.25rem 0 1rem;
}

/* 3. Artifact body breathing room. Individual specs (cards, charts,
      tables) set their own internal padding, but the expanded body
      needs a small top offset from the header and a little end-cap
      so the collapse animation doesn't feel abrupt. */
.gh-artifacts-body {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

/* 4. Responsive: on narrow screens allow the artifact body to use
      the full available width, and let wide specs (tables/charts)
      scroll horizontally within their own container rather than
      pushing the chat column out. */
@media (max-width: 640px) {
  .gh-cot,
  .gh-artifacts {
    max-width: 100%;
  }
  .gh-artifacts-body > * {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* 5. Hover affordance for the artifact collapsible header icon,
      matching the muted→foreground transition used by CoT. */
.gh-artifacts > button:hover .gh-artifacts-icon {
  border-color: hsl(var(--foreground) / 0.35);
}

/* 6. Chainlit renders the copy/actions toolbar inside .ai-message
      right below the message content. When an artifacts-only cl.Message
      follows the final text reply, the artifacts step crowds the text
      step's toolbar and the copy button visually disappears. Push the
      artifacts step down a half-line so the copy button above it has
      room. */
[id^="step-"]:has(> .ai-message .gh-artifacts) {
  margin-top: 0.5rem;
}

/* 7. Bare-div specs (SectionSpec, ActionButtonsSpec) have no border of
      their own, so when they sit directly above/below a bordered
      <Card> spec they read as touching. Give the action buttons row a
      hair of vertical padding so the top/bottom edges of its buttons
      don't kiss neighboring content. */
.gh-artifacts-body > .gh-artifact-actions {
  padding-block: 0.125rem;
}

/* =========================================================
   Chat surfaces — brand-tinted gradients
   ---------------------------------------------------------
   Chainlit applies `bg-accent dark:bg-card` to #message-composer
   and plain `bg-accent` to the user-message bubble. That gives us
   gold in light mode (everywhere) and a magenta-tinted card in the
   composer in dark mode. We want:
     • Composer: magenta-tinted in both modes (dark mode already
       looks right, so we only restyle light mode).
     • User bubble: gold-tinted in both modes.
   Text color falls back to --foreground which is already tuned for
   contrast in each theme, but we pin it explicitly so the gradient
   can never reduce legibility. ID / attribute selectors give us
   enough specificity to override Tailwind's class-level background
   without !important. */

/* Composer — light mode: soft magenta tint over the page background */
html:not(.dark) #message-composer {
  background:
    linear-gradient(
      135deg,
      hsl(var(--gh-magenta-start) / 0.10) 0%,
      hsl(var(--gh-magenta-end) / 0.14) 100%
    ),
    hsl(var(--background));
  border: 1px solid hsl(var(--gh-magenta-end) / 0.18);
  color: hsl(var(--foreground));
}
html:not(.dark) #message-composer textarea,
html:not(.dark) #message-composer input {
  color: hsl(var(--foreground));
}
html:not(.dark) #message-composer textarea::placeholder,
html:not(.dark) #message-composer input::placeholder {
  color: hsl(var(--muted-foreground));
}

/* User message bubble — both modes: brand-gold tint.
   Chainlit applies rounded-3xl + bg-accent to the bubble; scoping by
   [data-step-type="user_message"] ensures we never restyle assistant
   bubbles or the composer edit-mode inner .bg-accent. */
[data-step-type="user_message"] div.rounded-3xl {
  color: hsl(var(--foreground));
}

html:not(.dark) [data-step-type="user_message"] div.rounded-3xl {
  background:
    linear-gradient(
      135deg,
      hsl(var(--gh-gold-start) / 0.22) 0%,
      hsl(var(--gh-gold-end) / 0.32) 100%
    ),
    hsl(var(--background));
  border: 1px solid hsl(var(--gh-gold-start) / 0.30);
}

html.dark [data-step-type="user_message"] div.rounded-3xl {
  background:
    linear-gradient(
      135deg,
      hsl(var(--gh-gold-start) / 0.18) 0%,
      hsl(var(--gh-gold-end) / 0.24) 100%
    ),
    hsl(var(--card));
  border: 1px solid hsl(var(--gh-gold-end) / 0.25);
}

/* =========================================================
   Artifact spec accents — brand magenta + gold gradients
   ---------------------------------------------------------
   Each rule below only touches surfaces that don't carry body
   text, or restyles text that reads fine against the brand hues
   in both themes. No text color is tinted over a competing
   gradient — foreground stays on --foreground so legibility
   never regresses. */

/* KPI cards — thin magenta gradient stripe across the top edge
   and a gradient-text treatment for the hero metric value. The
   value is set in a saturated fuchsia→magenta range that holds
   contrast on both light (near-white) and dark (deep burgundy)
   card backgrounds. */
.gh-kpi-card {
  position: relative;
  overflow: hidden;
}
.gh-kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--gh-gradient-primary);
  pointer-events: none;
}
.gh-kpi-value {
  background: var(--gh-gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Section headers — magenta→gold duo gradient text. Matches the
   welcome-screen wordmark treatment so section dividers feel like
   brand beats rather than plain subheads. Font-weight bumped to
   700 so the gradient fill stays readable at -lg sizes. */
.gh-section-title {
  background: var(--gh-gradient-duo);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

/* Progress bar — fill the indicator with the magenta gradient.
   shadcn's Progress renders a child element that shifts translateX
   to represent completion; we recolor whichever child is inside. */
.gh-progress-bar > * {
  background: var(--gh-gradient-primary) !important;
}

/* Timeline rail — replace shadcn's muted 1px left border with a
   slightly wider gold-tinted accent line. The event dots keep
   their semantic variant colors (success/warning/error/info) so
   status reads stay clear against the warm brand rail. */
.gh-timeline-rail {
  border-left-width: 2px;
  border-left-color: hsl(var(--gh-gold-start) / 0.55);
}

/* Action suggestion chips — brand-magenta hover affordance. Idle
   state keeps shadcn's secondary styling (so chips read as neutral
   suggestions); hover brightens the border and nudges text toward
   magenta to signal the chip will post back to the agent. */
.gh-artifact-action-chip {
  transition: border-color 0.15s ease, color 0.15s ease,
              background-color 0.15s ease, box-shadow 0.15s ease;
}
.gh-artifact-action-chip:hover {
  border-color: hsl(var(--gh-magenta-end) / 0.55);
  color: hsl(var(--gh-magenta-end));
  box-shadow: 0 0 0 1px hsl(var(--gh-magenta-end) / 0.18);
}
