/* AgentCore Enterprise Workspace (hr-web).
 *
 * Enterprise 3-column desktop workspace matched to the zinc-cards palette from
 * dashboard/public/app.css, paired with a dark-slate left bot roster sidebar,
 * center conversation + A2UI card tray, and right collapsible utility drawer.
 * Zero CDN, zero external fonts, zero frameworks.
 */

:root {
  color-scheme: light;
  --font: "Amazon Ember", "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #fafafa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;

  --ink: #09090b;
  --ink-2: #3f3f46;
  --ink-3: #71717a;

  --accent: #18181b;
  --accent-soft: #f4f4f5;

  /* Dark-slate left roster tokens */
  --roster-bg: #12141a;
  --roster-surface: #1a1d26;
  --roster-hover: #222633;
  --roster-active: #272c3b;
  --roster-line: #272b36;
  --roster-ink: #f4f4f5;
  --roster-ink-2: #cbd5e1;
  --roster-ink-3: #8b95a7;

  --ok: #00802f;
  --ok-soft: #effff1;
  --ok-dot: #22c55e;
  --err: #db0000;
  --err-soft: #fff5f5;
  --warn: #855900;
  --warn-soft: #fffce9;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --handover: #0284c7;
  --handover-soft: #e0f2fe;

  --r: 8px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-up: 0 10px 28px rgba(0, 0, 0, .12);
  --topbar-h: 56px;
  --roster-w: 272px;
  --drawer-w: 380px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; max-width: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ----------------------------------------------------------------- login gate */
.hr-login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface-2);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 20px 20px;
}
.hr-login-card {
  width: 100%;
  max-width: 440px;
  padding: 34px 30px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .07);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}
.brand-mark--lg {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  font-size: 15px;
  flex: 0 0 48px;
}
.ew-login-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.hr-login-title {
  margin: 2px 0 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -.015em;
}
.hr-login-sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.55;
}
.ew-login-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  list-style: none;
  margin: 2px 0 6px;
  padding: 0;
}
.ew-login-pills li {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
}
.hr-login-error {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #f2b4b4;
  border-radius: var(--r-sm);
  background: var(--err-soft);
  color: var(--err);
  font-size: 12.5px;
  text-align: left;
}
.hr-button--lg {
  width: 100%;
  height: 40px;
  font-size: 13.5px;
}
.hr-login-meta {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ----------------------------------------------------------------- shell */
.hr-shell,
.ew-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ----------------------------------------------------------------- topbar */
.ew-topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.ew-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent);
  color: #fafafa;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  flex: 0 0 32px;
}
.ew-brand-copy { min-width: 0; }
.brand-name, .brand-sub { display: block; line-height: 1.2; white-space: nowrap; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--ink-3); }

.ew-agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ew-agent-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-dot);
  flex: 0 0 7px;
}
.ew-agent-pill[data-status="available"]::before,
.ew-agent-pill[data-status="marketplace"]::before {
  background: #8b5cf6;
}
.ew-agent-pill[data-handover="active"] {
  border-color: #93c5fd;
  background: var(--info-soft);
  color: var(--info);
}
.ew-agent-pill[data-handover="active"]::before {
  background: var(--info);
  animation: ew-pulse-ring 1.6s ease-out infinite;
}

.ew-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.identity-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.identity-state[data-state="signed-in"] {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #bbf7d0;
}
.identity-state[data-state="error"] {
  color: var(--err);
  background: var(--err-soft);
  border-color: #fecaca;
}

.ew-reviews-btn {
  gap: 6px;
}
.ew-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--info);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

.ew-topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: 0 0 1px;
}

.ew-icon-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ew-icon-btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ew-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 15px;
}
.ew-icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}
.ew-icon-btn.is-active,
.ew-icon-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fafafa;
}

/* ----------------------------------------------------------------- 3-col grid */
.ew-workspace-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--roster-w) minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--surface-2);
}

/* --------------------------------------------------------- 1. left roster */
.ew-left-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--roster-bg);
  color: var(--roster-ink);
  border-right: 1px solid var(--roster-line);
}
.ew-left-sidebar :focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}
.ew-sidebar-mobile-bar {
  display: contents;
}
.ew-roster-toggle {
  display: none;
}

.ew-pinned-section {
  padding: 12px 10px 10px;
  border-bottom: 1px solid var(--roster-line);
}
.ew-pinned-orchestrator {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 1px solid var(--roster-line);
  border-radius: var(--r-sm);
  background: var(--roster-surface);
}
.ew-roster-section-label {
  padding: 0 4px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--roster-ink-3);
}

.ew-handover-banner {
  margin: 10px 10px 4px;
  padding: 9px 11px;
  border-radius: var(--r);
  border: 1px solid var(--roster-line);
  background: var(--roster-surface);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.ew-handover-banner[data-state="active"],
.ew-handover-banner.is-active,
.ew-handover-banner:has(#handoverStatusLabel[data-state="active"]) {
  border-color: rgba(56, 189, 248, .55);
  background: rgba(14, 116, 144, .2);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, .22);
}
.ew-handover-banner:has(#handoverStatusLabel[data-state="paused"]) {
  border-color: rgba(245, 158, 11, .5);
  background: rgba(146, 64, 14, .2);
}
.ew-handover-banner:has(#handoverStatusLabel[data-state="done"]) {
  border-color: rgba(34, 197, 94, .4);
  background: rgba(20, 83, 45, .2);
}
.ew-handover-banner:has(#handoverStatusLabel[data-state="error"]) {
  border-color: rgba(248, 113, 113, .5);
  background: rgba(127, 29, 29, .22);
}
.ew-handover-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.ew-handover-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok-dot);
  flex: 0 0 7px;
}
.ew-handover-banner[data-state="active"] .ew-handover-pulse,
.ew-handover-banner.is-active .ew-handover-pulse,
.ew-handover-banner:has(#handoverStatusLabel[data-state="active"]) .ew-handover-pulse {
  background: #38bdf8;
  animation: ew-pulse-ring 1.4s ease-out infinite;
}
.ew-handover-banner:has(#handoverStatusLabel[data-state="paused"]) .ew-handover-pulse {
  background: #fbbf24;
}
.ew-handover-banner:has(#handoverStatusLabel[data-state="error"]) .ew-handover-pulse {
  background: #f87171;
}
.ew-handover-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--roster-ink-3);
}
.ew-handover-banner[data-state="active"] .ew-handover-kicker,
.ew-handover-banner.is-active .ew-handover-kicker,
.ew-handover-banner:has(#handoverStatusLabel[data-state="active"]) .ew-handover-kicker {
  color: #7dd3fc;
}
.ew-handover-route {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--roster-ink-2);
  overflow-wrap: anywhere;
}
#handoverStatusLabel[data-state="active"] { color: #e0f2fe; }
#handoverStatusLabel[data-state="done"] { color: #bbf7d0; }
#handoverStatusLabel[data-state="paused"] { color: #fef3c7; }
#handoverStatusLabel[data-state="error"] { color: #fecaca; }

.ew-roster-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Dark-slate bot roster items (overrides app.js :where() fallback styles) */
.ew-left-sidebar .hr-bot-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid var(--roster-line);
  border-radius: var(--r-sm);
  background: var(--roster-surface);
  color: var(--roster-ink);
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.ew-left-sidebar .hr-bot-item[data-bot-id="god-bot"],
.ew-left-sidebar .hr-bot-item[data-tier="1"],
.ew-left-sidebar .hr-bot-item[data-tier="orchestrator"] {
  border-color: rgba(245, 158, 11, .35);
  box-shadow: inset 3px 0 0 #f59e0b;
}
.ew-left-sidebar .hr-bot-item[data-tier="2"],
.ew-left-sidebar .hr-bot-item[data-tier="department"] {
  margin-left: 8px;
  width: calc(100% - 8px);
}
.ew-left-sidebar .hr-bot-item[data-tier="3"],
.ew-left-sidebar .hr-bot-item[data-tier="leaf"],
.ew-left-sidebar .hr-bot-item[data-tier="governance"],
.ew-left-sidebar .hr-bot-item[data-tier="platform"] {
  margin-left: 16px;
  width: calc(100% - 16px);
  background: rgba(26, 29, 38, .65);
}
.ew-left-sidebar .hr-bot-item:hover {
  background: var(--roster-hover);
  border-color: #3f4659;
}
.ew-left-sidebar .hr-bot-item.is-selected,
.ew-left-sidebar .hr-bot-item[aria-current="true"] {
  background: var(--roster-active);
  border-color: #64748b;
  box-shadow: inset 3px 0 0 #fafafa;
}
.ew-left-sidebar .hr-bot-item[data-activity="active"] {
  background: rgba(14, 116, 144, .22);
  border-color: rgba(56, 189, 248, .65);
  box-shadow: inset 3px 0 0 #38bdf8;
}
.ew-left-sidebar .hr-bot-item[data-activity="done"] {
  border-color: rgba(34, 197, 94, .45);
  background: rgba(20, 83, 45, .18);
}
.ew-left-sidebar .hr-bot-item[data-activity="paused"] {
  border-color: rgba(245, 158, 11, .55);
  background: rgba(146, 64, 14, .2);
}
.ew-left-sidebar .hr-bot-item[data-activity="denied"],
.ew-left-sidebar .hr-bot-item[data-activity="error"] {
  border-color: rgba(248, 113, 113, .55);
  background: rgba(127, 29, 29, .24);
}

.ew-left-sidebar .hr-bot-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.ew-left-sidebar .hr-bot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 7px;
  background: #52525b;
}
.ew-left-sidebar .hr-bot-item[data-activity="active"] .hr-bot-dot {
  background: #38bdf8;
  animation: ew-pulse-ring 1.3s ease-out infinite;
}
.ew-left-sidebar .hr-bot-item[data-activity="done"] .hr-bot-dot {
  background: var(--ok-dot);
}
.ew-left-sidebar .hr-bot-item[data-activity="paused"] .hr-bot-dot {
  background: #fbbf24;
}
.ew-left-sidebar .hr-bot-item[data-activity="denied"] .hr-bot-dot,
.ew-left-sidebar .hr-bot-item[data-activity="error"] .hr-bot-dot {
  background: #f87171;
}
.ew-left-sidebar .hr-bot-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--roster-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-left-sidebar .hr-bot-status {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: var(--roster-ink-3);
  flex-shrink: 0;
}
.ew-left-sidebar .hr-bot-item[data-activity="active"] .hr-bot-status {
  background: rgba(56, 189, 248, .2);
  color: #7dd3fc;
}
.ew-left-sidebar .hr-bot-item[data-activity="done"] .hr-bot-status {
  background: rgba(34, 197, 94, .18);
  color: #86efac;
}
.ew-left-sidebar .hr-bot-item[data-activity="paused"] .hr-bot-status {
  background: rgba(245, 158, 11, .2);
  color: #fde68a;
}
.ew-left-sidebar .hr-bot-item[data-activity="denied"] .hr-bot-status,
.ew-left-sidebar .hr-bot-item[data-activity="error"] .hr-bot-status {
  background: rgba(248, 113, 113, .22);
  color: #fecaca;
}
.ew-left-sidebar .hr-bot-sub {
  font-size: 11px;
  color: var(--roster-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-left-sidebar .hr-bot-details {
  margin-top: 5px;
  padding-top: 6px;
  border-top: 1px dashed var(--roster-line);
  font-size: 11px;
  line-height: 1.4;
  color: var(--roster-ink-2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ew-left-sidebar .hr-bot-details .mono {
  font-size: 10.5px;
  color: #93c5fd;
}
.ew-bot-group + .ew-bot-group {
  margin-top: 12px;
}
.ew-roster-group-title {
  padding: 4px 6px 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--roster-ink-3);
}

.ew-bot-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--roster-ink);
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.ew-bot-item:hover {
  background: var(--roster-hover);
  border-color: var(--roster-line);
}
.ew-bot-item.is-active,
.ew-bot-item[aria-current="true"] {
  background: var(--roster-active);
  border-color: #3f4659;
  box-shadow: inset 3px 0 0 #fafafa;
}
.ew-bot-item--pinned {
  background: var(--roster-surface);
  border-color: var(--roster-line);
}
.ew-bot-item.is-handover,
.ew-bot-item[data-handover="active"] {
  background: rgba(37, 99, 235, .18);
  border-color: rgba(96, 165, 250, .55);
  box-shadow: inset 3px 0 0 #60a5fa;
}
.ew-bot-item.is-handover .ew-status-dot,
.ew-bot-item[data-handover="active"] .ew-status-dot {
  background: #60a5fa;
  animation: ew-pulse-ring 1.3s ease-out infinite;
}

.ew-bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f59e0b;
  color: #18181b;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .03em;
  flex: 0 0 28px;
}
.ew-bot-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ew-bot-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ew-bot-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--roster-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-bot-badge {
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, .16);
  color: #fcd34d;
  font-size: 10px;
  font-weight: 600;
  flex: 0 0 auto;
}
.ew-bot-tag {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  color: var(--roster-ink-3);
  font-size: 10px;
  font-weight: 600;
  flex: 0 0 auto;
}
.ew-bot-desc {
  font-size: 11px;
  color: var(--roster-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ew-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--roster-ink-3);
  flex: 0 0 8px;
}
.ew-status-dot--online,
.ew-status-dot--live { background: var(--ok-dot); }
.ew-status-dot--busy { background: #38bdf8; }
.ew-status-dot--marketplace,
.ew-status-dot--available { background: #a78bfa; }
.ew-status-dot--offline { background: #52525b; }

.ew-sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--roster-line);
  background: var(--roster-bg);
}
.ew-marketplace-cta {
  width: 100%;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px dashed #3f4659;
  border-radius: var(--r-sm);
  background: var(--roster-surface);
  color: var(--roster-ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.ew-marketplace-cta svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 14px;
}
.ew-marketplace-cta:hover {
  background: var(--roster-hover);
  border-color: #64748b;
}

/* --------------------------------------------------------- 2. center console */
.ew-center-console {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.ew-focus-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-3);
  font-size: 12px;
  color: var(--ink-3);
}
.ew-focus-label {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-focus-label strong {
  color: var(--ink);
  font-weight: 600;
}
.ew-focus-sep { color: var(--line-strong); }
.ew-focus-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.ew-focus-chip {
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
}

.ew-chat-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
  background: var(--surface-2);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 20px 20px;
}

.hr-welcome,
.ew-welcome {
  width: min(820px, calc(100% - 40px));
  margin: auto;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ew-welcome-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hr-welcome-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.hr-welcome-sub {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
}
.hr-starters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.hr-starter-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
.hr-starter-chip:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
}
.hr-starter-chip:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.hr-starter-chip strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.hr-starter-chip span {
  font-size: 11.5px;
  color: var(--ink-3);
}

.hr-messages,
.ew-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
}
.ew-messages:empty {
  display: none;
}

.hr-message {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  max-width: 820px;
  margin: 0 auto 14px;
}
.hr-message > div:last-child { min-width: 0; }
.hr-message--user { grid-template-columns: minmax(0, 1fr) 30px; }
.hr-message--user .hr-avatar {
  grid-column: 2;
  grid-row: 1;
  background: var(--surface);
  color: var(--ink);
}
.hr-message--user > div:last-child {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  max-width: 88%;
}
.hr-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent);
  color: #fafafa;
  font-size: 9.5px;
  font-weight: 700;
}
.hr-message-meta {
  margin: 0 0 4px;
  color: var(--ink-3);
  font-size: 11px;
}
.hr-message--user .hr-message-meta {
  text-align: right;
}
.hr-message-body {
  display: inline-block;
  max-width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 3px 10px 10px 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.5;
}
.hr-message--user .hr-message-body {
  border-radius: 10px 3px 10px 10px;
  background: var(--accent);
  color: #fafafa;
  border-color: var(--accent);
}
.hr-message--system .hr-message-body {
  background: var(--warn-soft);
  border-color: #f6d78b;
  color: var(--ink-2);
}
.hr-message--error .hr-message-body {
  background: var(--err-soft);
  border-color: #f2b4b4;
  color: var(--ink);
}
.hr-message[data-thinking="true"] .hr-message-body {
  color: var(--ink-3);
  font-style: italic;
}
.hr-message-body:empty {
  display: none;
}

.hr-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #c7dbfb;
  border-radius: var(--r-sm);
  background: var(--info-soft);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.45;
}

/* Formatted Markdown inside .hr-message-body (.hr-md and .ew-md) */
.hr-message-body:has(.hr-md),
.hr-message-body.ew-md,
.hr-message-body .ew-md {
  white-space: normal;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}
.hr-md {
  white-space: normal;
  line-height: 1.55;
  font-size: 13.5px;
  color: inherit;
}
.hr-md > :first-child,
.ew-md > :first-child { margin-top: 0; }
.hr-md > :last-child,
.ew-md > :last-child { margin-bottom: 0; }
.hr-md p,
.ew-md p {
  margin: 0 0 8px;
  line-height: 1.55;
}
.hr-md h1,
.hr-md h2,
.hr-md h3,
.ew-md h3 {
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.hr-md h1 { font-size: 15.5px; }
.hr-md h2 { font-size: 14.5px; }
.hr-md h4,
.hr-md h5,
.hr-md h6,
.ew-md h4 {
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.hr-md ul,
.hr-md ol,
.ew-md ul,
.ew-md ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}
.hr-md li,
.ew-md li {
  margin: 2px 0;
  line-height: 1.5;
}
.hr-md strong,
.ew-md strong { font-weight: 600; }
.hr-md blockquote,
.hr-md blockquote.hr-md-quote,
.ew-md blockquote {
  margin: 8px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--ink-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.hr-md code,
.ew-md code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
}
.hr-md pre,
.hr-md pre.hr-md-pre,
.ew-md pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 0;
  background: #18181b;
  color: #f4f4f5;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
.hr-md pre code,
.hr-md pre.hr-md-pre code,
.ew-md pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}
.hr-md-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
}
.hr-md table,
.hr-md-table,
.ew-md table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.ew-md table { margin: 8px 0; }
.hr-md th,
.hr-md td,
.hr-md-table th,
.hr-md-table td,
.ew-md th,
.ew-md td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.hr-md th:last-child,
.hr-md td:last-child,
.hr-md-table th:last-child,
.hr-md-table td:last-child,
.ew-md th:last-child,
.ew-md td:last-child { border-right: 0; }
.hr-md tr:last-child td,
.hr-md-table tr:last-child td,
.ew-md tr:last-child td { border-bottom: 0; }
.hr-md thead th,
.hr-md-table th,
.ew-md thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 600;
}
.hr-md hr,
.hr-md-hr,
.ew-md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 10px 0;
}

.hr-message--user .hr-md h1,
.hr-message--user .hr-md h2,
.hr-message--user .hr-md h3,
.hr-message--user .hr-md h4,
.hr-message--user .ew-md h3,
.hr-message--user .ew-md h4 { color: #fafafa; }
.hr-message--user .hr-md code,
.hr-message--user .ew-md code {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .2);
  color: #fafafa;
}
.hr-message--user .hr-md a,
.hr-message--user .ew-md a { color: #bfdbfe; }
.hr-message--user .hr-md blockquote,
.hr-message--user .ew-md blockquote {
  background: rgba(255, 255, 255, .08);
  border-left-color: rgba(255, 255, 255, .35);
  color: #e4e4e7;
}

/* Tool & Handover trace pills */
.hr-trace {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 8px 0 0;
  padding: 8px 0 0;
  list-style: none;
  border-top: 1px dashed var(--line);
}
.hr-trace-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.hr-trace-head {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 100%;
  min-width: 0;
}
.hr-trace-label {
  font-family: var(--mono);
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hr-trace-toggle {
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}
.hr-trace-toggle:hover {
  background: var(--line);
  color: var(--ink);
}
.hr-trace-detail {
  margin: 2px 0 4px 10px;
  padding: 8px 10px;
  border-left: 2px solid var(--line-strong);
  background: var(--surface);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 200px;
  overflow: auto;
}
.hr-trace-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--info);
  background: var(--info-soft);
  flex: 0 0 8px;
}
.hr-trace-item[data-kind="deny"] .hr-trace-head {
  border-color: #fecaca;
  background: var(--err-soft);
}
.hr-trace-item[data-kind="deny"] .hr-trace-dot {
  border-color: var(--err);
  background: var(--err-soft);
}
.hr-trace-item[data-kind="allow"] .hr-trace-head {
  border-color: #bbf7d0;
  background: var(--ok-soft);
}
.hr-trace-item[data-kind="allow"] .hr-trace-dot {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.hr-trace-item[data-kind="handover"] .hr-trace-head {
  border-color: #bae6fd;
  background: var(--handover-soft);
  color: #0369a1;
}
.hr-trace-item[data-kind="handover"] .hr-trace-dot {
  border-color: var(--handover);
  background: var(--handover-soft);
}

/* Dynamic A2UI surfaces tray inside center console */
.ew-center-surfaces {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 12px;
  padding: 12px max(20px, calc((100% - 820px) / 2));
  max-height: 40vh;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--surface-3);
}
.ew-center-surfaces:empty {
  display: none;
}
.ew-center-surfaces > .a2ui-surface {
  margin-bottom: 0;
  min-width: 0;
}

/* Composer */
.hr-composer,
.ew-composer {
  flex: 0 0 auto;
  padding: 12px max(20px, calc((100% - 820px) / 2)) 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.hr-composer textarea {
  min-height: 52px;
  max-height: 160px;
}
.hr-composer-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 11.5px;
}
.ew-composer-slash-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-2);
}
.ew-composer-slash-hint kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink);
}
.hr-composer-hint { margin-left: auto; }

/* --------------------------------------------------------- 3. right drawer */
.ew-right-drawer {
  width: var(--drawer-w);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  animation: ew-drawer-in .18s ease-out;
}
.ew-drawer-header {
  flex: 0 0 auto;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-3);
}
.ew-drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ew-drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.ew-drawer-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ew-drawer-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.ew-drawer-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.ew-drawer-tab {
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.ew-drawer-tab svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 13px;
}
.ew-drawer-tab:hover {
  color: var(--ink);
}
.ew-drawer-tab.is-active,
.ew-drawer-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.ew-drawer-search-wrap {
  position: relative;
  flex: 0 0 auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.ew-drawer-search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.ew-drawer-search {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}
.ew-drawer-search:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

.ew-drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ew-drawer-section-label,
.hr-drawer-section-title {
  margin: 4px 0 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.hr-drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hr-drawer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ew-drawer-empty,
.hr-drawer-empty {
  padding: 28px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 12.5px;
  text-align: center;
}

/* Shared dynamic drawer cards generated by app.js */
.hr-drawer-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .12s ease, background .12s ease;
}
.hr-drawer-card:hover {
  border-color: var(--line-strong);
}
.hr-drawer-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.hr-drawer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.hr-drawer-card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}
.hr-drawer-card-meta {
  font-size: 11px;
  color: var(--ink-3);
}
.hr-drawer-card-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}
.hr-drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.hr-drawer-chip {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 500;
}
.hr-drawer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}
.hr-history-btn {
  all: unset;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.hr-history-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.hr-guide-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.45;
}
.hr-guide-tips {
  margin: 2px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-3);
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.45;
}

/* History drawer items */
.ew-history-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.ew-history-item:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}
.ew-history-item.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ew-history-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ew-history-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-history-item-time {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.ew-history-item-snippet {
  font-size: 12px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ew-history-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}

/* Prompt library cards */
.ew-prompt-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}
.ew-prompt-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.ew-prompt-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ew-prompt-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.ew-prompt-card-tag {
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.ew-prompt-card-text {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}
.ew-prompt-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}

/* User guide cards */
.ew-guide-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ew-guide-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.ew-guide-card p {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.ew-guide-card p:last-child { margin-bottom: 0; }
.ew-guide-card ul,
.ew-guide-card ol {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--ink-2);
}
.ew-guide-card li { margin: 4px 0; line-height: 1.45; }
.ew-guide-card code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 11.5px;
}

/* Marketplace agent cards */
.ew-market-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ew-market-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.ew-market-card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.ew-market-card-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--ink-3);
}
.ew-market-card-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}
.ew-market-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ew-market-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* ----------------------------------------------------------------- HR cards */
/* Preserved verbatim for hr-primitives.js and a2ui.js */
.hr-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.hr-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}
.hr-card--review { border-color: #c7dbfb; background: #fbfdff; }
.hr-card--notice { border-color: #f6d78b; background: var(--warn-soft); }
.hr-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.hr-card h2 { margin: 0; font-size: 13px; font-weight: 600; }
.hr-card-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.hr-card-tag--pending { background: var(--info-soft); color: var(--info); border-color: transparent; }
.hr-card-tag--blocked { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.hr-card-tag--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.hr-card-tag--err { background: var(--err-soft); color: var(--err); border-color: transparent; }

.hr-kv { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0; }
.hr-kv > div {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 8px;
  padding: 3px 0;
  font-size: 12.5px;
}
.hr-kv dt { color: var(--ink-3); }
.hr-kv dd { margin: 0; overflow-wrap: anywhere; }

.hr-reports { margin: 0; padding: 0; list-style: none; }
.hr-reports li {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}
.hr-reports li:last-child { border-bottom: 0; }
.hr-reports li .mono { color: var(--ink-3); }

.hr-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
}
.hr-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--err-soft);
  color: var(--err);
  font-size: 12px;
}

.hr-reason {
  margin: 8px 0 0;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--surface-2);
}
.hr-reason-label {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  margin-bottom: 4px;
}
.hr-reason-body {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-2);
}

.hr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}
.hr-edit-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.hr-edit-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hr-edit-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
}
.hr-input--sm {
  padding: 5px 8px;
  font-size: 12.5px;
  resize: none;
}

/* ----------------------------------------------------------------- A2UI */
.a2ui-surface {
  display: block;
}
.a2ui-surface:not(:last-child) { margin-bottom: 12px; }
.a2ui-unknown {
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  background: var(--surface-2);
  font-size: 12px;
}
.a2ui-unknown::before {
  content: "Unknown component: " attr(data-component);
}

.a2ui-column {
  display: flex;
  flex-direction: column;
}
.a2ui-column[data-gap="none"] { gap: 0; }
.a2ui-column[data-gap="sm"] { gap: 6px; }
.a2ui-column[data-gap="md"] { gap: 10px; }
.a2ui-column[data-gap="lg"] { gap: 16px; }
.a2ui-column[data-align="start"] { align-items: flex-start; }
.a2ui-column[data-align="center"] { align-items: center; }
.a2ui-column[data-align="stretch"] { align-items: stretch; }

.a2ui-row {
  display: flex;
  flex-direction: row;
}
.a2ui-row[data-gap="none"] { gap: 0; }
.a2ui-row[data-gap="sm"] { gap: 6px; }
.a2ui-row[data-gap="md"] { gap: 10px; }
.a2ui-row[data-gap="lg"] { gap: 16px; }
.a2ui-row[data-align="start"] { align-items: flex-start; }
.a2ui-row[data-align="center"] { align-items: center; }
.a2ui-row[data-align="end"] { align-items: flex-end; }
.a2ui-row[data-align="baseline"] { align-items: baseline; }
.a2ui-row[data-justify="start"] { justify-content: flex-start; }
.a2ui-row[data-justify="center"] { justify-content: center; }
.a2ui-row[data-justify="end"] { justify-content: flex-end; }
.a2ui-row[data-justify="between"] { justify-content: space-between; }

.a2ui-heading {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.a2ui-heading-text { flex: 1; }

.a2ui-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.a2ui-text--muted { color: var(--ink-3); font-size: 12.5px; }
.a2ui-text--error { color: var(--err); }
.a2ui-text--warning { color: var(--warn); }
.a2ui-text--mono { font-family: var(--mono); font-size: 12.5px; }

.hr-notice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--ink-2);
}
.hr-notice--info {
  background: var(--info-soft);
  border-color: #c7dbfb;
  color: var(--info);
}
.hr-notice--ok {
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok);
}
.hr-notice--warn {
  background: var(--warn-soft);
  border-color: #f6d78b;
  color: var(--warn);
}
.hr-notice--err {
  background: var(--err-soft);
  border-color: #f2b4b4;
  color: var(--err);
}
.hr-notice-title {
  font-weight: 600;
  font-size: 12.5px;
}

/* ----------------------------------------------------------------- buttons */
.hr-button {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fafafa;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.hr-button:hover { opacity: .92; }
.hr-button:disabled { opacity: .45; cursor: not-allowed; }
.hr-button--outline {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.hr-button--outline:hover { background: var(--surface-2); opacity: 1; }
.hr-button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.hr-button--ghost:hover { background: var(--surface-2); }

/* ----------------------------------------------------------------- input */
.hr-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 9px 10px;
  outline: none;
  resize: vertical;
  line-height: 1.45;
}
.hr-input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hr-input:disabled { background: var(--surface-2); color: var(--ink-3); }

/* ----------------------------------------------------------------- footer */
.hr-footer {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 11.5px;
}
#footerSession {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ew-footer-handover {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-2);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hr-footer-hint {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* ----------------------------------------------------------------- anims */
@keyframes ew-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, .55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(56, 189, 248, 0); }
}
@keyframes ew-drawer-in {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ----------------------------------------------------------------- resp. */
@media (max-width: 1220px) {
  .ew-icon-label { display: none; }
  .ew-icon-btn { width: 32px; padding: 0; }
  .ew-brand-copy .brand-sub { display: none; }
}

@media (max-width: 1120px) {
  .ew-right-drawer {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(var(--drawer-w), 100vw);
    z-index: 40;
    box-shadow: var(--shadow-up);
  }
}

@media (max-width: 960px) {
  .hr-shell,
  .ew-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }
  .ew-topbar {
    flex: 0 0 auto;
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px 10px;
  }
  .ew-topbar-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .ew-agent-pill { display: none; }
  .identity-state {
    min-width: 0;
    max-width: min(210px, 42vw);
    padding: 3px 8px;
    font-size: 11.5px;
  }
  .ew-topbar-right { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .ew-topbar-sep { display: none; }

  .ew-workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  /* Collapse left sidebar into a compact single-row mobile/tablet agent bar */
  .ew-left-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--roster-line);
    padding: 6px 10px;
    gap: 0;
    flex: 0 0 auto;
  }
  .ew-left-sidebar.is-roster-open {
    gap: 8px;
    padding-bottom: 10px;
  }
  .ew-sidebar-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    width: 100%;
  }
  .ew-pinned-section {
    padding: 0;
    border-bottom: 0;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
  }
  .ew-pinned-orchestrator {
    padding: 4px 8px;
    gap: 6px;
  }
  .ew-pinned-orchestrator .ew-bot-avatar {
    width: 22px;
    height: 22px;
    font-size: 9.5px;
    flex: 0 0 22px;
  }
  .ew-roster-section-label,
  .ew-roster-group-title,
  .ew-bot-desc,
  .ew-bot-tag,
  .ew-bot-badge,
  .ew-left-sidebar .hr-bot-sub,
  .ew-left-sidebar .hr-bot-details {
    display: none;
  }
  .ew-handover-banner {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .ew-handover-head { margin-bottom: 0; flex: 0 0 auto; }
  .ew-handover-kicker { display: none; }
  .ew-handover-route {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .ew-roster-toggle {
    flex: 0 0 auto;
    height: 30px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 9px;
    border: 1px solid var(--roster-line);
    border-radius: var(--r-sm);
    background: var(--roster-surface);
    color: var(--roster-ink-2);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .ew-roster-toggle:hover {
    background: var(--roster-hover);
    color: var(--roster-ink);
  }
  .ew-roster-toggle svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .15s ease;
  }
  .ew-left-sidebar.is-roster-open .ew-roster-toggle svg {
    transform: rotate(180deg);
  }
  .ew-roster-list,
  .ew-sidebar-foot {
    display: none;
  }
  .ew-left-sidebar.is-roster-open .ew-roster-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 6px;
    padding: 2px 0 0;
    max-height: 28vh;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .ew-left-sidebar.is-roster-open .ew-sidebar-foot {
    display: block;
    padding: 0;
    border-top: 0;
  }
  .ew-bot-group {
    display: contents;
  }
  .ew-bot-item,
  .ew-left-sidebar .hr-bot-item,
  .ew-left-sidebar .hr-bot-item[data-tier="2"],
  .ew-left-sidebar .hr-bot-item[data-tier="department"],
  .ew-left-sidebar .hr-bot-item[data-tier="3"],
  .ew-left-sidebar .hr-bot-item[data-tier="leaf"],
  .ew-left-sidebar .hr-bot-item[data-tier="governance"],
  .ew-left-sidebar .hr-bot-item[data-tier="platform"] {
    width: auto;
    margin-left: 0;
    flex: 0 1 auto;
    margin-bottom: 0;
    padding: 6px 9px;
    border: 1px solid var(--roster-line);
    background: var(--roster-surface);
  }
  .ew-marketplace-cta {
    height: 32px;
  }

  .ew-center-console { min-height: 0; min-width: 0; overflow: hidden; }
  .ew-chat-stage { min-height: 0; padding: 0; }
  .ew-welcome { width: calc(100% - 24px); margin: 14px auto; padding: 16px; }
  .ew-messages { padding: 12px; }
  .ew-focus-strip { padding: 6px 12px; }
  .ew-focus-badges { display: none; }
  .ew-center-surfaces {
    padding: 10px 12px;
    max-height: 40vh;
    overflow-y: auto;
    grid-template-columns: minmax(0, 1fr);
  }
  .hr-composer,
  .ew-composer { padding: 8px 12px 10px; }
  .hr-composer-hint { display: none; }

  .ew-right-drawer {
    top: 0;
    width: min(var(--drawer-w), 100vw);
    z-index: 50;
  }

  .hr-footer {
    padding: 6px 12px;
    gap: 8px;
    font-size: 11px;
  }
  .ew-footer-handover { display: none; }
  .hr-footer-hint { text-align: right; white-space: nowrap; }
}

@media (max-width: 640px) {
  .ew-topbar-left { flex: 1 0 100%; justify-content: space-between; }
  .ew-topbar-right {
    flex: 1 0 100%;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }
  .identity-state { max-width: 48vw; }
  .ew-pinned-orchestrator .ew-bot-meta { display: none; }
  .ew-welcome { width: calc(100% - 16px); margin: 10px auto; padding: 14px; }
  .ew-messages { padding: 10px; }
  .hr-message { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
  .hr-message--user { grid-template-columns: minmax(0, 1fr) 24px; }
  .hr-message--user > div:last-child { max-width: 92%; }
  .hr-avatar { width: 24px; height: 24px; font-size: 8.5px; border-radius: 6px; }
  .hr-input { font-size: 16px; min-height: 44px; padding: 8px 10px; }
  .ew-composer-slash-hint { display: none; }
  .hr-starters { grid-template-columns: 1fr; }
  .hr-kv > div { grid-template-columns: 84px minmax(0, 1fr); gap: 6px; }
  .ew-right-drawer { width: 100vw; max-width: 100vw; }
  .hr-login-card { padding: 24px 18px; }
  .hr-footer-hint { display: none; }
}

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