/* XSEDES COS · interface styles · Brand Guidelines v3.0 (dark interface)
   Chrome stays #000000 / #2DDDA8 / #313131 / #FFFFFF. Light fields (glow) sit behind hero areas only. */

@font-face {
  font-family: "Inter";
  src: url("/assets/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --xs-black: #000000;
  --xs-green: #2DDDA8;
  --xs-gray: #313131;
  --xs-white: #FFFFFF;
  --xs-t70: rgba(255, 255, 255, .70);
  --xs-t55: rgba(255, 255, 255, .55);
  --xs-t40: rgba(255, 255, 255, .40);
  --xs-t12: rgba(255, 255, 255, .12);
  --xs-t06: rgba(255, 255, 255, .06);
  --xs-t03: rgba(255, 255, 255, .03);

  /* Functional status tones (interface states only, never brand fills) */
  --st-ok: #2DDDA8;
  --st-warn: #F2B544;
  --st-danger: #FF7A7A;
  --st-info: #9DC8FF;

  /* Light tokens · approved L1 (xsedes-light.css) */
  --xs-glow-core-alpha: .34;
  --xs-glow-mid-alpha: .14;
  --xs-glow-edge-alpha: .03;
  --xs-grain-opacity: .035;
  --xs-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-h1: clamp(26px, 1.4rem + .6vw, 32px);
  --fs-h2: 18px;
  --fs-body: 15px;
  --fs-small: 13px;
  --fs-label: 11px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s12: 48px; --s16: 64px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --topbar: 60px;
  --nav-w: 232px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --t-micro: 120ms;
  --t-comp: 200ms;
  --focus: 0 0 0 2px var(--xs-black), 0 0 0 4px var(--xs-green);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--xs-black); color: var(--xs-white);
  font-family: var(--font); font-size: var(--fs-body); line-height: 1.55;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
body.is-booting #gate, body.is-booting #workspace { visibility: hidden; }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--xs-white); text-underline-offset: 3px; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
::selection { background: rgba(45, 221, 168, .35); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; box-shadow: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s4); top: -100px; z-index: 100; background: var(--xs-green); color: var(--xs-black); padding: var(--s2) var(--s4); border-radius: var(--r-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: var(--s4); }
.muted { color: var(--xs-t55); }
.eyebrow { font-size: var(--fs-label); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--xs-t55); }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ---- Light field (from xsedes-light.css) ---- */
.xs-field {
  position: relative; isolation: isolate;
  background: radial-gradient(ellipse var(--glow-size, 60% 55%) at var(--glow-x, 50%) var(--glow-y, 50%),
    rgba(45,221,168,var(--xs-glow-core-alpha)) 0%, rgba(45,221,168,var(--xs-glow-mid-alpha)) 35%,
    rgba(45,221,168,var(--xs-glow-edge-alpha)) 62%, rgba(0,0,0,0) 85%), #000;
}
.xs-field::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--xs-grain); opacity: var(--xs-grain-opacity); mix-blend-mode: screen; border-radius: inherit;
}
.xs-field > * { position: relative; z-index: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5); border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; letter-spacing: .01em; cursor: pointer; text-decoration: none;
  transition: background var(--t-micro) var(--ease), border-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease), transform var(--t-micro) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--sm { min-height: 36px; padding: 0 var(--s4); font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--xs-green); color: var(--xs-black); }
.btn--primary:hover:not(:disabled) { background: #5BE7BC; }
.btn--secondary { background: transparent; border-color: var(--xs-t40); color: var(--xs-white); }
.btn--secondary:hover:not(:disabled) { border-color: var(--xs-white); background: var(--xs-t06); }
.btn--ghost { background: transparent; color: var(--xs-t70); }
.btn--ghost:hover:not(:disabled) { color: var(--xs-white); background: var(--xs-t06); }
.btn--danger { background: transparent; border-color: rgba(255,122,122,.55); color: var(--st-danger); }
.btn--danger:hover:not(:disabled) { background: rgba(255,122,122,.1); }
.btn--link { background: none; border: 0; padding: 0 2px; min-height: 32px; color: var(--xs-t70); text-decoration: underline; font-weight: 500; }
.btn--link:hover { color: var(--xs-white); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; background: transparent; border-radius: var(--r-md); cursor: pointer; }
.icon-btn:hover { background: var(--xs-t06); }

/* ---- Forms ---- */
.label, .field label, .decision label { display: block; font-size: var(--fs-small); font-weight: 500; color: var(--xs-t70); margin-bottom: var(--s2); }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; background: var(--xs-black); color: var(--xs-white);
  border: 1px solid var(--xs-t40); border-radius: var(--r-md); transition: border-color var(--t-micro) var(--ease);
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--xs-t55); }
input:hover, select:hover, textarea:hover { border-color: var(--xs-t70); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--xs-green); box-shadow: 0 0 0 1px var(--xs-green); border-radius: var(--r-md); }
input[aria-invalid="true"] { border-color: var(--st-danger); }
.field { margin-bottom: var(--s3); }
.help { font-size: var(--fs-small); color: var(--xs-t55); margin-top: var(--s2); }
.form-error { color: var(--st-danger); font-size: var(--fs-small); min-height: 0; }
.form-error:not(:empty) { margin: var(--s2) 0 var(--s3); }

/* ---- Badges, notices ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; border: 1px solid currentColor;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--signal { color: var(--xs-green); background: rgba(45,221,168,.08); }
.badge--ok { color: var(--st-ok); background: rgba(45,221,168,.08); }
.badge--warn { color: var(--st-warn); background: rgba(242,181,68,.08); }
.badge--danger { color: var(--st-danger); background: rgba(255,122,122,.08); }
.badge--info { color: var(--st-info); background: rgba(157,200,255,.08); }
.badge--muted { color: var(--xs-t70); border-color: var(--xs-t40); background: transparent; }
.notice { padding: var(--s4); border-radius: var(--r-md); border: 1px solid var(--xs-gray); }
.notice--error { border-color: rgba(255,122,122,.5); color: var(--st-danger); background: rgba(255,122,122,.06); }
.empty { padding: var(--s12) var(--s6); text-align: center; border: 1px dashed var(--xs-gray); border-radius: var(--r-lg); }
.empty__title { font-weight: 600; }
.empty__body { color: var(--xs-t55); margin-top: var(--s2); font-size: var(--fs-small); }
.loading { display: flex; align-items: center; gap: var(--s3); color: var(--xs-t55); padding: var(--s6) 0; font-size: var(--fs-small); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--xs-gray); border-top-color: var(--xs-green); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fmt { display: inline-grid; place-items: center; flex: none; width: 38px; height: 44px; border-radius: var(--r-sm); border: 1px solid var(--xs-t40); font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--xs-white); background: var(--xs-t03); }
.fmt--pdf { border-color: rgba(255,122,122,.6); }
.fmt--xlsx { border-color: rgba(45,221,168,.6); }
.fmt--docx { border-color: rgba(157,200,255,.6); }
.fmt--pptx { border-color: rgba(242,181,68,.6); }

/* ---- Toasts ---- */
.toasts { position: fixed; right: var(--s4); top: calc(var(--topbar) + var(--s3)); display: grid; gap: var(--s2); z-index: 60; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: #0b0b0b; border: 1px solid var(--xs-gray); border-left: 3px solid var(--st-info); padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: var(--fs-small); transition: opacity var(--t-comp) var(--ease), transform var(--t-comp) var(--ease); }
.toast--ok { border-left-color: var(--xs-green); }
.toast--error { border-left-color: var(--st-danger); }
.toast--out { opacity: 0; transform: translateY(6px); }

/* ======================= Access gate ======================= */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: var(--s8) var(--s4); --glow-y: 92%; --glow-size: 70% 50%; }
.gate__inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.gate__lockup { width: 200px; height: auto; margin-bottom: var(--s8); }
.gate__title { font-size: 15px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-bottom: var(--s8); }
.gate__dot { color: var(--xs-green); }
.gate__sub { color: var(--xs-t70); font-weight: 500; }
.gate__card {
  width: 100%; text-align: left; padding: var(--s8); border-radius: var(--r-lg);
  background: rgba(0,0,0,.72); border: 1px solid var(--xs-gray); backdrop-filter: blur(8px);
}
.gate__card .btn--primary { margin-top: var(--s2); }
.gate__card--wide { max-width: 520px; }
.gate__step { font-size: 20px; font-weight: 600; margin-bottom: var(--s5); }
.gate__foot { margin-top: var(--s8); font-size: var(--fs-small); color: var(--xs-t55); letter-spacing: .04em; }
.profiles { list-style: none; padding: 0; margin: 0 0 var(--s3); display: grid; gap: var(--s3); }
.profile {
  width: 100%; display: flex; align-items: center; gap: var(--s4); padding: var(--s4); text-align: left; cursor: pointer;
  background: var(--xs-black); border: 1px solid var(--xs-gray); border-radius: var(--r-md);
  transition: border-color var(--t-micro) var(--ease), background var(--t-micro) var(--ease);
}
.profile:hover:not(:disabled) { border-color: var(--xs-green); background: rgba(45,221,168,.04); }
.profile:disabled { opacity: .5; }
.profile__avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 14px; border: 1px solid var(--xs-t40); }
.profile__text { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.profile__name { font-weight: 600; font-size: 16px; }

/* ======================= Workspace ======================= */
.ws { min-height: 100dvh; display: grid; grid-template-columns: var(--nav-w) 1fr; grid-template-rows: var(--topbar) 1fr; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s5);
  border-bottom: 1px solid var(--xs-gray); background: var(--xs-black); position: sticky; top: 0; z-index: 30;
}
.topbar__menu { display: none; }
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; padding: 4px; }
.brand img { width: 22px; height: auto; }
.brand__name { font-weight: 700; letter-spacing: .14em; font-size: 14px; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--s4); min-width: 0; }
.budget-pill {
  font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  border: 1px solid rgba(45,221,168,.45); color: var(--xs-white); background: rgba(45,221,168,.06);
}
.budget-pill::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--xs-green); margin-right: 8px; vertical-align: middle; }
.budget-pill--low { border-color: rgba(242,181,68,.6); }
.budget-pill--low::before { background: var(--st-warn); }
.budget-pill--blocked { border-color: rgba(255,122,122,.6); }
.budget-pill--blocked::before { background: var(--st-danger); }
.user { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.user__name { font-weight: 600; font-size: 13.5px; }
.user__role { font-size: 12px; color: var(--xs-t55); }

.nav { border-right: 1px solid var(--xs-gray); padding: var(--s6) var(--s3); display: flex; flex-direction: column; position: sticky; top: var(--topbar); height: calc(100dvh - var(--topbar)); background: var(--xs-black); }
.nav__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav__group { font-size: var(--fs-label); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--xs-t55); padding: var(--s6) var(--s3) var(--s2); }
.nav__link {
  display: flex; align-items: center; min-height: 40px; padding: 0 var(--s3); border-radius: var(--r-md);
  text-decoration: none; color: var(--xs-t70); font-weight: 500; font-size: 14px; position: relative;
  transition: background var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.nav__link:hover { background: var(--xs-t06); color: var(--xs-white); }
.nav__link[aria-current="page"] { color: var(--xs-white); background: var(--xs-t06); }
.nav__link[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--xs-green); }
.nav__foot { margin-top: auto; padding: var(--s3); opacity: .55; }
.nav__foot img { width: 96px; height: auto; }
.nav-backdrop { display: none; }

.main { min-width: 0; outline: none; }
.view { min-width: 0; }

/* ---- Pages ---- */
.page { padding: var(--s8) clamp(16px, 3vw, 48px) var(--s16); max-width: 1240px; }
.page__head { display: flex; gap: var(--s4); align-items: flex-end; justify-content: space-between; margin-bottom: var(--s8); flex-wrap: wrap; }
.page__title { font-size: var(--fs-h1); font-weight: 600; letter-spacing: -.01em; outline: none; }
.page__lede { color: var(--xs-t55); margin-top: var(--s2); }
.section-title { font-size: var(--fs-h2); font-weight: 600; margin: var(--s12) 0 var(--s4); }

.table-wrap { overflow-x: auto; border: 1px solid var(--xs-gray); border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: var(--fs-label); letter-spacing: .1em; text-transform: uppercase; color: var(--xs-t55); font-weight: 600; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--xs-gray); white-space: nowrap; }
.table td { padding: var(--s4); border-bottom: 1px solid var(--xs-t12); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--xs-t03); }
.col-action { text-align: right; }
.table td:not(.col-main) { white-space: nowrap; }
.table td.col-main { min-width: 240px; }
.file-cell { display: flex; align-items: center; gap: var(--s3); }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--xs-t55); font-size: var(--fs-small); word-break: break-all; }
.hash { display: inline-flex; align-items: center; gap: var(--s2); background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 4px 6px; cursor: pointer; color: var(--xs-t70); }
.hash:hover { border-color: var(--xs-t40); color: var(--xs-white); }
.hash__copy { font-size: 11px; font-weight: 600; color: var(--xs-green); }

.search { display: flex; gap: var(--s3); max-width: 720px; margin-bottom: var(--s6); }
.kb-count { color: var(--xs-t55); font-size: var(--fs-small); margin-bottom: var(--s4); }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cards--wide { grid-template-columns: 1fr; max-width: 900px; }
.card { border: 1px solid var(--xs-gray); border-radius: var(--r-lg); padding: var(--s6); display: flex; flex-direction: column; gap: var(--s3); background: linear-gradient(180deg, var(--xs-t03), transparent 60%); }
.card__meta { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; font-size: var(--fs-small); color: var(--xs-t55); }
.card__title { font-size: 17px; font-weight: 600; line-height: 1.35; }
.card__body { color: var(--xs-t70); font-size: 14px; }
.card__foot { color: var(--xs-t55); font-size: var(--fs-small); margin-top: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: 0; font-size: 14px; }
.kv dt { color: var(--xs-t55); text-transform: capitalize; }
.kv dd { margin: 0; }
.handoff { border-top: 1px solid var(--xs-gray); padding-top: var(--s4); display: grid; gap: var(--s2); justify-items: start; }
.handoff__pre, .md-pre { width: 100%; margin: 0; padding: var(--s4); background: #0a0a0a; border: 1px solid var(--xs-gray); border-radius: var(--r-md); overflow: auto; max-height: 360px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.decision { border-top: 1px solid var(--xs-gray); padding-top: var(--s4); }
.decision .row { margin-top: var(--s3); }

.panel { border: 1px solid var(--xs-gray); border-radius: var(--r-lg); padding: var(--s6); }
.panel__title { font-size: 15px; font-weight: 600; margin-bottom: var(--s4); }
.panel--hero { --glow-x: 85%; --glow-y: 0%; --glow-size: 50% 90%; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); margin-top: var(--s4); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.stat__label { font-size: var(--fs-label); letter-spacing: .12em; text-transform: uppercase; color: var(--xs-t55); font-weight: 600; }
.stat__value { font-size: clamp(22px, 1.2rem + 1vw, 32px); font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat__value--signal { color: var(--xs-green); }
.meter { display: flex; height: 10px; border-radius: 999px; background: var(--xs-t12); overflow: hidden; }
.meter__settled { background: var(--xs-white); }
.meter__reserved { background: repeating-linear-gradient(135deg, var(--xs-t70) 0 4px, var(--xs-t40) 4px 8px); }
.meter__legend { margin-top: var(--s3); font-size: var(--fs-small); color: var(--xs-t70); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.key:first-child { margin-left: 0; }
.key--settled { background: var(--xs-white); }
.key--reserved { background: var(--xs-t55); }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: var(--s3); align-items: center; font-size: 14px; }
.hbar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--xs-t70); }
.hbar__track { height: 8px; background: var(--xs-t06); border-radius: 999px; overflow: hidden; }
.hbar__fill { display: block; height: 100%; background: var(--xs-white); border-radius: 999px; }
.hbar__value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ======================= Chat ======================= */
.ws.is-chat .main { height: calc(100dvh - var(--topbar)); overflow: hidden; }
.view--chat, .chat { height: 100%; }
.chat { display: grid; grid-template-columns: 280px 1fr; }
.chat__list { border-right: 1px solid var(--xs-gray); padding: var(--s5) var(--s3); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s3); }
.chat__list-head { display: grid; gap: var(--s3); padding: 0 var(--s2); }
.new-conv { padding: var(--s4); border: 1px solid var(--xs-gray); border-radius: var(--r-md); }
.conv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.conv-list__empty { color: var(--xs-t55); font-size: var(--fs-small); padding: var(--s2); }
.conv { width: 100%; text-align: left; background: none; border: 0; border-radius: var(--r-md); padding: 10px var(--s3); cursor: pointer; display: grid; gap: 2px; position: relative; }
.conv:hover { background: var(--xs-t06); }
.conv[aria-current="true"] { background: var(--xs-t06); }
.conv[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--xs-green); }
.conv__title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv__meta { font-size: 12px; color: var(--xs-t55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat__main { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; }
.chat__head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--xs-gray); min-width: 0; }
.chat__head > div { min-width: 0; }
.chat__list-toggle { display: none; }
.chat__title { font-size: 17px; font-weight: 600; outline: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__sub { font-size: 12.5px; color: var(--xs-t55); }
.chat__sub:empty { display: none; }
.thread { overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.thread__inner { max-width: 820px; margin: 0 auto; padding: var(--s8) clamp(16px, 3vw, 40px); display: flex; flex-direction: column; gap: var(--s6); }

.welcome { padding: var(--s12) var(--s6) var(--s8); border-radius: var(--r-lg); position: relative; isolation: isolate; overflow: hidden; }
.welcome::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 55% 70% at 50% 0%, rgba(45,221,168,.20) 0%, rgba(45,221,168,.07) 40%, rgba(45,221,168,.015) 65%, rgba(0,0,0,0) 85%);
}
.welcome__eyebrow { font-size: var(--fs-label); letter-spacing: .14em; text-transform: uppercase; color: var(--xs-green); font-weight: 600; margin-bottom: var(--s3); }
.welcome__title { font-size: clamp(26px, 1.4rem + 1.2vw, 36px); font-weight: 600; letter-spacing: -.015em; margin-bottom: var(--s3); }
.welcome__body { color: var(--xs-t70); max-width: 560px; margin-bottom: var(--s6); }
.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.suggestion { width: 100%; text-align: left; padding: var(--s3) var(--s4); background: rgba(0,0,0,.6); border: 1px solid var(--xs-gray); border-radius: var(--r-md); cursor: pointer; color: var(--xs-t70); font-size: 14px; transition: border-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease); }
.suggestion:hover { border-color: var(--xs-t40); color: var(--xs-white); }

.msg { display: grid; gap: var(--s2); }
.msg__head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 12.5px; color: var(--xs-t55); }
.msg__who { font-weight: 600; color: var(--xs-white); font-size: 13px; letter-spacing: .04em; }
.msg__avatar { width: 18px; height: auto; }
.msg__badges { display: inline-flex; gap: var(--s2); margin-left: var(--s1); }
.msg--user { align-self: flex-end; max-width: min(620px, 92%); }
.msg--user .msg__head { justify-content: flex-end; }
.msg--user .msg__body { background: var(--xs-t06); border: 1px solid var(--xs-t12); border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg); padding: var(--s3) var(--s4); }
.msg__body--plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--cos .msg__body { display: grid; gap: var(--s3); overflow-wrap: anywhere; }
.msg--cos .msg__body:empty { display: none; }
.msg__body ul, .msg__body ol { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.msg__body code { background: var(--xs-t06); border: 1px solid var(--xs-t12); border-radius: 4px; padding: 1px 5px; }
.msg__body strong { font-weight: 650; }
.md-h { font-size: 15px; font-weight: 650; margin-top: var(--s2); }
.md-table-wrap { overflow-x: auto; border: 1px solid var(--xs-gray); border-radius: var(--r-md); }
.md-table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.md-table th, .md-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--xs-t12); }
.md-table th { color: var(--xs-t70); font-weight: 600; border-bottom-color: var(--xs-gray); }
.md-table tr:last-child td { border-bottom: 0; }
.msg__files, .msg__actions { display: grid; gap: var(--s2); }
.msg > .btn--link { justify-self: start; }
.msg__files:empty, .msg__actions:empty { display: none; }

.run__live { border-left: 1px solid var(--xs-gray); padding-left: var(--s4); margin-left: 8px; }
.run__status { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--xs-t70); margin-bottom: var(--s2); }
.msg:not(.msg--pending) .run__status { display: none; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--xs-green); box-shadow: 0 0 0 0 rgba(45,221,168,.5); animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(45,221,168,.45); } 70% { box-shadow: 0 0 0 8px rgba(45,221,168,0); } 100% { box-shadow: 0 0 0 0 rgba(45,221,168,0); } }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.step { display: grid; grid-template-columns: 10px 1fr auto; gap: var(--s3); align-items: baseline; font-size: 13px; color: var(--xs-t70); animation: step-in var(--t-comp) var(--ease); }
@keyframes step-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.step__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--xs-t40); transform: translateY(-1px); }
.step--call .step__dot { background: var(--xs-green); }
.step--ok .step__dot { background: var(--st-ok); }
.step--warn .step__dot { background: var(--st-warn); }
.step--danger .step__dot { background: var(--st-danger); }
.step__body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; overflow-wrap: anywhere; }
.step--note .step__body { color: var(--xs-white); font-style: italic; }
.step--call .step__body strong { color: var(--xs-white); font-weight: 600; }
.step__route { white-space: nowrap; }
.step__time { font-size: 11.5px; color: var(--xs-t55); font-variant-numeric: tabular-nums; white-space: nowrap; }
.step .badge { height: 19px; font-size: 10.5px; padding: 0 7px; }
.worklog { border: 1px solid var(--xs-t12); border-radius: var(--r-md); padding: 0 var(--s4); }
.worklog summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; font-size: 13px; color: var(--xs-t70); list-style-position: inside; }
.worklog summary:hover { color: var(--xs-white); }
.worklog[open] { padding-bottom: var(--s4); }

.chip-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: var(--s3); max-width: 100%; padding: 8px 14px 8px 8px; text-align: left; cursor: pointer;
  background: var(--xs-black); border: 1px solid var(--xs-t40); border-radius: var(--r-md);
  transition: border-color var(--t-micro) var(--ease), background var(--t-micro) var(--ease);
}
.chip:hover:not(:disabled) { border-color: var(--xs-green); background: rgba(45,221,168,.04); }
.chip__text { display: grid; min-width: 0; }
.chip__title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__meta { font-size: 12px; color: var(--xs-t55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__dl { color: var(--xs-green); font-weight: 700; margin-left: var(--s2); }
.proposal { border: 1px solid rgba(45,221,168,.35); border-radius: var(--r-md); padding: var(--s4); display: grid; gap: var(--s2); justify-items: start; background: rgba(45,221,168,.03); }
.proposal__label { font-size: var(--fs-label); letter-spacing: .12em; text-transform: uppercase; color: var(--xs-green); font-weight: 600; }
.proposal__title { font-weight: 600; }
.proposal__body { font-size: 13.5px; color: var(--xs-t70); }
.proposal__status { font-size: 13px; color: var(--xs-t70); }
.proposal__status:empty { display: none; }

.composer { padding: var(--s3) clamp(16px, 3vw, 40px) var(--s4); border-top: 1px solid var(--xs-gray); background: var(--xs-black); }
.composer__box { max-width: 820px; margin: 0 auto; display: flex; gap: var(--s2); align-items: flex-end; border: 1px solid var(--xs-t40); border-radius: var(--r-lg); padding: 6px 6px 6px var(--s4); transition: border-color var(--t-micro) var(--ease); }
.composer__box:focus-within { border-color: var(--xs-green); box-shadow: 0 0 0 1px var(--xs-green); }
.composer textarea { border: 0; padding: 10px 0; min-height: 44px; max-height: 220px; resize: none; background: transparent; }
.composer textarea:focus-visible { box-shadow: none; }
.composer__send { flex: none; }
.composer__hint, .composer .form-error { max-width: 820px; margin: var(--s2) auto 0; font-size: 12px; color: var(--xs-t55); }
.composer .form-error { color: var(--st-danger); }

/* ======================= Responsive ======================= */
@media (max-width: 1100px) {
  .chat { grid-template-columns: 1fr; position: relative; }
  .chat__list { position: absolute; z-index: 20; inset: 0 auto 0 0; width: min(320px, 88vw); background: var(--xs-black); border-right: 1px solid var(--xs-gray); transform: translateX(-102%); visibility: hidden; transition: transform var(--t-comp) var(--ease), visibility 0s linear var(--t-comp); box-shadow: 24px 0 48px rgba(0,0,0,.6); }
  .chat__list.is-open { transform: none; visibility: visible; transition: transform var(--t-comp) var(--ease); }
  .chat__list-toggle { display: inline-flex; flex: none; }
}
@media (max-width: 900px) {
  .ws { grid-template-columns: 1fr; }
  .topbar { padding: 0 var(--s2) 0 var(--s1); gap: var(--s2); }
  .topbar__menu { display: inline-grid; }
  .nav { position: fixed; z-index: 40; top: var(--topbar); left: 0; bottom: 0; height: auto; width: min(280px, 84vw); transform: translateX(-102%); visibility: hidden; transition: transform var(--t-comp) var(--ease), visibility 0s linear var(--t-comp); }
  .nav.is-open { transform: none; visibility: visible; transition: transform var(--t-comp) var(--ease); }
  .nav-backdrop { display: block; position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0,0,0,.6); z-index: 35; }
  .user__role { display: none; }
}
@media (max-width: 720px) {
  .user { display: none; }
  .budget-pill { font-size: 11.5px; padding: 5px 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page__head { margin-bottom: var(--s6); }
  .table-wrap { border: 0; overflow: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--xs-gray); border-radius: var(--r-lg); padding: var(--s2) var(--s4); margin-bottom: var(--s3); }
  .table td { display: grid; grid-template-columns: 96px 1fr; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--xs-t06); text-align: left; }
  .table td::before { content: attr(data-label); font-size: var(--fs-label); letter-spacing: .1em; text-transform: uppercase; color: var(--xs-t55); font-weight: 600; }
  .table td.col-main { grid-template-columns: 1fr; min-width: 0; }
  .table td:not(.col-main) { white-space: normal; }
  .table td.col-main::before { display: none; }
  .table tbody tr:hover td { background: none; }
  .search { flex-direction: column; }
  .gate__card { padding: var(--s6); }
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: var(--s2); }
}
@media (max-width: 420px) {
  .budget-pill { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .topbar .btn--sm { padding: 0 var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .pulse { animation: none; }
}
@media (forced-colors: active) {
  .badge, .btn, .chip, .card { border: 1px solid CanvasText; }
  .nav__link[aria-current="page"] { outline: 2px solid Highlight; }
}

/* Dev mock indicator (only present with ?mock=1) */
.mock-banner { position: fixed; left: 8px; bottom: 8px; z-index: 70; margin: 0; padding: 3px 10px; border-radius: 999px; font-size: 11px; color: var(--xs-black); background: var(--st-warn); pointer-events: none; opacity: .9; }

/* Burger icon, compact topbar, mobile card cells */
.burger { display: grid; gap: 4px; width: 18px; }
.burger span { display: block; height: 2px; border-radius: 2px; background: var(--xs-white); transition: transform var(--t-comp) var(--ease), opacity var(--t-comp) var(--ease); }
.topbar__menu[aria-expanded="true"] .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar__menu[aria-expanded="true"] .burger span:nth-child(2) { opacity: 0; }
.topbar__menu[aria-expanded="true"] .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.topbar .btn { white-space: nowrap; }
.pill-short { display: none; }
@media (max-width: 720px) {
  .table td > .badge, .table td > .btn, .table td > .hash { justify-self: start; }
}
@media (max-width: 520px) {
  .pill-label, .pill-of { display: none; }
  .pill-short { display: inline; }
  .budget-pill { max-width: none; }
  .brand__name { display: none; }
}
