/* ============================================================
   ChatHaiku Support — shared stylesheet
   ============================================================
   Palette is lifted verbatim from ui/css/styles.css so the UI
   replicas on these pages match the product exactly. If the app
   palette changes, change it here too — these are intentionally
   duplicated rather than imported, because the app stylesheet is
   119KB and carries layout rules that would fight the docs shell.
   ============================================================ */

:root {
  /* Tells the browser this page is dark, so UA-rendered chrome —
     scrollbars, form controls, focus rings — is drawn dark to match.
     Without this, Chrome renders light scrollbars over a dark page
     no matter what background-color says, and the sidebar's nested
     scroller ends up looking nothing like the root one. */
  color-scheme: dark;

  /* DARK (default) — mirrors the app */
  --bg-main: #131314;
  --bg-panel: #0d0d0d;
  --bg-bubble-bot: #131314;
  --bg-bubble-user: #282a2c;
  --bg-input: rgba(19, 19, 20, 0.85);
  --bg-input-focus: #1e1f20;

  --text-main: #f2f2f2;
  --text-soft: #8f8f95;
  --text-bot: #e8e8e8;

  --border-main: #1e1f20;
  --accent: #bfbfbf;

  /* Docs-only additions. The brand arc (cyan -> purple -> pink) is
     the same one used by the generating shimmer and avatar ring. */
  --brand-cyan: #7cd3ff;
  --brand-purple: #c68bff;
  --brand-pink: #ff81cc;
  --brand-grad: linear-gradient(100deg, var(--brand-cyan), var(--brand-purple), var(--brand-pink));

  --docs-sidebar-w: 268px;
  --docs-max: 780px;
  --radius: 10px;
}

body.light {
  color-scheme: light;

  --bg-main: #f6f7fb;
  --bg-panel: #ffffff;
  --bg-bubble-bot: #f6f7fb;
  --bg-bubble-user: #6366f1;
  --bg-input: rgba(246, 247, 251, 0.85);
  --bg-input-focus: #d1d5db;

  --text-main: #111827;
  --text-soft: #6b7280;
  --text-bot: #1f2937;

  --border-main: #d1d5db;
  --accent: #6366f1;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-main); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   TOP BAR
   ============================================================ */

.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg-main) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-main);
}

.docs-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  white-space: nowrap;
}
.docs-brand:hover { text-decoration: none; }
.docs-brand .mini { font-weight: 400; color: var(--text-soft); }
.docs-brand .haiku {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.docs-brand-sep {
  color: var(--text-soft);
  opacity: 0.5;
  font-weight: 300;
  margin: 0 2px;
}
.docs-brand-label {
  font-size: 13px;
  color: var(--text-soft);
  letter-spacing: 0.3px;
}

.docs-topbar-spacer { flex: 1; }

.docs-topbar-link {
  font-size: 13px;
  color: var(--text-soft);
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}
.docs-topbar-link:hover {
  text-decoration: none;
  color: var(--text-main);
  background: color-mix(in srgb, var(--text-soft) 12%, transparent);
}

.docs-menu-btn {
  display: none;
  appearance: none;
  border: 1px solid var(--border-main);
  background: transparent;
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.docs-shell {
  display: flex;
  align-items: flex-start;
  max-width: 1240px;
  margin: 0 auto;
}

.docs-sidebar {
  position: sticky;
  top: 56px;
  flex: 0 0 var(--docs-sidebar-w);
  width: var(--docs-sidebar-w);
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 26px 14px 60px 20px;
  border-right: 1px solid var(--border-main);
  /* No scrollbar styling here on purpose. The sidebar scroller should
     look exactly like the page scroller, and both are drawn by the
     browser from `color-scheme` above. Any rule here would apply to
     the sidebar only and reintroduce the mismatch. */
}

.docs-nav-group { margin-bottom: 22px; }
.docs-nav-title {
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 0 10px 8px;
  font-weight: 600;
}
.docs-nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.4;
}
.docs-nav-link:hover {
  text-decoration: none;
  color: var(--text-main);
  background: color-mix(in srgb, var(--text-soft) 10%, transparent);
}
.docs-nav-link.active {
  color: var(--text-main);
  font-weight: 500;
  background: color-mix(in srgb, var(--text-soft) 14%, transparent);
}

.docs-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 40px 40px 100px;
}
.docs-article { max-width: var(--docs-max); }

/* ============================================================
   TYPE
   ============================================================ */

.docs-eyebrow {
  font-size: 11px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 10px;
}

.docs-article h1 {
  font-size: 33px;
  line-height: 1.2;
  letter-spacing: -0.8px;
  font-weight: 600;
  margin: 0 0 14px;
}
.docs-lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 34px;
}
.docs-article h2 {
  font-size: 21px;
  letter-spacing: -0.3px;
  font-weight: 600;
  margin: 46px 0 12px;
  padding-top: 6px;
  scroll-margin-top: 76px;
}
.docs-article h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 30px 0 8px;
  scroll-margin-top: 76px;
}
.docs-article p { margin: 0 0 14px; color: var(--text-bot); }
.docs-article ul, .docs-article ol { margin: 0 0 16px; padding-left: 22px; }
.docs-article li { margin-bottom: 7px; color: var(--text-bot); }
.docs-article strong { color: var(--text-main); font-weight: 600; }

kbd {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-main);
  border-bottom-width: 2px;
  background: color-mix(in srgb, var(--text-soft) 12%, transparent);
  color: var(--text-main);
  white-space: nowrap;
}

code:not(pre code) {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--text-soft) 14%, transparent);
  color: var(--text-main);
}

.docs-hr {
  border: 0;
  border-top: 1px solid var(--border-main);
  margin: 46px 0;
}

/* ============================================================
   CALLOUTS
   ============================================================ */

.docs-note {
  border: 1px solid var(--border-main);
  border-left: 3px solid var(--text-soft);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 22px 0;
  background: color-mix(in srgb, var(--text-soft) 6%, transparent);
}
.docs-note p:last-child { margin-bottom: 0; }
.docs-note-title {
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}
.docs-note.tip { border-left-color: var(--brand-cyan); }
.docs-note.warn { border-left-color: var(--brand-pink); }
.docs-note.privacy { border-left-color: var(--brand-purple); }

/* ============================================================
   TABLES
   ============================================================ */

.docs-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  margin: 22px 0;
}
.docs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.docs-table th, .docs-table td {
  text-align: left;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border-main);
  vertical-align: top;
}
.docs-table th {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 600;
  background: color-mix(in srgb, var(--text-soft) 7%, transparent);
}
.docs-table tr:last-child td { border-bottom: none; }
.docs-table td.soft { color: var(--text-soft); }

/* ============================================================
   HUB CARDS
   ============================================================ */

.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin: 26px 0;
}
.docs-card {
  display: block;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.docs-card:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--brand-purple) 45%, var(--border-main));
  transform: translateY(-2px);
}
.docs-card-title { font-weight: 600; font-size: 15px; margin-bottom: 5px; }
.docs-card-desc { font-size: 13px; color: var(--text-soft); line-height: 1.55; }

/* ============================================================
   NEXT / PREV
   ============================================================ */

.docs-pager {
  display: flex;
  gap: 12px;
  margin-top: 60px;
  padding-top: 26px;
  border-top: 1px solid var(--border-main);
}
.docs-pager a {
  flex: 1;
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  padding: 13px 16px;
}
.docs-pager a:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--brand-purple) 45%, var(--border-main));
}
.docs-pager .dir {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-soft);
  display: block;
  margin-bottom: 3px;
}
.docs-pager .next { text-align: right; }

/* ============================================================
   UI REPLICAS
   ============================================================
   These reproduce real product surfaces using the app's own
   palette and geometry. They are static and non-interactive
   except where noted; the point is that they can't drift out
   of date the way a screenshot does.
   ============================================================ */

.ui-demo {
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  background: var(--bg-main);
  padding: 20px;
  margin: 22px 0;
  overflow-x: auto;
}
.ui-demo-label {
  font-size: 10.5px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 14px;
  font-weight: 600;
}
.ui-demo-caption {
  font-size: 12.5px;
  color: var(--text-soft);
  margin-top: 14px;
  line-height: 1.55;
}

/* --- message bubbles --- */
.ui-chat { display: flex; flex-direction: column; gap: 10px; }
.ui-msg {
  max-width: 78%;
  padding: 10px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
}
.ui-msg-user {
  align-self: flex-end;
  background: var(--bg-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ui-msg-bot {
  align-self: flex-start;
  background: transparent;
  color: var(--text-bot);
  padding-left: 0;
}
.ui-bot-row { display: flex; gap: 12px; align-items: flex-start; }
.ui-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text-soft) 22%, transparent);
  position: relative;
}
.ui-avatar.ring::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 240deg,
    rgba(124,211,255,0.45) 285deg, rgba(198,139,255,0.9) 325deg,
    rgba(255,129,204,0.65) 355deg, transparent 360deg);
  animation: ui-ring-spin 1.4s linear infinite;
}
@keyframes ui-ring-spin { to { transform: rotate(360deg); } }

/* --- action row --- */
.ui-actions { display: flex; gap: 4px; align-items: center; margin-top: 6px; }
.ui-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-main);
  opacity: 0.55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.ui-icon-btn svg { width: 15px; height: 15px; }
.ui-icon-btn.on { opacity: 1; color: var(--brand-purple); }
.ui-retry-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.5;
  padding: 4px 8px;
}
.ui-retry-pill svg { width: 14px; height: 14px; }

/* --- disclosure rows --- */
.ui-disclosure {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}
.ui-disclosure .caret { font-size: 11px; }
.ui-source-panel {
  margin-top: 7px;
  padding-left: 10px;
  border-left: 1px solid var(--accent);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}
.ui-source-summary { opacity: 0.8; margin-bottom: 6px; }
.ui-source-item { display: flex; flex-wrap: wrap; gap: 7px; align-items: baseline; margin-bottom: 5px; }
.ui-chip {
  font-size: 10px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-main);
  color: var(--text-soft);
}

/* --- settings rows --- */
.ui-settings {
  border: 1px solid var(--border-main);
  border-radius: 14px;
  background: var(--bg-panel);
  overflow: hidden;
}
.ui-settings-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-main);
  font-weight: 600;
  font-size: 15px;
}
.ui-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-main);
}
.ui-row:last-child { border-bottom: none; }
.ui-row-label { flex: 1; min-width: 0; }
.ui-row-title { font-size: 14px; font-weight: 500; }
.ui-row-title .exp {
  font-size: 9.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-main);
  color: var(--text-soft);
  margin-left: 7px;
  vertical-align: middle;
}
.ui-row-sub { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; margin-top: 2px; }
.ui-row.sub { padding-left: 34px; }

.ui-switch {
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-soft) 35%, transparent);
  position: relative;
}
.ui-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.ui-switch.on { background: var(--brand-purple); }
.ui-switch.on::after { transform: translateX(16px); }

.ui-pill {
  border: 1px solid var(--border-main);
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  flex-shrink: 0;
}

.ui-seg { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.ui-seg-btn {
  border: 1px solid var(--border-main);
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
}
.ui-seg-btn.on {
  color: var(--text-main);
  border-color: color-mix(in srgb, var(--brand-purple) 55%, var(--border-main));
  background: color-mix(in srgb, var(--brand-purple) 14%, transparent);
}

/* --- menus --- */
.ui-menu {
  border: 1px solid var(--border-main);
  border-radius: 12px;
  background: var(--bg-panel);
  padding: 6px;
  width: 264px;
  max-width: 100%;
}
.ui-menu-header {
  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 8px 10px 5px;
  font-weight: 600;
}
.ui-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
}
.ui-menu-item .meta { margin-left: auto; font-size: 11px; color: var(--text-soft); }
.ui-menu-item.on { background: color-mix(in srgb, var(--text-soft) 14%, transparent); }
.ui-menu-item .sub { display: block; font-size: 11.5px; color: var(--text-soft); }

/* --- composer --- */
.ui-composer {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-main);
  background: var(--bg-input-focus);
  border-radius: 999px;
  padding: 8px 10px 8px 14px;
}
.ui-composer .dots { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; opacity: 0.6; }
.ui-composer .dots i { width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--text-main); display: block; }
.ui-composer .field { flex: 1; color: var(--text-soft); font-size: 14px; }
.ui-composer .btn {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text-soft) 18%, transparent);
  display: inline-flex; align-items: center; justify-content: center;
}
.ui-composer .btn svg { width: 16px; height: 16px; }

/* --- sidebar replica --- */
.ui-sidebar {
  border: 1px solid var(--border-main);
  border-radius: 14px;
  background: var(--bg-panel);
  width: 262px;
  max-width: 100%;
  padding: 12px;
}
.ui-sidebar-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ui-sidebar-item.on { background: color-mix(in srgb, var(--text-soft) 14%, transparent); }
.ui-badge {
  font-size: 9.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-main);
  color: var(--text-soft);
  flex: 0 0 auto;
}

/* --- toast --- */
.ui-toast {
  display: inline-block;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  color: var(--text-main);
}

/* --- two-up --- */
.ui-split { display: flex; gap: 16px; flex-wrap: wrap; }
.ui-split > * { flex: 1 1 260px; min-width: 0; }

/* ============================================================
   FAQ
   ============================================================ */

.faq-item {
  border-bottom: 1px solid var(--border-main);
  padding: 4px 0;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 500;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: "+";
  color: var(--text-soft);
  font-weight: 400;
  flex: 0 0 auto;
  width: 14px;
}
.faq-item[open] summary::before { content: "\2212"; }
.faq-body { padding: 0 0 14px 24px; }
.faq-body p:last-child { margin-bottom: 0; }

/* ============================================================
   FOOTER
   ============================================================ */

.docs-footer {
  border-top: 1px solid var(--border-main);
  padding: 26px 40px 50px;
  color: var(--text-soft);
  font-size: 12.5px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin: 0 auto;
}
.docs-footer a { color: var(--text-soft); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .docs-menu-btn { display: inline-flex; }
  .docs-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    height: auto;
    background: var(--bg-panel);
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--border-main);
  }
  body.nav-open .docs-sidebar { transform: none; }
  body.nav-open .docs-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .docs-scrim {
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 44;
  }
  .docs-main { padding: 28px 20px 80px; }
  .docs-article h1 { font-size: 27px; }
  .docs-footer { padding: 24px 20px 44px; }
  .ui-msg { max-width: 92%; }
}

@media (min-width: 901px) { .docs-scrim { display: none; } }