/* ==========================================================================
   AI Tawin Workspace — full-screen chat shell
   Loaded after portal.css so it owns the application layout.
   ========================================================================== */

[hidden] {
  display: none !important;
}

body.ws-body.is-app {
  height: 100dvh;
  overflow: hidden;
}

.ws-app {
  --side-w-user: 292px;
  --side-w: var(--side-w-user);
  position: relative;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  isolation: isolate;
}

.ws-app[hidden] {
  display: none;
}

.ws-app.is-collapsed {
  --side-w: 78px;
}

.ws-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  background: rgba(8, 15, 24, 0.46);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* ------------------------------------------------------------------ side */

.ws-side {
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--glass-bar);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
}

.ws-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  height: 60px;
  padding: 0 12px 0 14px;
}

.ws-brand .brand-mark {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
}

.ws-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.ws-brand-name {
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.ws-brand-sub {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.ws-collapse {
  margin-left: auto;
  flex: 0 0 auto;
}

.ws-newchat {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  margin: 0 12px 12px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-2) var(--ease), border-color var(--t-2) var(--ease), transform var(--t-2) var(--ease);
}

.ws-newchat:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent);
}

.ws-newchat:active {
  transform: translateY(1px);
}

.ws-newchat svg {
  width: 15px;
  height: 15px;
}

.ws-newchat kbd {
  margin-left: auto;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.ws-history-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 0 12px 8px;
}

.ws-search {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  transition: border-color var(--t-2) var(--ease), box-shadow var(--t-2) var(--ease);
}

.ws-search:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--ring);
}

.ws-search svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex: 0 0 auto;
}

.ws-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 11.5px;
  outline: 0;
}

.ws-history {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 10px;
  scrollbar-width: thin;
}

.ws-history-empty {
  padding: 26px 12px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

.ws-hgroup {
  margin-top: 10px;
}

.ws-hgroup:first-child {
  margin-top: 0;
}

.ws-hlabel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ws-hrow {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin-bottom: 1px;
  border-radius: var(--r-sm);
}

.ws-hrow.is-active {
  background: var(--accent-soft);
}

.ws-hrow.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.ws-hopen {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 8px 6px 8px 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ws-hrow:hover .ws-hopen {
  background: var(--glass-soft);
}

.ws-hemoji {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--accent);
  font-size: 11px;
}

.ws-hcopy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ws-hcopy b {
  display: block;
  overflow: hidden;
  color: var(--fg-2);
  font-size: 11.8px;
  font-weight: 560;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-hrow.is-active .ws-hcopy b {
  color: var(--accent);
  font-weight: 650;
}

.ws-hcopy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-hpin {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  color: var(--accent);
}

.ws-hmore {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
}

.ws-hrow:hover .ws-hmore,
.ws-hrow.is-active .ws-hmore,
.ws-hmore:focus-visible {
  opacity: 1;
}

.ws-hmore:hover {
  background: var(--glass-strong);
  color: var(--fg);
}

.ws-hmore svg {
  width: 13px;
  height: 13px;
}

.ws-nav {
  display: grid;
  gap: 2px;
  flex: 0 0 auto;
  margin: 0 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.ws-navbtn,
.ws-nav .navbtn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 33px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease);
}

.ws-navbtn:hover,
.ws-nav .navbtn:hover {
  background: var(--glass-soft);
  color: var(--fg-2);
}

.ws-navbtn.is-active,
.ws-nav .navbtn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.ws-navbtn svg,
.ws-nav .navbtn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.ws-nav .ws-archive-back {
  justify-content: center;
  min-height: 28px;
  font-size: 10.5px;
}

.ws-side-foot {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}

.ws-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 2px 7px;
}

.ws-user .avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  font-size: 9.5px;
}

.ws-user-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.2;
}

.ws-user-copy b {
  overflow: hidden;
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-user-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-user .icon-btn {
  width: 26px;
  height: 26px;
}

.ws-user .icon-btn svg {
  width: 14px;
  height: 14px;
}

.ws-side-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 2px 1px;
  color: var(--muted);
  font-size: 10px;
  text-decoration: none;
}

.ws-side-link:hover {
  color: var(--accent);
}

.ws-side-link svg {
  width: 11px;
  height: 11px;
}

.ws-resize {
  position: absolute;
  z-index: 5;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
}

.ws-resize:hover,
.ws-app.is-resizing .ws-resize {
  background: var(--accent-line);
}

.ws-app.is-collapsed .ws-brand-copy,
.ws-app.is-collapsed .ws-newchat span,
.ws-app.is-collapsed .ws-newchat kbd,
.ws-app.is-collapsed .ws-history-head,
.ws-app.is-collapsed .ws-history,
.ws-app.is-collapsed .ws-navbtn span,
.ws-app.is-collapsed .ws-nav .navbtn span,
.ws-app.is-collapsed .ws-user-copy,
.ws-app.is-collapsed .ws-side-link span,
.ws-app.is-collapsed .ws-user #sideTheme,
.ws-app.is-collapsed .ws-user #logoutBtn {
  display: none;
}

.ws-app.is-collapsed .ws-brand {
  justify-content: center;
  padding: 0;
}

.ws-app.is-collapsed .ws-collapse {
  display: none;
}

.ws-app.is-collapsed .ws-newchat {
  justify-content: center;
  margin: 0 10px 10px;
  padding: 0;
}

.ws-app.is-collapsed .ws-nav {
  margin: 0 8px;
  padding-top: 8px;
}

.ws-app.is-collapsed .ws-navbtn,
.ws-app.is-collapsed .ws-nav .navbtn {
  justify-content: center;
  padding: 0;
}

.ws-app.is-collapsed .ws-user {
  justify-content: center;
}

/* ------------------------------------------------------------------ main */

.ws-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.ws-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  height: 58px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-bar);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  backdrop-filter: blur(20px) saturate(150%);
}

.ws-menu-btn {
  display: none;
  flex: 0 0 auto;
}

/* A collapsed desktop rail must always offer a way back. Without this the
   only escape was Ctrl+B because the in-sidebar collapse button is hidden. */
.ws-app.is-collapsed .ws-menu-btn {
  display: grid;
}

.ws-title-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.ws-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.02em;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.ws-title:hover {
  color: var(--accent);
}

.ws-title-input {
  width: min(440px, 100%);
  padding: 2px 6px;
  border: 1px solid var(--accent-line);
  border-radius: 5px;
  background: var(--field);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: 0;
}

.ws-subtitle {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.ws-tier-tag {
  font-size: 8.5px;
}

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  max-width: 190px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--field);
  color: var(--fg-2);
  font: inherit;
  font-size: 10.5px;
  cursor: pointer;
  transition: border-color var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.ws-pill:hover {
  border-color: var(--accent-line);
  background: var(--glass-strong);
}

.ws-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-pill svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--accent);
}

.ws-pill .chev {
  width: 10px;
  height: 10px;
  color: var(--muted);
}

.ws-content {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.ws-view {
  height: 100%;
  min-height: 0;
}

.ws-view.is-active {
  display: flex;
  flex-direction: column;
}

.ws-view-pad {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px clamp(16px, 4vw, 44px) 44px;
  scrollbar-width: thin;
}

/* --------------------------------------------------------------- thread */

.ws-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scroll-behavior: auto;
}

.ws-thread {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  min-height: 100%;
  margin: 0 auto;
  padding: 26px 22px 30px;
}

.ws-app.is-wide .ws-thread {
  max-width: 1180px;
}

.ws-welcome {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42vh;
  padding: 24px 0;
  text-align: center;
  animation: ws-rise 420ms var(--ease-out) both;
}

.ws-welcome-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 4px;
  border: 1px solid var(--accent-line);
  border-radius: 17px;
  background: radial-gradient(circle at 32% 24%, var(--accent-soft), transparent 70%), var(--glass-strong);
  color: var(--accent);
  box-shadow: 0 18px 44px -28px var(--accent-line);
}

.ws-welcome-mark svg {
  width: 26px;
  height: 26px;
}

.ws-welcome h2 {
  margin: 0;
  color: var(--fg);
  font-size: clamp(20px, 3.2vw, 27px);
  font-weight: 640;
  letter-spacing: -0.035em;
}

.ws-welcome p {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.ws-suggest {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin-top: 14px;
}

.ws-suggest button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  color: var(--fg-2);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-2) var(--ease), transform var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.ws-suggest button:hover {
  border-color: var(--accent-line);
  background: var(--glass-strong);
  transform: translateY(-1px);
}

.ws-suggest b {
  color: var(--fg);
  font-size: 11.5px;
  font-weight: 600;
}

.ws-suggest span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

/* ------------------------------------------------------------- messages */

.ws-msg {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  animation: ws-rise 260ms var(--ease-out) both;
}

.ws-msg.is-user {
  flex-direction: row-reverse;
}

.ws-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--glass-strong);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  user-select: none;
}

.ws-msg.is-user .ws-avatar {
  border-color: var(--accent-line);
  background: linear-gradient(150deg, var(--accent-soft), var(--glass-strong));
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.ws-msg-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  flex: 1;
}

.ws-msg.is-user .ws-msg-body {
  align-items: flex-end;
  flex: 0 1 auto;
  max-width: 82%;
}

.ws-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 16px;
  color: var(--muted);
  font-size: 9.5px;
}

.ws-msg-head b {
  color: var(--fg-2);
  font-size: 10.5px;
  font-weight: 600;
}

.ws-msg.is-user .ws-msg-head {
  justify-content: flex-end;
}

.ws-msg-head .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

.ws-msg-bubble {
  position: relative;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  border-top-left-radius: 5px;
  background: var(--glass-strong);
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.ws-msg.is-user .ws-msg-bubble {
  border-color: transparent;
  border-radius: 13px;
  border-top-right-radius: 5px;
  background: linear-gradient(160deg, var(--btn-a), var(--btn-b));
  color: var(--btn-fg);
  box-shadow: 0 12px 28px -22px var(--accent-line);
}

.ws-msg-bubble .ws-attached {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.ws-msg-bubble .ws-attached span {
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  opacity: 0.75;
}

.ws-msg.is-user .ws-msg-bubble .ws-attached {
  opacity: 0.85;
}

.ws-md {
  color: var(--fg-2);
  font-size: 13.2px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.ws-md > :first-child {
  margin-top: 0;
}

.ws-md > :last-child {
  margin-bottom: 0;
}

.ws-md p {
  margin: 0 0 9px;
}

.ws-md h1,
.ws-md h2,
.ws-md h3,
.ws-md h4,
.ws-md h5,
.ws-md h6 {
  margin: 18px 0 8px;
  color: var(--fg);
  font-weight: 640;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.ws-md h1 { font-size: 19px; }
.ws-md h2 { font-size: 16.5px; }
.ws-md h3 { font-size: 14.5px; }
.ws-md h4,
.ws-md h5,
.ws-md h6 { font-size: 13px; }

.ws-md ul,
.ws-md ol {
  margin: 0 0 9px;
  padding-left: 21px;
}

.ws-md li {
  margin: 3px 0;
}

.ws-md li > ul,
.ws-md li > ol {
  margin: 3px 0;
}

.ws-md li input[type='checkbox'] {
  width: 11px;
  height: 11px;
  margin: 0 4px 0 0;
  accent-color: var(--accent);
  vertical-align: -1px;
}

.ws-md blockquote {
  margin: 10px 0;
  padding: 7px 12px;
  border-left: 2px solid var(--accent-line);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  background: var(--accent-soft);
  color: var(--fg-2);
}

.ws-md blockquote p {
  margin: 0;
}

.ws-md hr {
  height: 1px;
  margin: 15px 0;
  border: 0;
  background: var(--line);
}

.ws-md a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 2px;
}

.ws-md a:hover {
  text-decoration-color: var(--accent);
}

.ws-md strong {
  color: var(--fg);
  font-weight: 650;
}

.ws-md del {
  color: var(--muted);
}

.ws-md .md-inline {
  padding: 1.5px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.ws-md .md-code {
  margin: 11px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--canvas-2);
}

.ws-md .md-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px 5px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-soft);
}

.ws-md .md-lang {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ws-md .md-copy {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  color: var(--muted);
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.ws-md .md-copy:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}

.ws-md .md-code pre {
  margin: 0;
  padding: 11px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.ws-md .md-code code {
  display: block;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.ws-md .md-table-wrap {
  margin: 11px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  scrollbar-width: thin;
}

.ws-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.ws-md th,
.ws-md td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.ws-md th {
  background: var(--glass-soft);
  color: var(--fg);
  font-weight: 600;
  white-space: nowrap;
}

.ws-md tr:last-child td {
  border-bottom: 0;
}

.ws-md .md-empty {
  margin: 0;
}

.md-copy-fallback {
  position: fixed;
  left: -9999px;
  top: 0;
}

/* streaming caret + typing */
.ws-md.is-streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -2px;
  animation: ws-blink 1s steps(2, start) infinite;
}

.ws-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
}

.ws-thinking i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: ws-dots 1.15s var(--ease) infinite;
}

.ws-thinking i:nth-child(2) { animation-delay: 0.14s; }
.ws-thinking i:nth-child(3) { animation-delay: 0.28s; }

.ws-phase {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.ws-phase::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-line);
  animation: ws-pulse 1.4s var(--ease) infinite;
}

/* message actions */
.ws-msg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-2) var(--ease);
}

.ws-msg:hover .ws-msg-actions,
.ws-msg:focus-within .ws-msg-actions {
  opacity: 1;
}

.ws-act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.ws-act:hover {
  background: var(--glass-soft);
  color: var(--fg);
}

.ws-act svg {
  width: 11px;
  height: 11px;
}

.ws-act.is-danger:hover {
  background: var(--bad-soft);
  color: var(--bad);
}

/* tool cards + council timeline */
.ws-steps {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  font-size: 10.5px;
}

.ws-steps > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  list-style: none;
}

.ws-steps > summary::-webkit-details-marker {
  display: none;
}

.ws-steps > summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 9px;
}

.ws-steps[open] > summary::before {
  content: '▾';
}

.ws-steps > summary svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

.ws-steps-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 2px 9px 9px;
}

.ws-step {
  padding: 7px 9px;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 5px 5px 0;
  background: var(--field);
}

.ws-step.is-final {
  border-left-color: var(--accent);
}

.ws-step-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-2);
  font-size: 10px;
  font-weight: 600;
}

.ws-step-head span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ws-step .ws-md {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.6;
}

.ws-tool {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--field);
  overflow: hidden;
}

.ws-tool-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 10px;
}

.ws-tool-head code {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.ws-tool-head .tag {
  margin-left: auto;
  font-size: 8px;
}

.ws-tool pre {
  margin: 0;
  padding: 7px 8px;
  max-height: 180px;
  overflow: auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ws-msg.is-error .ws-msg-bubble {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad);
}

.ws-compacted {
  align-self: center;
  padding: 4px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: 9px;
}

.ws-jump {
  position: sticky;
  bottom: 12px;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 auto 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  color: var(--fg-2);
  font: inherit;
  font-size: 9.5px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transform: translateX(0);
}

.ws-jump svg {
  width: 11px;
  height: 11px;
}

/* --------------------------------------------------------------- composer */

.ws-compose-dock {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: 0 clamp(12px, 3vw, 26px) 14px;
  background: linear-gradient(180deg, transparent, var(--canvas) 28%);
}

.ws-composer,
.ws-council {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.ws-app.is-wide .ws-composer,
.ws-app.is-wide .ws-council {
  max-width: 1180px;
}

.ws-composer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 9px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  box-shadow: 0 18px 46px -30px rgba(20, 32, 44, 0.45), 0 1px 0 var(--inset-hi) inset;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  transition: border-color var(--t-2) var(--ease), box-shadow var(--t-2) var(--ease);
}

.ws-composer:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 18px 46px -28px var(--accent-line), 0 0 0 3px var(--ring);
}

.ws-composer-flags {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0 1px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ws-composer-flags::-webkit-scrollbar {
  display: none;
}

.ws-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 9.5px;
  cursor: pointer;
  transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease), border-color var(--t-1) var(--ease);
}

.ws-flag:hover {
  background: var(--glass-soft);
  color: var(--fg-2);
}

.ws-flag[aria-pressed='true'] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.ws-flag svg {
  width: 11px;
  height: 11px;
}

.ws-context {
  margin-left: auto;
  padding-right: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
}

.ws-input-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.ws-toolbtn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  margin-bottom: 1px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ws-toolbtn:hover {
  border-color: var(--line);
  background: var(--glass-soft);
  color: var(--fg-2);
}

.ws-toolbtn svg {
  width: 16px;
  height: 16px;
}

.ws-input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  max-height: 190px;
  padding: 7px 4px 5px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  outline: 0;
  scrollbar-width: thin;
}

.ws-input-row textarea::placeholder {
  color: var(--muted);
}

.ws-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-bottom: 1px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: linear-gradient(160deg, var(--btn-a), var(--btn-b));
  color: var(--btn-fg);
  cursor: pointer;
  transition: transform var(--t-2) var(--ease), opacity var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.ws-send:hover {
  transform: translateY(-1px);
}

.ws-send:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.ws-send svg {
  width: 15px;
  height: 15px;
}

.ws-send.is-stop {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-line);
}

.ws-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 3px 0;
  color: var(--muted);
  font-size: 8px;
}

.ws-composer-foot .mono {
  font-size: 8.5px;
}

.ws-attach {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 6px;
}

.ws-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  color: var(--fg-2);
  font-size: 9.5px;
}

.ws-attach-chip b {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-attach-chip span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  white-space: nowrap;
}

.ws-attach-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.ws-attach-chip button:hover {
  background: var(--bad-soft);
  color: var(--bad);
}

.ws-drop {
  position: absolute;
  inset: 8px;
  z-index: 30;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent-line);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  color: var(--accent);
  font-size: 12px;
  pointer-events: none;
}

/* ------------------------------------------------------------ popovers */

.ws-pop {
  position: fixed;
  z-index: 140;
  width: min(310px, calc(100vw - 20px));
  max-height: min(430px, 70vh);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  animation: ws-pop-in 140ms var(--ease-out) both;
  scrollbar-width: thin;
}

.ws-pop-head {
  padding: 6px 8px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ws-pop-section {
  padding: 6px 8px 3px;
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ws-pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 33px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.ws-pop-item:hover,
.ws-pop-item:focus-visible {
  background: var(--accent-soft);
  color: var(--fg);
  outline: 0;
}

.ws-pop-item[aria-checked='true'] {
  color: var(--accent);
}

.ws-pop-item .ws-pop-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.ws-pop-item .ws-pop-main b {
  overflow: hidden;
  font-size: 11px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-pop-item .ws-pop-main span {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.ws-pop-item > svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--muted);
}

.ws-pop-item.is-danger {
  color: var(--bad);
}

.ws-pop-item.is-danger:hover {
  background: var(--bad-soft);
}

.ws-pop-check {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--accent);
}

.ws-pop-emoji {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  font-size: 11px;
}

/* ---------------------------------------------------------------- slash */

.ws-menu.ws-slash {
  position: absolute;
  left: clamp(12px, 3vw, 26px);
  right: clamp(12px, 3vw, 26px);
  bottom: calc(100% - 4px);
  z-index: 45;
  max-width: 900px;
  margin: 0 auto;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.ws-slash-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ws-slash-item.is-active,
.ws-slash-item:hover {
  background: var(--accent-soft);
  outline: 0;
}

.ws-slash-item code {
  flex: 0 0 auto;
  min-width: 62px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
}

.ws-slash-item span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-slash-item:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- council */

.ws-council {
  margin-bottom: 7px;
  padding: 9px 10px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r);
  background: var(--glass-strong);
  box-shadow: var(--shadow-sm);
  animation: ws-pop-in 160ms var(--ease-out) both;
}

.ws-council-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--fg-2);
  font-size: 10.5px;
  font-weight: 600;
}

.ws-council-head svg {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.ws-council-head span {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
}

.ws-council-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ws-council-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  font-size: 8.5px;
}

.ws-council-field select {
  width: 100%;
  min-height: 29px;
  padding: 4px 24px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--field);
  color: var(--fg-2);
  font: inherit;
  font-size: 10px;
}

.ws-council-switches {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
}

.ws-council-switches label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.ws-council-switches input {
  width: 12px;
  height: 12px;
  accent-color: var(--accent);
}

.ws-council-note {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

/* ------------------------------------------------------------------ views */

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.view-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 3px;
  color: var(--fg);
  font-size: 21px;
  font-weight: 640;
  letter-spacing: -0.035em;
}

.view-head h2::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(140deg, var(--accent), var(--accent-3));
  box-shadow: 0 0 14px var(--accent-line);
}

.view-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.section-title {
  margin: 24px 0 10px;
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.ws-tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 9px;
}

.ws-tips > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-soft);
}

.ws-tips b {
  color: var(--fg-2);
  font-size: 10.5px;
}

.ws-tips span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.ws-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 42px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  text-align: center;
}

.ws-empty-card svg {
  width: 24px;
  height: 24px;
  color: var(--muted);
}

.ws-empty-card h3 {
  margin: 0;
  color: var(--fg-2);
  font-size: 13px;
}

.ws-empty-card p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
}

.ws-tool-list {
  margin-top: 10px;
}

/* --------------------------------------------------------------- agents */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.agent-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass-soft);
  transition: border-color var(--t-2) var(--ease), transform var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.agent-card:hover {
  border-color: var(--accent-line);
  background: var(--glass-strong);
  transform: translateY(-1px);
}

.agent-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.agent-emoji {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 15px;
}

.agent-card-name {
  min-width: 0;
  flex: 1;
}

.agent-card-name b {
  display: block;
  overflow: hidden;
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-card-name span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.05em;
}

.agent-card p {
  display: -webkit-box;
  flex: 1;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.agent-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.agent-card-tags .tag {
  font-size: 8px;
}

.agent-card-actions {
  display: flex;
  gap: 4px;
}

.agent-card-actions .btn {
  flex: 1;
  min-height: 27px;
  font-size: 9.5px;
}

.agent-empty {
  grid-column: 1 / -1;
  padding: 34px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-2) var(--ease), background-color var(--t-2) var(--ease);
}

.preset-card:hover {
  border-color: var(--accent-line);
  background: var(--glass-strong);
}

.preset-card b {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-2);
  font-size: 11px;
  font-weight: 600;
}

.preset-card span {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}

/* --------------------------------------------------------------- settings */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px;
}

.settings-rows {
  display: flex;
  flex-direction: column;
}

.settings-rows > div,
.settings-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.settings-rows > div:last-child,
.settings-switch:last-child {
  border-bottom: 0;
}

.settings-rows span,
.settings-switch span > b {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.settings-rows b {
  color: var(--fg-2);
  font-size: 10.5px;
  font-weight: 560;
}

.settings-switch {
  cursor: pointer;
}

.settings-switch > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-rows .settings-switch b {
  color: var(--fg-2);
  font-size: 10.5px;
}

.settings-switch i {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
}

.shortcut-list > div {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}

.shortcut-list > div:last-child {
  border-bottom: 0;
}

.shortcut-list kbd {
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--field);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-align: center;
}

.shortcut-list span {
  margin-left: auto;
  color: var(--muted);
  font-size: 9.5px;
}

/* --------------------------------------------------------------- modals */

.ws-modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 15, 24, 0.48);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: ws-fade 150ms var(--ease-out) both;
}

.ws-dialog {
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: min(88dvh, 820px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  animation: ws-dialog-in 190ms var(--ease-out) both;
}

.ws-dialog.is-small {
  width: min(420px, 100%);
}

.ws-dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 0 0 auto;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.ws-dialog-head h3 {
  margin: 0;
  color: var(--fg);
  font-size: 14px;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.ws-dialog-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.ws-dialog-head .icon-btn {
  margin-left: auto;
  flex: 0 0 auto;
}

.ws-dialog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  scrollbar-width: thin;
}

.ws-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
}

.ws-dialog-foot .left {
  margin-right: auto;
}

.ws-form {
  display: grid;
  gap: 10px;
}

.ws-form .two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ws-form .three {
  display: grid;
  grid-template-columns: 64px 1fr 120px;
  gap: 10px;
}

.ws-form .field {
  margin: 0;
}

.ws-form .field > span {
  font-size: 9.5px;
}

.ws-form textarea {
  min-height: 96px;
  max-height: 260px;
  resize: vertical;
  line-height: 1.55;
}

.ws-form .field-hint {
  margin: -3px 0 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.ws-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ws-color-row input[type='color'] {
  width: 34px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  cursor: pointer;
}

.ws-color-swatch {
  width: 22px;
  height: 22px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

/* Preset swatch colours are classes, not inline styles, so the strict
 * style-src 'self' policy keeps applying. */
.ws-color-swatch[data-color='#1f3a5f'] { background: #1f3a5f; }
.ws-color-swatch[data-color='#0e5a6e'] { background: #0e5a6e; }
.ws-color-swatch[data-color='#1f6f3a'] { background: #1f6f3a; }
.ws-color-swatch[data-color='#7a4b12'] { background: #7a4b12; }
.ws-color-swatch[data-color='#7a1f2e'] { background: #7a1f2e; }
.ws-color-swatch[data-color='#5b21b6'] { background: #5b21b6; }
.ws-color-swatch[data-color='#334155'] { background: #334155; }

.ws-color-swatch.is-active {
  border-color: var(--fg);
  box-shadow: 0 0 0 2px var(--glass-strong);
}

.ws-confirm-text {
  margin: 0;
  color: var(--fg-2);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.ws-tool-args {
  max-height: 190px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--field);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ws-command-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ws-command-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--glass-soft);
  font-size: 10.5px;
}

.ws-command-list code {
  flex: 0 0 auto;
  min-width: 64px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
}

.ws-command-list span {
  color: var(--muted);
}

.ws-command-list li.is-denied {
  opacity: 0.55;
}

.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;
}

/* --------------------------------------------------------------- motion */

@keyframes ws-rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ws-pop-in {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ws-dialog-in {
  from { opacity: 0; transform: translateY(9px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ws-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ws-dots {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@keyframes ws-blink {
  50% { opacity: 0; }
}

@keyframes ws-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .ws-pill {
    max-width: 150px;
  }
}

@media (max-width: 980px) {
  .ws-app {
    grid-template-columns: 1fr;
  }

  .ws-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    width: min(310px, 86vw);
    transform: translateX(-102%);
    transition: transform var(--t-3) var(--ease-out);
    box-shadow: var(--shadow-lg);
  }

  .ws-app.is-open .ws-side {
    transform: none;
  }

  .ws-app.is-open .ws-scrim {
    display: block;
  }

  .ws-app.is-collapsed .ws-side {
    width: min(310px, 86vw);
  }

  .ws-app.is-collapsed .ws-brand-copy,
  .ws-app.is-collapsed .ws-newchat span,
  .ws-app.is-collapsed .ws-newchat kbd,
  .ws-app.is-collapsed .ws-history-head,
  .ws-app.is-collapsed .ws-history,
  .ws-app.is-collapsed .ws-navbtn span,
  .ws-app.is-collapsed .ws-nav .navbtn span,
  .ws-app.is-collapsed .ws-user-copy,
  .ws-app.is-collapsed .ws-side-link span,
  .ws-app.is-collapsed .ws-user #sideTheme,
  .ws-app.is-collapsed .ws-user #logoutBtn {
    display: flex;
  }

  .ws-app.is-collapsed .ws-brand-copy,
  .ws-app.is-collapsed .ws-user-copy {
    display: flex;
  }

  .ws-app.is-collapsed .ws-newchat,
  .ws-app.is-collapsed .ws-brand,
  .ws-app.is-collapsed .ws-navbtn,
  .ws-app.is-collapsed .ws-nav .navbtn,
  .ws-app.is-collapsed .ws-user {
    justify-content: flex-start;
  }

  .ws-app.is-collapsed .ws-collapse {
    display: grid;
  }

  .ws-app.is-collapsed .ws-newchat {
    margin: 0 12px 12px;
    padding: 0 11px;
  }

  .ws-app.is-collapsed .ws-nav {
    margin: 0 8px;
  }

  .ws-app.is-collapsed .ws-navbtn,
  .ws-app.is-collapsed .ws-nav .navbtn {
    padding: 0 9px;
  }

  .ws-resize {
    display: none;
  }

  .ws-menu-btn {
    display: grid;
  }
}

@media (max-width: 760px) {
  .ws-thread {
    padding: 20px 14px 24px;
  }

  .ws-compose-dock {
    padding: 0 10px 10px;
  }

  .ws-top {
    padding: 0 9px;
    height: 54px;
  }

  .ws-subtitle {
    display: none;
  }

  .ws-tier-tag {
    display: none;
  }

  .ws-pill {
    max-width: 118px;
    min-height: 28px;
    padding: 0 8px;
  }

  .ws-pill .chev {
    display: none;
  }

  .ws-msg.is-user .ws-msg-body {
    max-width: 90%;
  }

  .ws-msg-actions {
    opacity: 0.68;
  }

  .ws-suggest {
    grid-template-columns: 1fr;
  }

  .ws-welcome {
    min-height: 32vh;
  }

  .ws-view-pad {
    padding: 20px 14px 34px;
  }

  .ws-council-grid,
  .ws-form .two,
  .ws-form .three {
    grid-template-columns: 1fr;
  }

  .ws-form .three {
    gap: 7px;
  }

  .ws-dialog {
    max-height: 92dvh;
  }

  .ws-dialog-body {
    padding: 12px;
  }

  .ws-menu.ws-slash {
    left: 10px;
    right: 10px;
  }
}

@media (max-width: 520px) {
  .ws-top-actions {
    gap: 4px;
  }

  .ws-pill span {
    max-width: 74px;
  }

  .ws-pill#agentBtn {
    display: none;
  }

  .ws-composer-flags .ws-context {
    display: none;
  }

  .ws-composer-foot > span:first-child {
    display: none;
  }

  .ws-composer-foot {
    justify-content: flex-end;
  }

  .ws-avatar {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }

  .ws-msg {
    gap: 8px;
  }

  .ws-md {
    font-size: 12.8px;
  }

  .ws-send {
    width: 34px;
    height: 34px;
  }

  .ws-dialog {
    border-radius: var(--r);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ws-msg,
  .ws-welcome,
  .ws-pop,
  .ws-dialog,
  .ws-modal,
  .ws-council {
    animation: none !important;
  }

  .ws-thinking i,
  .ws-md.is-streaming::after,
  .ws-phase::before {
    animation: none !important;
  }

  .ws-side {
    transition: none !important;
  }
}

/* ------------------------------------------------- readable portal type scale
   The portal is a reading surface. Body copy stays at 15.5px, navigation and
   controls at 13–14px, and no primary text is smaller than 11px. These rules
   intentionally come last so the old 8–12px values in the responsive blocks
   cannot shrink a message again on a narrow screen. */
body.ws-body {
  font-size: 15px;
}

.ws-brand-name { font-size: 15px; }
.ws-brand-sub { font-size: 10.5px; }
.ws-newchat { font-size: 14px; }
.ws-newchat kbd { font-size: 10.5px; }
.ws-search input { font-size: 13.5px; }
.ws-history-empty { font-size: 13px; }
.ws-hlabel { font-size: 11px; }
.ws-hcopy b { font-size: 13.5px; }
.ws-hcopy span { font-size: 11.5px; }
.ws-navbtn,
.ws-nav .navbtn { min-height: 38px; font-size: 14px; }
.ws-nav .ws-archive-back { font-size: 12px; }
.ws-user-copy b { font-size: 13px; }
.ws-user-copy span { font-size: 11.5px; }
.ws-side-link { font-size: 12.5px; }
.ws-title { font-size: 15.5px; }
.ws-title-input { font-size: 15px; }
.ws-subtitle { font-size: 12px; }
.ws-tier-tag { font-size: 10.5px; }
.ws-pill { min-height: 32px; font-size: 12.5px; }

.ws-welcome p { font-size: 14px; }
.ws-suggest button { font-size: 13px; }
.ws-suggest b { font-size: 13.5px; }
.ws-suggest span { font-size: 12px; }

.ws-msg-head { font-size: 12px; }
.ws-msg-head b { font-size: 13px; }
.ws-msg-bubble { font-size: 15.5px; line-height: 1.75; }
.ws-md { font-size: 15.5px; line-height: 1.75; }
.ws-md h1 { font-size: 22px; }
.ws-md h2 { font-size: 19.5px; }
.ws-md h3 { font-size: 17.5px; }
.ws-md h4,
.ws-md h5,
.ws-md h6 { font-size: 15.5px; }
.ws-md .md-code code { font-size: 13.5px; }
.ws-md table { font-size: 13.5px; }
.ws-md .md-lang,
.ws-md .md-copy { font-size: 11px; }

.ws-act { height: 26px; font-size: 11.5px; }
.ws-phase { font-size: 12px; }
.ws-steps { font-size: 12.5px; }
.ws-steps > summary { font-size: 12px; }
.ws-step-head { font-size: 12px; }
.ws-step-head span { font-size: 11px; }
.ws-step .ws-md { font-size: 13.5px; }
.ws-tool-head { font-size: 12px; }
.ws-tool-head code { font-size: 11.5px; }
.ws-tool-head .tag { font-size: 10.5px; }
.ws-tool pre { font-size: 11.5px; }
.ws-compacted { font-size: 11.5px; }
.ws-jump { font-size: 12px; }

.ws-flag { height: 27px; font-size: 12px; }
.ws-context { font-size: 11px; }
.ws-input-row textarea { font-size: 15px; }
.ws-composer-foot { font-size: 11px; }
.ws-composer-foot .mono { font-size: 11px; }
.ws-attach-chip { font-size: 12px; }
.ws-attach-chip span { font-size: 11px; }

.view-head p { font-size: 13.5px; }
.section-title { font-size: 14px; }
.ws-tips b { font-size: 13px; }
.ws-tips span { font-size: 12.5px; }
.ws-empty-card h3 { font-size: 15px; }
.ws-empty-card p { font-size: 13px; }
.tag { font-size: 11px; }

@media (max-width: 760px) {
  .ws-top { height: 60px; }
  .ws-thread { padding: 20px 16px 24px; }
  .ws-md,
  .ws-msg-bubble { font-size: 15.5px; }
  .ws-msg.is-user .ws-msg-body { max-width: 88%; }
}

@media (max-width: 520px) {
  .ws-md { font-size: 15.5px; }
  .ws-top { padding: 0 10px; }
  .ws-composer-flags { gap: 2px; }
}
