/* Holabi — component styles. Colours, spacing, radii, layout and motion all come from tokens.css. */
body { margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 24px; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

/* Utilities --------------------------------------------------------------- */
.hb-icon { display: inline-block; flex: none; width: 20px; height: 20px; vertical-align: middle; }
.hb-scroll { overflow: auto; overscroll-behavior: contain; scrollbar-width: none; }
.hb-scroll::-webkit-scrollbar { display: none; }

/* Theme pairs (previews and docs): the same markup in Kintsugi and Sumi --- */
.hb-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hb-duo--stack { grid-template-columns: minmax(0, 1fr); }
.hb-duo__panel { position: relative; min-width: 0; padding: var(--space-7) var(--space-5) var(--space-5); background: var(--bg); color: var(--ink); }
.hb-duo__label { position: absolute; top: var(--space-4); left: var(--space-5); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-subtle); }

/* Logo and isotype ------------------------------------------------------ */
.hb-logo { display: block; height: 48px; width: auto; overflow: visible; }
.hb-enso { display: block; width: 48px; height: 48px; overflow: visible; }
.hb-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); padding: var(--space-5); }
.hb-tile { box-sizing: border-box; position: relative; display: grid; place-items: center; min-height: 176px; padding: var(--space-6) var(--space-5) var(--space-7); border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.hb-tile--surface { background: var(--surface); }
.hb-tile--clay { background: var(--clay); border-color: transparent; }
.hb-tile .hb-logo { height: 40px; }
.hb-tile .hb-enso { width: 80px; height: 80px; }
.hb-tile__cap { position: absolute; left: var(--space-4); bottom: var(--space-3); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-tile--clay .hb-tile__cap { color: var(--on-clay); }
.hb-signature { display: grid; justify-items: center; gap: var(--space-3); }
.hb-signature .hb-logo { height: 40px; }
.hb-signature__tag { margin: 0; font-size: 13px; line-height: 18px; letter-spacing: .01em; color: var(--ink-muted); }
.hb-usage { display: grid; gap: var(--space-6); }
.hb-usage__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-6); }
.hb-usage figure { margin: 0; display: grid; gap: var(--space-2); justify-items: start; }
.hb-usage figcaption { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-clear { padding: 39px; background: var(--surface); outline: 1px dashed var(--line-strong); }
.hb-clear .hb-logo { height: 56px; }
.hb-dont { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.hb-dont__item { display: grid; gap: var(--space-2); min-width: 0; }
.hb-dont__art { display: grid; place-items: center; height: 104px; overflow: hidden; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); }
.hb-dont__art .hb-logo { height: 26px; }
.hb-dont__type { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; letter-spacing: -0.035em; font-variation-settings: 'opsz' 12; }
.hb-dont__cap { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-dont__cap .hb-icon { width: 16px; height: 16px; color: var(--danger); }

/* Agent state: the ensō breathes, draws itself or pulses ---------------- */
.hb-agent { display: inline-flex; flex: none; width: 40px; height: 40px; align-items: center; justify-content: center; }
.hb-agent .hb-enso { width: 100%; height: 100%; }
.hb-agent .hb-enso__ink { transform-box: fill-box; transform-origin: 50% 50%; }
.hb-agent .hb-enso__spine { stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.hb-agent[data-state="listening"] .hb-enso__ink { animation: hb-breath var(--duration-breath) var(--ease-in-out) infinite; }
.hb-agent[data-state="thinking"] .hb-enso__spine { animation: hb-draw var(--duration-think) var(--ease-brush) infinite; }
.hb-agent[data-state="speaking"] .hb-enso__ink { animation: hb-speak var(--duration-speak) var(--ease-out) infinite; }
@keyframes hb-breath { 0%, 100% { transform: scale(.93); opacity: .82; } 50% { transform: scale(1); opacity: 1; } }
@keyframes hb-draw { 0% { stroke-dashoffset: 1; opacity: 1; } 62% { stroke-dashoffset: 0; opacity: 1; } 82% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes hb-speak { 0%, 100% { transform: scale(1); } 18% { transform: scale(1.08); } 36% { transform: scale(.98); } 56% { transform: scale(1.05); } 76% { transform: scale(.995); } }

/* Brush-writing animation ----------------------------------------------- */
.hb-write { position: relative; text-align: center; }
.hb-write__svg { display: block; width: 100%; height: auto; overflow: visible; }
.hb-write__tag { margin: var(--space-4) 0 0; font-family: var(--font-sans); font-size: 15px; line-height: 22px; color: var(--ink-muted); opacity: 0; }
.hb-brush__handle { fill: var(--clay); }
.hb-brush__ferrule { fill: var(--gold); }
.hb-brush__hair { fill: var(--ink); }
.hb-brush__hair--gold { fill: var(--gold-mark); }

/* App shell: sidebar (Operar / Construir / Gobernar), top bar, page ----- */
.hb-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 560px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg); color: var(--ink); }
.hb-side { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) var(--space-3); background: var(--surface); border-right: 1px solid var(--line); scrollbar-width: none; }
.hb-side__brand { padding: var(--space-1) var(--space-2) var(--space-2); }
.hb-side__brand .hb-logo { height: 22px; }
.hb-ws { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: 40px; padding: 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer; }
.hb-ws:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-ws__mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--clay); color: var(--on-clay); font-size: 12px; line-height: 16px; }
.hb-ws > .hb-icon:last-child { margin-left: auto; width: 16px; height: 16px; color: var(--ink-muted); }
.hb-nav { display: grid; gap: 2px; }
.hb-nav__group { padding: var(--space-3) var(--space-3) var(--space-1); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-subtle); }
.hb-nav__item { display: flex; align-items: center; gap: var(--space-3); height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-md); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink-muted); text-decoration: none; }
.hb-nav__item .hb-icon { width: 18px; height: 18px; }
.hb-nav__item:hover { background: var(--surface-alt); color: var(--ink); }
.hb-nav__item[aria-current="page"] { background: var(--clay-soft); color: var(--clay); }
.hb-nav__item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-nav__count { margin-left: auto; box-sizing: border-box; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--clay); color: var(--on-clay); font-size: 12px; line-height: 20px; text-align: center; }
.hb-side__foot { margin-top: auto; display: grid; gap: var(--space-2); }
.hb-credits { padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.hb-credits b { display: block; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.hb-meter { height: 4px; margin-top: var(--space-2); overflow: hidden; border-radius: 2px; background: var(--surface-alt); }
.hb-meter > span { display: block; height: 100%; border-radius: 2px; background: var(--clay); }
.hb-main { display: flex; flex-direction: column; min-width: 0; container: hb-main / inline-size; }
.hb-top { display: flex; align-items: center; gap: var(--space-3); height: var(--topbar-height); padding: 0 var(--space-5); border-bottom: 1px solid var(--line); }
.hb-top .hb-search { flex: 1; max-width: 360px; }
.hb-top__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.hb-content { flex: 1; padding: var(--space-5); scrollbar-width: none; }
.hb-page { display: grid; gap: var(--space-5); width: 100%; max-width: min(var(--content-max), 70%); margin-inline: auto; }
@container hb-main (max-width: 900px) { .hb-page { max-width: 100%; } }
.hb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }

/* Mobile: phone frame and bottom tab bar ------------------------------- */
.hb-phone { box-sizing: border-box; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 320px; height: 580px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 36px; background: var(--bg); color: var(--ink); }
.hb-phone__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-5) var(--space-4) var(--space-3); }
.hb-phone__bar .hb-logo { height: 20px; }
.hb-phone__body { display: grid; align-content: start; gap: var(--space-3); padding: 0 var(--space-3) var(--space-3); }
.hb-tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: var(--space-2) var(--space-1) var(--space-4); background: var(--surface); border-top: 1px solid var(--line); }
.hb-tabbar__item { display: grid; justify-items: center; gap: 2px; padding: var(--space-1) 0; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); text-decoration: none; }
.hb-tabbar__item .hb-icon { width: 22px; height: 22px; }
.hb-tabbar__item[aria-current="page"] { color: var(--clay); }
.hb-tabbar__item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; border-radius: var(--radius-md); }

/* Page header and tabs --------------------------------------------------- */
.hb-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.hb-pagehead__crumbs { display: flex; align-items: center; gap: var(--space-1); margin: 0 0 var(--space-2); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-subtle); }
.hb-pagehead__crumbs a { color: inherit; text-decoration: none; }
.hb-pagehead__crumbs .hb-icon { width: 14px; height: 14px; }
.hb-pagehead__title { margin: 0; font-family: var(--font-display); font-size: 28px; line-height: 32px; font-weight: 700; letter-spacing: -0.03em; font-variation-settings: 'opsz' 12; color: var(--ink); }
.hb-pagehead__desc { margin: var(--space-1) 0 0; max-width: 560px; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-pagehead__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hb-tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.hb-tab { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; border: 0; background: none; font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink-muted); white-space: nowrap; cursor: pointer; }
.hb-tab:hover { color: var(--ink); }
.hb-tab[aria-selected="true"] { color: var(--ink); }
.hb-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--clay); }
.hb-tab:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.hb-tab__count { padding: 0 6px; border-radius: var(--radius-full); background: var(--surface-alt); font-size: 12px; line-height: 18px; color: var(--ink-muted); }
.hb-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-alt); }
.hb-seg__item { height: 32px; padding: 0 var(--space-3); border: 0; border-radius: 8px; background: transparent; font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink-muted); cursor: pointer; }
.hb-seg__item[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.hb-seg__item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* Empty state ------------------------------------------------------------ */
.hb-empty { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-7) var(--space-5); text-align: center; }
.hb-empty .hb-agent { margin-bottom: var(--space-2); }
.hb-empty__title { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: 'opsz' 12; }
.hb-empty__text { margin: 0; max-width: 380px; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }

/* Metric card ------------------------------------------------------------ */
.hb-metric { display: grid; gap: var(--space-2); min-width: 0; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.hb-metric__label { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink-muted); }
.hb-metric__label .hb-icon { width: 18px; height: 18px; }
.hb-metric__value { font-family: var(--font-display); font-size: 32px; line-height: 36px; font-weight: 700; letter-spacing: -0.03em; font-variation-settings: 'opsz' 12; font-variant-numeric: tabular-nums; color: var(--ink); }
.hb-metric__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: 12px; line-height: 16px; color: var(--ink-subtle); }
.hb-spark { width: 88px; height: 28px; overflow: visible; }
.hb-spark path { fill: none; stroke: var(--clay); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hb-delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; line-height: 16px; font-weight: 500; }
.hb-delta .hb-icon { width: 14px; height: 14px; }
.hb-delta--good { color: var(--success); }
.hb-delta--bad { color: var(--danger); }

/* Table ------------------------------------------------------------------ */
.hb-tablewrap { overflow-x: auto; scrollbar-width: none; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.hb-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.hb-table th { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .01em; color: var(--ink-muted); white-space: nowrap; }
.hb-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: middle; white-space: nowrap; }
.hb-table tbody tr:last-child td { border-bottom: 0; }
.hb-table tbody tr:hover td { background: var(--surface-alt); }
.hb-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.hb-table .is-muted { color: var(--ink-muted); }
.hb-person { display: flex; align-items: center; gap: var(--space-3); }
.hb-person small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-subtle); }

/* Agent card and builder ---------------------------------------------- */
.hb-agentcard { display: grid; gap: var(--space-4); min-width: 0; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); transition: border-color var(--duration-fast) var(--ease-out); }
.hb-agentcard:hover { border-color: var(--line-strong); }
.hb-agentcard__head { display: flex; align-items: flex-start; gap: var(--space-3); }
.hb-agentcard__name { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: 'opsz' 12; }
.hb-agentcard__role { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-agentcard__head > .hb-badge { margin-left: auto; }
.hb-agentcard__channels { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hb-agentcard__stats { display: flex; gap: var(--space-6); font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.hb-agentcard__stats b { display: block; font-size: 16px; line-height: 24px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.hb-agentcard__foot { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.hb-agentcard__foot > :last-child { margin-left: auto; }
.hb-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--space-3) 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--bg); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.hb-chip .hb-icon { width: 16px; height: 16px; color: var(--ink-muted); }
.hb-builder { display: grid; gap: var(--space-5); max-width: var(--content-narrow); padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.hb-builder__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.hb-builder__name { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: 'opsz' 12; }
.hb-builder__meta { margin: 0; font-size: 12px; line-height: 16px; color: var(--ink-subtle); }
.hb-builder__actions { margin-left: auto; display: flex; gap: var(--space-2); }
.hb-builder .hb-field__input { background: var(--bg); }
.hb-builder__prompt { min-height: 148px; }
.hb-advanced { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); }
.hb-advanced > summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); list-style: none; cursor: pointer; font-size: 14px; line-height: 20px; font-weight: 500; }
.hb-advanced > summary::-webkit-details-marker { display: none; }
.hb-advanced > summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-md); }
.hb-advanced > summary .hb-icon { width: 18px; height: 18px; color: var(--ink-muted); }
.hb-advanced__hint { font-weight: 400; color: var(--ink-muted); }
.hb-advanced__chev { margin-left: auto; transition: transform var(--duration-fast) var(--ease-out); }
.hb-advanced[open] .hb-advanced__chev { transform: rotate(180deg); }
.hb-advanced__body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); padding: 0 var(--space-4) var(--space-4); }

/* Channel card ----------------------------------------------------------- */
.hb-channel { display: flex; align-items: center; gap: var(--space-4); min-width: 0; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.hb-channel__icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--surface-alt); color: var(--ink); }
.hb-channel__icon .hb-icon { width: 22px; height: 22px; }
.hb-channel__body { flex: 1; min-width: 0; }
.hb-channel__name { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; }
.hb-channel__detail { margin: 0; overflow: hidden; font-size: 14px; line-height: 20px; color: var(--ink-muted); white-space: nowrap; text-overflow: ellipsis; }
.hb-channel > .hb-badge, .hb-channel > .hb-btn { flex: none; }

/* Call panel ------------------------------------------------------------- */
.hb-call { display: grid; justify-items: center; gap: var(--space-4); max-width: 360px; margin: 0 auto; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); text-align: center; }
.hb-call__top { justify-self: stretch; display: flex; align-items: center; justify-content: space-between; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-call__live { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); }
.hb-call__live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.hb-call__time { font-variant-numeric: tabular-nums; }
.hb-call__status { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: 'opsz' 12; }
.hb-call__who { margin: -8px 0 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-call__quote { justify-self: stretch; margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-alt); font-size: 14px; line-height: 20px; color: var(--ink); text-align: left; }
.hb-call__controls { display: flex; justify-content: center; gap: var(--space-3); }

/* Conversation list ------------------------------------------------------ */
.hb-convlist { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.hb-conv { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; cursor: pointer; }
.hb-conv:last-child { border-bottom: 0; }
.hb-conv:hover { background: var(--surface-alt); }
.hb-conv[aria-current="true"] { background: var(--clay-soft); }
.hb-conv:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.hb-conv__name { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; line-height: 20px; font-weight: 500; }
.hb-conv__preview { display: block; overflow: hidden; font-size: 14px; line-height: 20px; color: var(--ink-muted); white-space: nowrap; text-overflow: ellipsis; }
.hb-conv--unread .hb-conv__preview { color: var(--ink); }
.hb-conv__side { display: grid; justify-items: end; gap: var(--space-1); font-size: 12px; line-height: 16px; color: var(--ink-subtle); }
.hb-unread { box-sizing: border-box; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--clay); color: var(--on-clay); font-size: 12px; line-height: 20px; font-weight: 500; text-align: center; }
.hb-by { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-by .hb-icon { width: 14px; height: 14px; }

/* Chat message, composer and hand-off ---------------------------------- */
.hb-chat { display: flex; flex-direction: column; gap: var(--space-3); }
.hb-msg { display: flex; align-items: flex-end; gap: var(--space-2); max-width: 520px; }
.hb-msg .hb-agent { width: 32px; height: 32px; margin-bottom: 2px; }
.hb-msg__bubble { padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font-size: 16px; line-height: 24px; color: var(--ink); }
.hb-msg--agent .hb-msg__bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: var(--radius-sm); }
.hb-msg--user { align-self: flex-end; }
.hb-msg--user .hb-msg__bubble { background: var(--clay-soft); border: 1px solid var(--line); border-bottom-right-radius: var(--radius-sm); }
.hb-msg__typing { margin-bottom: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-msg__meta { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-subtle); }
.hb-composer { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); }
.hb-composer:focus-within { border-color: var(--clay); outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-composer__input { min-height: 48px; padding: var(--space-1) var(--space-2); border: 0; outline: 0; resize: none; background: transparent; font-family: var(--font-sans); font-size: 16px; line-height: 24px; color: var(--ink); }
.hb-composer__input::placeholder { color: var(--ink-subtle); }
.hb-composer__bar { display: flex; align-items: center; gap: var(--space-1); }
.hb-composer__bar > .hb-btn--primary { margin-left: auto; }
.hb-handoff { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-alt); font-size: 14px; line-height: 20px; color: var(--ink); }
.hb-handoff > .hb-btn { margin-left: auto; }

/* Flow builder ----------------------------------------------------------- */
.hb-canvas { position: relative; height: 296px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background-color: var(--bg); background-image: radial-gradient(var(--line) 1.2px, transparent 1.4px); background-size: 16px 16px; }
.hb-canvas > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hb-canvas > .hb-node { position: absolute; }
.hb-node { box-sizing: border-box; position: relative; width: 232px; min-height: 104px; padding: var(--space-3) var(--space-4) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); }
.hb-node__type { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-node__type .hb-icon { width: 16px; height: 16px; }
.hb-node--agent .hb-node__type .hb-icon { color: var(--gold-mark); }
.hb-node__title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); }
.hb-node__text { margin: var(--space-1) 0 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.hb-node__port { box-sizing: border-box; position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--surface); }
.hb-node__port--in { left: -7px; }
.hb-node__port--out { right: -7px; }
.hb-node__port.is-on { border-color: var(--clay); background: var(--clay); }
.hb-node.is-selected { border-color: var(--clay); box-shadow: 0 0 0 1px var(--clay); }
.hb-node.is-error { border-color: var(--danger); }
.hb-node__error { display: flex; align-items: center; gap: 4px; margin-top: var(--space-2); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--danger); }
.hb-node__error .hb-icon { width: 14px; height: 14px; }
.hb-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.hb-edge.is-on { stroke: var(--clay); stroke-width: 2; }

/* Onboarding (mobile first) --------------------------------------------- */
.hb-onb { box-sizing: border-box; display: grid; gap: var(--space-4); width: 100%; max-width: 360px; margin: 0 auto; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); }
.hb-onb__top { display: flex; align-items: center; justify-content: space-between; }
.hb-onb__top .hb-logo { height: 20px; }
.hb-onb__step { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.hb-progress { height: 4px; overflow: hidden; border-radius: 2px; background: var(--surface-alt); }
.hb-progress > span { display: block; height: 100%; border-radius: 2px; background: var(--clay); }
.hb-onb__title { margin: var(--space-2) 0 0; font-family: var(--font-display); font-size: 26px; line-height: 30px; font-weight: 700; letter-spacing: -0.03em; font-variation-settings: 'opsz' 12; }
.hb-onb__text { margin: 0; font-size: 16px; line-height: 24px; color: var(--ink-muted); }
.hb-onb__nodes { display: grid; gap: var(--space-3); }
.hb-onode { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--bg); font-family: var(--font-sans); color: var(--ink); text-align: left; cursor: pointer; }
.hb-onode:hover { border-color: var(--clay); }
.hb-onode:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-onode.is-done { border-color: var(--line); }
.hb-onode__icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--surface-alt); }
.hb-onode__body { flex: 1; min-width: 0; }
.hb-onode__body b { display: block; font-size: 16px; line-height: 24px; font-weight: 500; }
.hb-onode__body small { display: block; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-onode > .hb-badge { flex: none; }
.hb-onode__go { color: var(--ink-muted); }
.hb-onb__cta { width: 100%; }

/* Button ---------------------------------------------------------------- */
.hb-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 40px; padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out); }
.hb-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-btn--primary { background: var(--clay); color: var(--on-clay); }
.hb-btn--primary:hover { background: var(--clay-hover); }
.hb-btn--secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.hb-btn--secondary:hover { background: var(--surface-alt); }
.hb-btn--ghost { background: transparent; color: var(--ink); }
.hb-btn--ghost:hover { background: var(--surface-alt); }
.hb-btn--danger { background: var(--danger); color: var(--on-danger); }
.hb-btn--danger:hover { filter: brightness(.92); }
.hb-btn--sm { height: 32px; padding: 0 var(--space-3); }
.hb-btn--lg { height: 48px; padding: 0 var(--space-5); font-size: 16px; line-height: 24px; }
.hb-btn--icon { width: 40px; padding: 0; }
.hb-btn--icon.hb-btn--sm { width: 32px; }
.hb-btn--round { width: 48px; height: 48px; padding: 0; border-radius: var(--radius-full); }
.hb-btn:disabled, .hb-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.hb-btn svg { width: 18px; height: 18px; flex: none; }
.hb-btn--round svg { width: 20px; height: 20px; }

/* Input, textarea, select, search -------------------------------------- */
.hb-field { display: grid; gap: var(--space-2); max-width: 360px; }
.hb-field--full { max-width: none; }
.hb-field__label { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); }
.hb-field__input { box-sizing: border-box; width: 100%; height: 44px; padding: 0 var(--space-3); background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-md); font-family: var(--font-sans); font-size: 16px; line-height: 24px; transition: border-color var(--duration-fast) var(--ease-out); }
.hb-field__input::placeholder { color: var(--ink-subtle); }
.hb-field__input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-color: var(--clay); }
.hb-field__input--area { height: auto; min-height: 112px; padding: var(--space-3); resize: vertical; }
.hb-field__hint { display: flex; align-items: center; gap: var(--space-1); font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-field__hint svg { width: 16px; height: 16px; flex: none; }
.hb-field[data-invalid] .hb-field__input { border-color: var(--danger); }
.hb-field[data-invalid] .hb-field__hint { color: var(--danger); }
.hb-select, .hb-search { position: relative; display: block; }
.hb-select > select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.hb-select > .hb-icon { position: absolute; top: 50%; right: 12px; width: 18px; height: 18px; margin-top: -9px; color: var(--ink-muted); pointer-events: none; }
.hb-search > .hb-icon { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; margin-top: -9px; color: var(--ink-subtle); pointer-events: none; }
.hb-search > input { padding-left: 40px; }
.hb-search--sm > input { height: 36px; font-size: 14px; line-height: 20px; }

/* Switch and checkbox ---------------------------------------------------- */
.hb-switch, .hb-check { display: inline-flex; align-items: center; gap: var(--space-3); font-size: 14px; line-height: 20px; color: var(--ink); cursor: pointer; }
.hb-switch > input { position: relative; flex: none; width: 40px; height: 24px; margin: 0; border-radius: var(--radius-full); background: var(--line-strong); appearance: none; -webkit-appearance: none; cursor: pointer; transition: background-color var(--duration-fast) var(--ease-out); }
.hb-switch > input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform var(--duration-fast) var(--ease-out); }
.hb-switch > input:checked { background: var(--clay); }
.hb-switch > input:checked::after { transform: translateX(16px); background: var(--on-clay); }
.hb-check > input { display: grid; place-content: center; flex: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--surface); appearance: none; -webkit-appearance: none; cursor: pointer; }
.hb-check > input:checked { border-color: var(--clay); background: var(--clay); }
.hb-check > input:checked::after { content: ""; width: 9px; height: 5px; border: solid var(--on-clay); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.hb-switch > input:focus-visible, .hb-check > input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.hb-switch > input:disabled, .hb-check > input:disabled { opacity: .45; cursor: not-allowed; }
.hb-switch small, .hb-check small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* Badge ----------------------------------------------------------------- */
.hb-badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 24px; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .01em; white-space: nowrap; background: var(--surface-alt); color: var(--ink); }
.hb-badge svg { width: 14px; height: 14px; flex: none; }
.hb-badge--success { background: var(--success-soft); color: var(--success); }
.hb-badge--warning { background: var(--warning-soft); color: var(--warning); }
.hb-badge--danger { background: var(--danger-soft); color: var(--danger); }
.hb-badge--info { background: var(--info-soft); color: var(--info); }
.hb-badge--clay { background: var(--clay); color: var(--on-clay); }

/* Avatar ----------------------------------------------------------------- */
.hb-avatar { position: relative; display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-full); background: var(--surface-alt); color: var(--ink); font-size: 14px; line-height: 1; font-weight: 500; text-transform: uppercase; }
.hb-avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.hb-avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.hb-avatar--clay { background: var(--clay-soft); color: var(--clay); }
.hb-avatar__channel { position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: var(--radius-full); background: var(--surface); box-shadow: 0 0 0 2px var(--bg); color: var(--ink-muted); }
.hb-avatar__channel .hb-icon { width: 12px; height: 12px; }

/* Menu ------------------------------------------------------------------- */
.hb-menu { display: grid; min-width: 220px; padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-float); }
.hb-menu__item { display: flex; align-items: center; gap: var(--space-3); height: 36px; padding: 0 var(--space-3); border: 0; border-radius: 6px; background: none; font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--ink); text-align: left; cursor: pointer; }
.hb-menu__item .hb-icon { width: 18px; height: 18px; color: var(--ink-muted); }
.hb-menu__item:hover { background: var(--surface-alt); }
.hb-menu__item:focus-visible { background: var(--surface-alt); outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.hb-menu__item--danger, .hb-menu__item--danger .hb-icon { color: var(--danger); }
.hb-menu__item kbd { margin-left: auto; font-family: var(--font-sans); font-size: 12px; color: var(--ink-subtle); }
.hb-menu__sep { height: 1px; margin: var(--space-1) 0; background: var(--line); }

/* Alert and toast -------------------------------------------------------- */
.hb-alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--info-soft); color: var(--ink); font-size: 14px; line-height: 20px; }
.hb-alert > .hb-icon { margin-top: 0; color: var(--info); }
.hb-alert--success { background: var(--success-soft); }
.hb-alert--success > .hb-icon { color: var(--success); }
.hb-alert--warning { background: var(--warning-soft); }
.hb-alert--warning > .hb-icon { color: var(--warning); }
.hb-alert--danger { background: var(--danger-soft); }
.hb-alert--danger > .hb-icon { color: var(--danger); }
.hb-alert__title { margin: 0; font-weight: 500; }
.hb-alert__text { margin: 2px 0 0; color: var(--ink-muted); }
.hb-alert > .hb-btn { align-self: center; }
.hb-toast { display: inline-flex; align-items: center; gap: var(--space-3); max-width: 440px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-float); font-size: 14px; line-height: 20px; }
.hb-toast > .hb-icon { width: 18px; height: 18px; }
.hb-toast__action { margin-left: var(--space-2); padding: 0; border: 0; background: none; font: inherit; font-weight: 500; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Modal ------------------------------------------------------------------ */
.hb-scrim { display: grid; place-items: center; padding: var(--space-6); background: var(--scrim); }
.hb-modal { box-sizing: border-box; display: grid; gap: var(--space-4); width: 100%; max-width: 440px; padding: var(--space-6); border-radius: var(--radius-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float); }
.hb-modal__title { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.02em; font-variation-settings: 'opsz' 12; }
.hb-modal__text { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.hb-modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

@media (prefers-reduced-motion: reduce) {
  .hb-agent .hb-enso__ink, .hb-agent .hb-enso__spine { animation: none !important; }
  .hb-btn, .hb-field__input, .hb-switch > input, .hb-switch > input::after, .hb-agentcard, .hb-advanced__chev { transition: none; }
}

/* Titles break into balanced lines (no orphan word). */
.hb-pagehead__title, .hb-empty__title, .hb-empty__text, .hb-onb__title, .hb-modal__title { text-wrap: balance; }
