body.ui-version-v2 {
  --topbar-height: 40px;
  --statusbar-height: 28px;
  --footer-control-height: 20px;
  --footer-control-inline-padding: 6px;
  /* One neutral interaction veil across independently themed Chat, Studio and Assistant surfaces. */
  --menu-scrim: rgba(64, 68, 62, 0.34);
  --bg-base: var(--surface-canvas);
  --bg-elevated: var(--surface-default);
  --bg-subtle: var(--surface-muted);
  --bg-accent: var(--surface-strong);
  --bg-hover: var(--surface-muted);
  --text-primary: var(--ink-primary);
  --text-secondary: var(--ink-secondary);
  --text-muted: var(--ink-muted);
  --accent-primary: var(--lime-strong);
  --accent-hover: var(--lime-default);
  --accent-on: var(--lime-strong-on);
  --accent-hover-on: var(--lime-on);
  --accent-muted: color-mix(in srgb, var(--lime-strong) 14%, transparent);
  --border-subtle: color-mix(in srgb, var(--ink-primary) 7%, transparent);
  --border-default: color-mix(in srgb, var(--ink-primary) 14%, transparent);
  --border-strong: color-mix(in srgb, var(--ink-primary) 24%, transparent);
  --border-focus: color-mix(in srgb, var(--lime-strong) 58%, transparent);
  --message-em-color: var(--ink-secondary);
  --message-quote-color: var(--lime-strong);
  /* Prompt kinds are distinguished by shape; every kind icon uses one action colour. */
  --prompt-kind-icon-tone: var(--lime-default);
  --prompt-kind-general: #0f766e;
  --prompt-kind-roleplay: #7c3aed;
  --prompt-kind-manuscript: #b45309;
  background: var(--surface-canvas);
}
:root[data-color-mode="dark"] body.ui-version-v2 {
  --prompt-kind-general: #5eead4;
  --prompt-kind-roleplay: #c4b5fd;
  --prompt-kind-manuscript: #fbbf24;
}
body.ui-version-v2 [data-prompt-kind="general"] { --prompt-kind-tone: var(--prompt-kind-general); }
body.ui-version-v2 [data-prompt-kind="roleplay"] { --prompt-kind-tone: var(--prompt-kind-roleplay); }
body.ui-version-v2 [data-prompt-kind="manuscript"] { --prompt-kind-tone: var(--prompt-kind-manuscript); }
body.ui-version-v2 .prompt-kind-icon {
  display: block;
  width: 1em;
  height: 1em;
  flex: none;
  color: var(--prompt-kind-icon-tone);
}


body.ui-version-v2 .top-bar,
body.ui-version-v2 .status-bar {
  background: var(--surface-default);
  border-color: color-mix(in srgb, var(--ink-primary) 10%, transparent);
  backdrop-filter: none;
}

/* The status row belongs to the Chat canvas, not the whole viewport. */
body.ui-version-v2 .status-bar {
  position: relative;
  inset: auto;
  width: 100%;
  flex: 0 0 var(--statusbar-height);
}

body.ui-version-v2 .status-right {
  display: flex;
}

body.ui-version-v2 .top-bar {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--lime-strong) 8%, transparent);
}

body.ui-version-v2 .top-bar-inner {
  /* Keep the compact identity within the same fixed height as Studio. */
  --chat-font-scale: min(var(--chat-interface-font-scale, 1), calc(15 / 14));
  height: 100%;
}


/* The title can shrink or swap layout; the actions keep their own edge and height. */
body.ui-version-v2 .top-bar-inner > .shell-actions {
  flex: none;
  height: 100%;
}
body.ui-version-v2 .modal-header,
body.ui-version-v2 #settingsModal .modal-header,
body.ui-version-v2 .model-picker-modal-header,
body.ui-version-v2 .v2-character-browser-header {
  min-height: var(--topbar-height);
  height: var(--topbar-height);
  flex: 0 0 var(--topbar-height);
  padding-top: 0;
  padding-bottom: 0;
}

/* A question dialog's title names the thing it asks about, so it may wrap: its header grows
 * with it (keeping the app-bar height for one line) and clamps only past five lines. */
body.ui-version-v2 .guest-account-prompt > .modal-header {
  height: auto;
  flex: 0 0 auto;
  padding-top: 6px;
  padding-bottom: 6px;
}

body.ui-version-v2 .guest-account-prompt > .modal-header h2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .model-picker-modal > .busy-region,
body.ui-version-v2 .model-picker-confirm {
  inset: var(--topbar-height) 0 0;
}

/* Desktop model selection carries a title and route summary. Match the
 * two-line Inventory header rather than clipping both into the 40px app bar.
 * Mobile moves the summary into content and resets this variable below. */
body.ui-version-v2 .model-picker-modal {
  --model-picker-header-height: 62px;
}

body.ui-version-v2 .model-picker-modal-header {
  min-height: var(--model-picker-header-height);
  height: var(--model-picker-header-height);
  flex-basis: var(--model-picker-header-height);
  padding-top: 8px;
  padding-bottom: 8px;
}

body.ui-version-v2 .model-picker-modal > .busy-region,
body.ui-version-v2 .model-picker-confirm {
  inset: var(--model-picker-header-height) 0 0;
}

body.ui-version-v2 .app-title-text {
  font-family: var(--font-interface);
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.035em;
}

/* The guest landing has no conversations button. Show the Sandcat mark
 * beside the wordmark there and on the conversations control elsewhere. */
body.ui-version-v2 .app-title-icon {
  display: none;
}

body.ui-version-v2.guest-workspace.v2-no-chat .app-title-icon {
  display: block;
}
/* Guest Studio is a named destination, not a chatless brand mark. */
@media (max-width: 768px) {
  body.ui-version-v2.guest-studio-arrival .top-bar-left .app-title-text {
    display: inline-block;
  }
}

body.ui-version-v2 .main-layout {
  height: calc(100% - var(--topbar-height));
  background: var(--surface-canvas);
  box-shadow: none;
  /* Hidden offscreen rails must not scroll the whole workspace on focus. */
  overflow: clip;
}

body.ui-version-v2 .sidebar {
  --busy-surface: var(--surface-default);
  background: var(--surface-default);
  border-color: color-mix(in srgb, var(--ink-primary) 9%, transparent);
}

/* While a conversation-list menu (row actions, New, order) is open, the rest of the
 * sidebar dims behind it and swallows the outside click that closes the menu, so
 * that click never also opens a conversation. The menu's own control and the row it
 * belongs to stay above the dim. The drawer is already positioned on narrow screens. */
@media (min-width: 769px) {
  body.ui-version-v2 .sidebar { position: relative; }
}
body.ui-version-v2 .sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 30;
  background: var(--menu-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}
body.ui-version-v2 .sidebar:has(.chat-item-menu:not([hidden]), .v2-chat-view-menu:not([hidden]), .account-menu.is-open)::after {
  opacity: 1;
  pointer-events: auto;
}
body.ui-version-v2 .sidebar :is(.chat-item, .v2-chat-view-control, .account-nav):has(.sandcat-menu:not([hidden])) {
  z-index: 35;
}
/* The raised row keeps an opaque surface: transparent, its ink would sit on the dim,
 * which is unreadable in light mode. */
body.ui-version-v2 .sidebar .chat-item:has(.chat-item-menu:not([hidden])) {
  background: var(--surface-default);
}
body.ui-version-v2 .sidebar .chat-item.active:has(.chat-item-menu:not([hidden])) {
  background: color-mix(in srgb, var(--lime-strong) 9%, var(--surface-default));
}
@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .sidebar::after { transition: none; }
}

body.ui-version-v2 .sidebar-header {
  padding: 14px;
  border-color: color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .open-library-btn {
  min-height: 42px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 55%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
  color: var(--lime-default);
  font-family: var(--font-interface);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body.ui-version-v2 .open-library-btn:hover {
  background: var(--lime-strong);
  color: var(--lime-strong-on);
}

/* A slim conversations control: 24px wide meets the minimum target size
 * without spending a full square button beside the application title. The
 * shared 8px flex gap leaves 6px after the centred 28px face on every width. */
body.ui-version-v2 .top-bar-left {
  gap: 8px;
}

body.ui-version-v2 .menu-toggle-btn {
  width: 24px;
  height: 32px;
  flex: 0 0 24px;
  padding: 0;
  margin-left: 3px;
}

body.ui-version-v2 .menu-toggle-btn svg {
  width: 28px;
  min-width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.sandcat-mode-badge {
  fill: var(--studio-accent, var(--lime-strong));
  paint-order: stroke;
  pointer-events: none;
  transform: translateX(2.2px);
}

body.manuscript-reader-open .sandcat-chat-mark,
body:not(.manuscript-reader-open) .sandcat-read-mark {
  display: none;
}

/* Icon-only controls stay unboxed in every state. Only a real pointer hover
 * brightens the glyph, so a tap leaves no lingering selection tint. */
body.ui-version-v2 .menu-toggle-btn:is(:hover, :focus, :focus-visible, :active) {
  border-color: transparent;
  background: transparent;
  outline: none;
  box-shadow: none;
}

@media (hover: hover) {
  :is(body.ui-version-v2 .menu-toggle-btn, .studio .studio-source-trigger):hover svg image {
    filter: brightness(1.2);
  }
}

/* No focus ring after a pointer or touch press (shell.js marks the page). A script that moves focus after a tap, such as opening a panel or returning focus to its trigger, otherwise leaves a ring behind. Keyboard use sets data-input="keyboard", which restores every ring; text fields always keep theirs. */
html[data-input='pointer'] :focus-visible:not(input, textarea, select, [contenteditable]) {
  outline: none !important;
  box-shadow: none !important;
}

body.ui-version-v2 .chat-item {
  gap: 10px;
  min-height: 54px;
  margin: 4px 0;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 3px;
}

@media (hover: hover) {
  body.ui-version-v2 .chat-item:hover:not(.active) {
    background: color-mix(in srgb, var(--ink-primary) 3.5%, transparent);
    border-color: color-mix(in srgb, var(--ink-primary) 8%, transparent);
  }
}

body.ui-version-v2 .chat-item.active {
  background: color-mix(in srgb, var(--lime-strong) 9%, transparent);
  border-color: color-mix(in srgb, var(--lime-strong) 20%, transparent);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

body.ui-version-v2 .v2-chat-portrait {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 32%, transparent);
  border-radius: 3px;
  object-fit: cover;
}

body.ui-version-v2 .chat-item-title {
  color: var(--ink-primary);
}

body.ui-version-v2 .chat-area {
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
}

body.ui-version-v2 .messages-container {
  width: 100%;
  max-width: none;
  margin: 0;
  gap: 0;
  padding: clamp(22px, 3vw, 42px) clamp(18px, 5vw, 64px) 112px;
  scrollbar-color: color-mix(in srgb, var(--lime-strong) 38%, transparent) transparent;
}
body.ui-version-v2 #messagesContainer.has-older-history > .chat-header,
body.ui-version-v2 #messagesContainer.has-older-history > .powered-by-tagline {
  display: none;
}

body.ui-version-v2 .transcript-history-control {
  display: block;
  flex: 0 0 auto;
  min-height: 32px;
  margin: 8px auto;
  padding: 4px 12px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted, #999);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

body.ui-version-v2 .transcript-history-control[hidden] { display: none; }

body.ui-version-v2 .transcript-virtual-spacer {
  width: 1px;
  min-height: 0;
  flex: 0 0 auto;
  pointer-events: none;
}

body.ui-version-v2 .powered-by-tagline-in-chat {
  width: 100%;
  max-width: 860px;
  margin: 0 auto 12px;
  color: var(--ink-secondary);
  opacity: 0.62;
  letter-spacing: 0.015em;
}

body.ui-version-v2 .chat-header {
  position: relative;
  top: auto;
  z-index: 1;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 17px;
  align-items: center;
  width: 100%;
  max-width: 860px;
  min-height: 104px;
  margin: 0 auto 14px;
  padding: 14px 18px;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 13%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-default) 92%, transparent);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(15px);
}

/* One accent frame, an outline and an offset shadow, worn only by a portrait that is an initial; real artwork wears
 * none. `applyPortrait` sets data-portrait, and every portrait border and offset shadow below reads these two. */
body.ui-version-v2 :is(.v2-character-portrait, .v2-sticky-portrait) {
  --portrait-outline: 1px solid color-mix(in srgb, var(--lime-default) 42%, transparent);
  --portrait-offset: color-mix(in srgb, var(--error) 20%, transparent);
}

body.ui-version-v2 :is(.v2-character-portrait, .v2-sticky-portrait)[data-portrait="image"] {
  --portrait-outline: 0 none;
  --portrait-offset: transparent;
}

body.ui-version-v2 .v2-character-portrait {
  grid-column: 1;
  grid-row: 1 / 4;
  width: 76px;
  height: 76px;
  border: var(--portrait-outline);
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 7px 7px 0 var(--portrait-offset);
}

body.ui-version-v2 .v2-character-kicker {
  grid-column: 2;
  color: var(--lime-strong);
  font-family: var(--font-interface);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

body.ui-version-v2 .chat-header-title {
  grid-column: 2;
  margin: 0;
  color: var(--ink-primary);
  font-family: var(--font-interface);
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

body.ui-version-v2 .chat-header-meta {
  grid-column: 2;
  margin-top: 4px;
  color: var(--ink-secondary);
  font-size: 0.75rem;
}

body.ui-version-v2 .greeting-selector {
  width: 100%;
  max-width: 860px;
  margin: -3px auto 2px;
  padding: 0;
}

body.ui-version-v2 .greeting-selector button {
  border: 1px solid color-mix(in srgb, var(--ink-primary) 14%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--surface-default) 78%, transparent);
  color: var(--ink-secondary);
}

body.ui-version-v2 .greeting-selector button:hover {
  border-color: color-mix(in srgb, var(--lime-strong) 50%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 12%, transparent);
  color: var(--lime-default);
}

body.ui-version-v2 .message-meta-row .message-action {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

body.ui-version-v2 .message-meta-row .message-action:hover {
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .message {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 0;
  border: 0;
}

body.ui-version-v2 .message-avatar {
  display: none;
}

body.ui-version-v2 .message-body,
body.ui-version-v2 .message.user .message-body {
  width: 100%;
  gap: 9px;
  align-items: stretch;
}

body.ui-version-v2 .message-role {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--lime-strong);
  font-family: var(--font-interface);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

body.ui-version-v2 .message-role::before {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--lime-strong);
}

body.ui-version-v2 .message.user {
  padding-left: clamp(50px, 9vw, 130px);
}

body.ui-version-v2 .message.user .message-role {
  justify-content: flex-end;
  color: var(--error);
}

body.ui-version-v2 .message.user .message-role::before {
  background: var(--error);
}

body.ui-version-v2 .message-content,
body.ui-version-v2 .message.assistant .message-content,
body.ui-version-v2 .message.user .message-content {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.ui-version-v2 .message-text,
body.ui-version-v2 .message.user .message-text {
  width: 100%;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-primary);
  font-family: var(--font-reading);
  font-size: 16px;
  line-height: 1.72;
  text-wrap: pretty;
}

body.ui-version-v2 .message.user .message-text {
  padding-right: 16px;
  border-right: 2px solid color-mix(in srgb, var(--error) 70%, transparent);
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-text p + p {
  margin-top: 0.88em;
}

body.ui-version-v2 .message.assistant .message-text > p > em {
  display: inline;
  color: var(--ink-secondary);
  font-size: 0.96em;
  line-height: inherit;
}

body.ui-version-v2 .message.assistant .message-text q {
  color: var(--ink-primary);
}

body.ui-version-v2 .message-meta-row {
  justify-content: flex-end;
}

body.ui-version-v2 .message.assistant .message-meta-row {
  width: 100%;
  min-height: 25px;
  margin-top: 2px;
}
body.ui-version-v2 .message.assistant .message-turn-primary .message-meta-row {
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0 0 0 auto;
  position: static;
}

/* The raw-view toggle is a reply action like the labelled ones. */
body.ui-version-v2 .message-meta-row .message-action.message-raw-toggle,
body.ui-version-v2 .message-turn-actions > .message-action.message-raw-toggle {
  display: inline-grid;
  width: 28px;
  height: 24px;
  min-height: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

body.ui-version-v2 .message-meta-row .message-action.message-raw-toggle svg,
body.ui-version-v2 .message-turn-actions > .message-action.message-raw-toggle svg {
  display: block;
  width: 15px;
  height: 15px;
}

body.ui-version-v2 .message-meta-row .message-action.message-raw-toggle:focus-visible,
body.ui-version-v2 .message-turn-actions > .message-action.message-raw-toggle:focus-visible {
  outline: 2px solid var(--lime-strong);
  outline-offset: 2px;
}

body.ui-version-v2 .message-meta-actions {
  gap: 5px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body.ui-version-v2 .message.assistant .message-turn-primary .message-meta-actions {
  position: static;
  display: flex;
  align-items: center;
  padding: 0;
  border-radius: 0;
}

body.ui-version-v2 .message-meta-row .message-action {
  width: 25px;
  height: 25px;
}

body.ui-version-v2 .input-area {
  position: relative;
  left: auto;
  bottom: auto;
  flex: 0 0 auto;
  /* Let the visual fade continue behind Latest; dock sync keeps content above it. */
  margin-top: calc(-1 * var(--v2-transcript-fade-depth));
  pointer-events: none;
  padding: 24px clamp(18px, 5vw, 64px) 12px;
  border: 0;
  background: transparent;
}

body.ui-version-v2 .input-area > * {
  pointer-events: auto;
}

body.ui-version-v2 .preview-rail {
  left: clamp(18px, 5vw, 64px);
  right: clamp(18px, 5vw, 64px);
}

body.ui-version-v2 .turn-generation-chip {
  bottom: 6px;
  min-height: 30px;
}
body.ui-version-v2 .scroll-bottom-btn {
  bottom: 6px;
}

body.ui-version-v2 .scroll-bottom-btn.is-generating {
  border-color: color-mix(in srgb, var(--lime-strong) 22%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 82%, transparent);
  color: color-mix(in srgb, var(--ink-primary) 68%, transparent);
}

body.ui-version-v2 .scroll-bottom-btn.is-generating:hover,
body.ui-version-v2 .scroll-bottom-btn.is-generating:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 42%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 94%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .scroll-bottom-btn svg {
  width: 16px;
  height: 16px;
}

body.ui-version-v2 .input-area .composer-control-rail {
  height: 34px;
}

body.ui-version-v2 .composer-control-rail {
  max-width: 900px;
}
body.ui-version-v2 .composer-input-row {
  display: grid;
  width: 100%;
  max-width: 900px;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 4px;
  margin: 0 auto;
}

body.ui-version-v2 .composer-input-row .input-wrapper {
  max-width: none;
  margin: 0;
}

body.ui-version-v2 .input-wrapper {
  --composer-action-row-height: 40px;
  --composer-resize-duration: 110ms;
  --composer-resize-ease: cubic-bezier(.2,.8,.2,1);
  position: relative;
  display: grid;
  width: 100%;
  max-width: 860px;
  min-width: 0;
  align-items: stretch;
  gap: 0;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  border-radius: 8px;
  background: var(--surface-default);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  backdrop-filter: none;
}

body.ui-version-v2 .composer-expanded-scrim {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: auto;
}

body.ui-version-v2 .chat-area.composer-expanded .messages-container {
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

body.ui-version-v2 .input-area.composer-expanded {
  position: absolute;
  inset: 0;
  z-index: 41;
  display: grid;
  place-items: end center;
  margin: 0;
  padding: clamp(18px, 5vw, 64px) clamp(18px, 5vw, 64px) 12px;
  pointer-events: none;
}

body.ui-version-v2 .input-area.composer-expanded > :not(.composer-input-row) {
  display: none;
}

body.ui-version-v2 .input-area.composer-expanded .composer-input-row {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

body.ui-version-v2 .input-area.composer-expanded #messageInput {
  transition: none;
}

body.ui-version-v2 .composer-editor-frame {
  position: relative;
  min-width: 0;
  padding-right: 0;
}

body.ui-version-v2 :is(.input-wrapper,.studio-composer).can-expand > .composer-editor-frame {
  padding-right: 0;
}

body.ui-version-v2 :is(.input-wrapper,.studio-composer).can-expand > .composer-editor-frame > :is(#messageInput,#studioInstruction) {
  padding-right: 34px;
}

body.ui-version-v2 #messageInput {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--composer-action-row-height);
  max-height: none;
  margin: 0;
  padding: 8px 12px 6px;
  border: 0;
  background: transparent;
  color: var(--ink-primary);
  font-family: var(--font-reading);
  font-size: 16px;
  line-height: 1.45;
  outline: 0;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--accent-primary) 42%, transparent) transparent;
  scrollbar-width: thin;
  transition: height var(--composer-resize-duration) var(--composer-resize-ease);
}
body.ui-version-v2 :is(#messageInput,#studioInstruction) {
  scrollbar-color: color-mix(in srgb, var(--accent-primary) 42%, transparent) transparent;
  scrollbar-width: thin;
}

body.ui-version-v2 :is(#messageInput,#studioInstruction)::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

body.ui-version-v2 :is(#messageInput,#studioInstruction)::-webkit-scrollbar-thumb {
  border: 0;
  background: color-mix(in srgb, var(--accent-primary) 42%, transparent);
  background-clip: border-box;
}

body.ui-version-v2 :is(#messageInput,#studioInstruction)::-webkit-scrollbar-track {
  background: transparent;
}

body.ui-version-v2 .input-wrapper:not(.is-multiline) #messageInput {
  padding-right: 44px;
}

body.ui-version-v2 .input-wrapper.is-multiline #messageInput {
  padding: 6px 12px 0;
}


body.ui-version-v2 .composer-actions-row {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: var(--composer-action-row-height);
  align-items: center;
  justify-content: space-between;
  margin-top: calc(-1 * var(--composer-action-row-height));
  padding: 4px;
  pointer-events: none;
  transition: margin-top var(--composer-resize-duration) var(--composer-resize-ease);
}

body.ui-version-v2 :is(.input-wrapper,.studio-composer).is-multiline > .composer-actions-row {
  margin-top: 0;
  padding: 0 4px 6px;
}

body.ui-version-v2 .composer-actions-row > * {
  pointer-events: auto;
}

body.ui-version-v2 .chat-composer-actions {
  justify-content: flex-end;
}

body.ui-version-v2 .composer-send-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

body.ui-version-v2 .composer-tool-options.sandcat-menu {
  position: static;
  inset: auto;
  z-index: auto;
  display: grid;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: none;
  max-height: none;
  gap: 1px;
  margin: 0;
  padding: 5px 8px;
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  border-radius: 8px;
  background: var(--surface-default);
  box-shadow: none;
  color: var(--ink-primary);
  transform: none;
}

body.ui-version-v2 .composer-tool-options[hidden] {
  display: none;
}

body.ui-version-v2 .composer-tool-options .composer-tool-option {
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 4px 6px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-primary);
  font: 400 16px/1.45 var(--font-reading);
  text-align: left;
}

body.ui-version-v2 .composer-input-row :is(#messageInput,.composer-tool-option) {
  font-family: var(--font-reading);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

body.ui-version-v2 .composer-tool-options .composer-tool-option:is(:hover,:focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 7%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .composer-tool-options .composer-tool-option > svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

body.ui-version-v2 .composer-expand-toggle {
  position: absolute;
  top: 1px;
  right: 5px;
  z-index: 3;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .composer-expand-toggle[hidden] {
  display: none;
}

body.ui-version-v2 .composer-expand-toggle:is(:hover,:focus-visible) {
  background: transparent;
  color: var(--ink-primary);
}

body.ui-version-v2 .composer-expand-toggle svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

body.ui-version-v2 .composer-expand-toggle .composer-collapse-icon,
body.ui-version-v2 .composer-expand-toggle[data-expanded="true"] .composer-expand-icon {
  display: none;
}

body.ui-version-v2 .composer-expand-toggle[data-expanded="true"] .composer-collapse-icon {
  display: inline;
}

body.ui-version-v2 .composer-plus-trigger {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .composer-plus-trigger:is(:hover,:focus-visible),
body.ui-version-v2 .is-tools-open .composer-plus-trigger {
  background: var(--surface-muted);
  color: var(--ink-primary);
}

body.ui-version-v2 .composer-plus-trigger svg {
  width: 20px;
  height: 20px;
}

body.ui-version-v2 :is(.send-btn,.stop-btn) {
  display: flex;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  box-shadow: none;
  /* Legacy transition:all needlessly animates inherited scrollbar paint when editor focus changes. */
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
}

body.ui-version-v2 .stop-btn {
  border: 1px solid color-mix(in srgb, var(--error) 18%, transparent);
  background: color-mix(in srgb, var(--error) 7%, transparent);
  color: var(--error);
}

body.ui-version-v2 .stop-btn:hover {
  border-color: color-mix(in srgb, var(--error) 28%, transparent);
  background: color-mix(in srgb, var(--error) 11%, transparent);
}

body.ui-version-v2 .stop-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

body.ui-version-v2 .send-btn {
  border: 0;
  background: transparent;
  color: var(--lime-strong);
}

body.ui-version-v2 .send-btn svg {
  width: 26px;
  height: 26px;
  transform: scaleX(0.75);
}

body.ui-version-v2 .send-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--lime-default);
  transform: scale(1.06);
}

body.ui-version-v2 .send-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--lime-strong) 60%, transparent);
  outline-offset: 1px;
}

body.ui-version-v2 .send-btn:disabled {
  background: transparent;
  color: var(--ink-muted);
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 :is(#messageInput,#studioInstruction,.composer-actions-row) {
    transition: none;
  }
}

@media (max-width: 768px) {

  body.ui-version-v2 .chat-area {
    background-position: 62% center;
  }

  body.ui-version-v2 .messages-container {
    padding: 16px calc(15px + var(--safe-right)) 108px calc(15px + var(--safe-left));
  }

  body.ui-version-v2 .chat-header {
    grid-template-columns: 58px minmax(0, 1fr);
    min-height: 84px;
    padding: 12px;
    column-gap: 13px;
  }

  body.ui-version-v2 .v2-character-portrait {
    width: 58px;
    height: 58px;
    box-shadow: 5px 5px 0 var(--portrait-offset);
  }

  body.ui-version-v2 .chat-header-title {
    font-size: 1.25rem;
  }

  body.ui-version-v2 .message {
    padding: 18px 0;
  }

  body.ui-version-v2 .message.user {
    padding-left: 28px;
  }

  body.ui-version-v2 .message-text,
  body.ui-version-v2 .message.user .message-text {
    font-size: 16px;
    line-height: 1.68;
  }

  body.ui-version-v2 .input-area {
    padding: 22px calc(12px + var(--safe-right)) 9px calc(12px + var(--safe-left));
  }

  body.ui-version-v2 #composerExpandedScrim {
    position: fixed;
    top: var(--topbar-height);
    bottom: var(--statusbar-height);
    z-index: 160;
  }

  body.ui-version-v2 .input-area.composer-expanded {
    position: fixed;
    top: var(--topbar-height);
    bottom: var(--statusbar-height);
    z-index: 161;
    padding: 12px calc(12px + var(--safe-right)) 12px calc(12px + var(--safe-left));
  }


  body.ui-version-v2 .input-wrapper {
    padding: 0;
  }

  body.ui-version-v2 .send-btn,
  body.ui-version-v2 .stop-btn {
    transform: none;
  }
}

/* The compact header is a separate overlay, so revealing it never changes the
   transcript's scroll height or feeds back into its own threshold. */
body.ui-version-v2 .v2-sticky-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 32;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 60px;
  height: 60px;
  padding: 8px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 14%, transparent);
  background: var(--surface-canvas);
  box-shadow: 0 13px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: none;
  opacity: 0;
  visibility: hidden;
  transform: none;
  pointer-events: none;
  transition: opacity 160ms ease-out, visibility 0s linear 160ms;
}

body.ui-version-v2.v2-sticky-visible .v2-sticky-header {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
  transition: opacity 160ms ease-out, visibility 0s;
}

/* The integrated header leaves its grid slot on return to the opening.
   Hide it in that frame, before it can paint at its out-of-flow position. */
body.ui-version-v2:not(.v2-sticky-visible) .v2-sticky-header-integrated {
  transition: none;
}

/* Restored transcript decoration finishes behind the loading screen. Suppress
   its entrance transitions so the hero and compact header are already at their
   final geometry when the app is revealed. */
body.ui-version-v2.app-loading :is(
  .chat-header,
  .v2-character-portrait,
  .v2-sticky-header
) {
  transition: none;
}

/* Opening a chat decorates the hero after the transcript renders. Animating the
   hero's container columns/padding/min-height (or the portrait box) reflows the
   surrounding text while the image arrives, so those layout transitions are off
   for the settle frames and restored afterwards for the scroll collapse. */
body.ui-version-v2 .v2-character-hero.v2-hero-settling,
body.ui-version-v2 .v2-character-hero.v2-hero-settling .v2-character-portrait {
  transition: none;
}

body.ui-version-v2 .v2-sticky-character {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

body.ui-version-v2 .v2-sticky-portrait {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: var(--portrait-outline);
  border-radius: 4px;
  background: var(--v2-portrait-image) 50% 25% / cover no-repeat var(--accent-muted);
  box-shadow: 3px 3px 0 var(--portrait-offset);
  color: var(--accent-primary);
  font: 700 0.72rem/1 var(--font-v2-display);
  letter-spacing: 0.04em;
}

/* The shared title block: a small line (type badge, then subject) above the title. Surfaces set only its two sizes. */
.title-block {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.title-block-kicker {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.title-block-badge {
  flex: none;
  padding: 1px 4px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 36%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--lime-strong) 9%, transparent);
  color: var(--lime-strong);
  font: 600 var(--title-block-kicker-size, 0.49rem)/1.1 var(--font-v2-display);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
}

.title-block-subject {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-secondary);
  font: 500 calc(var(--title-block-kicker-size, 0.49rem) * 1.35)/1.15 var(--font-v2-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block-title {
  overflow: hidden;
  color: var(--ink-primary);
  font: 500 var(--title-block-title-size, 0.98rem)/1.15 var(--font-v2-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:is(.title-block-badge, .title-block-subject, .title-block-title):empty {
  display: none;
}

/* Fixed asset headers share a title-first layout. Panel title blocks keep
   their own subject-first hierarchy. */
.shell-asset-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0 6px;
  min-width: 0;
  margin: 0;
}

.shell-asset-title-stacked {
  flex-direction: column;
  align-items: flex-start;
}

.shell-asset-title > .title-block-kicker {
  flex: none;
  max-width: min(100%, 15rem);
}

.shell-asset-title > :is(.shell-asset-name, .title-block-title),
.shell-asset-title:has(> .title-block-title:empty) .title-block-subject {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-primary);
  font: 650 1rem/1.15 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
  order: -1;
}

.shell-asset-title :is(.shell-asset-badge, .title-block-badge) {
  flex: none;
  padding: 2px 5px;
  border: 0;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink-primary) 20%, transparent);
  color: var(--ink-primary);
  font: 600 calc(.5rem + 1px)/1.1 var(--font-interface);
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
}

.shell-asset-title:has(> .title-block-title:empty) > .title-block-kicker {
  display: contents;
}

@media (max-width: 1050px) {
  .studio-header-title.shell-asset-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .shell-asset-title :is(.shell-asset-badge, .title-block-badge) {
    padding-block: 1px;
  }
}

body.ui-version-v2 .v2-sticky-character:disabled {
  opacity: 1;
  cursor: default;
}

body.ui-version-v2 .v2-sticky-character:not(:disabled):focus-visible {
  outline: 1px solid color-mix(in srgb, var(--lime-strong) 58%, transparent);
  outline-offset: 4px;
}

body.ui-version-v2 .v2-memory-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 25%, transparent);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font: 650 0.625rem/1 var(--font-v2-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

body.ui-version-v2 .v2-memory-toggle:hover,
body.ui-version-v2 .v2-memory-toggle[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--lime-strong) 52%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 14%, transparent);
  color: var(--lime-default);
}

body.ui-version-v2 .v2-memory-toggle strong {
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  padding: 0 4px;
  background: var(--lime-default);
  color: var(--lime-on);
  font-size: 0.625rem;
  font-weight: 750;
}

body.ui-version-v2 .v2-memory-toggle strong:empty {
  display: none;
}

body.ui-version-v2 .v2-boost-launch-icon {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  place-items: center;
}

body.ui-version-v2 .v2-boost-launch-icon svg {
  width: 17px;
  height: 17px;
}

body.ui-version-v2 .v2-memory-backdrop {
  display: none;
}

@media (max-width: 768px) {

  body.ui-version-v2 .v2-memory-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0;
    z-index: 104;
    display: block;
    border: 0;
    border-radius: 0;
    background: color-mix(in srgb, var(--surface-canvas) 67%, transparent);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 170ms ease-out, visibility 0s linear 170ms;
  }

  body.ui-version-v2.v2-memory-open .v2-memory-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 170ms ease-out, visibility 0s;
  }

  body.ui-version-v2 .v2-memory-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: block;
    width: min(360px, calc(100vw - 44px));
    min-width: 0;
    height: 100%;
    padding-top: 13px;
    border-left-color: color-mix(in srgb, var(--ink-primary) 14%, transparent);
    box-shadow: -22px 0 55px rgba(0, 0, 0, 0.42);
    visibility: hidden;
    transform: translateX(105%);
    pointer-events: none;
    transition: transform 190ms ease-out, visibility 0s linear 190ms;
  }

  body.ui-version-v2.v2-memory-open .v2-memory-sidebar {
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    transition: transform 190ms ease-out, visibility 0s;
  }

}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-sticky-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
    min-height: 56px;
    height: 56px;
    padding: 7px calc(9px + var(--safe-right)) 7px calc(9px + var(--safe-left));
  }

  /* A phone's fixed header names the chat without the picture: less clutter and more room for the title. */
  body.ui-version-v2 .v2-sticky-portrait {
    display: none;
  }

  body.ui-version-v2 .v2-sticky-character {
    gap: 8px;
  }

  body.ui-version-v2 .v2-memory-sidebar {
    width: min(334px, calc(100vw - 30px));
  }
}

/* Conversation Boosts reuse the former Story rail without exposing app plumbing. */
body.ui-version-v2 .v2-boost-list {
  display: grid;
  gap: 9px;
  margin: 2px 0 12px;
}

body.ui-version-v2 .v2-boost-card {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-muted) 78%, transparent);
}

body.ui-version-v2 .v2-boost-card-parent {
  padding: 11px;
}

body.ui-version-v2 .v2-boost-card[data-enabled="true"] {
  border-color: color-mix(in srgb, var(--lime-strong) 34%, transparent);
  background: color-mix(in srgb, var(--surface-muted) 84%, transparent);
}

body.ui-version-v2 .v2-boost-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

body.ui-version-v2 .v2-boost-card-heading > span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

body.ui-version-v2 .v2-boost-card-heading strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: calc(0.72rem + 1px);
  font-weight: 650;
}

body.ui-version-v2 .v2-boost-card-heading small,
body.ui-version-v2 .v2-boost-cost,
body.ui-version-v2 .v2-boost-requirement {
  margin: 0;
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: calc(0.64rem + 1px);
  line-height: 1.35;
}

body.ui-version-v2 .v2-boost-switch {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 18px;
  margin-top: 1px;
}

body.ui-version-v2 .v2-boost-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

body.ui-version-v2 .v2-boost-switch i {
  position: absolute;
  inset: 0;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 20%, transparent);
  border-radius: 999px;
  background: var(--surface-muted);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

body.ui-version-v2 .v2-boost-switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-secondary);
  transition: transform 140ms ease, background 140ms ease;
}

body.ui-version-v2 .v2-boost-switch input:checked + i {
  border-color: color-mix(in srgb, var(--lime-default) 70%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 80%, transparent);
}

body.ui-version-v2 .v2-boost-switch input:checked + i::after {
  transform: translateX(14px);
  background: var(--lime-default);
}

body.ui-version-v2 .v2-boost-switch input:focus-visible + i {
  outline: 2px solid color-mix(in srgb, var(--lime-default) 80%, transparent);
  outline-offset: 2px;
}

body.ui-version-v2 .v2-boost-switch input:disabled + i {
  cursor: default;
  opacity: 0.46;
}

body.ui-version-v2 .v2-boost-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

body.ui-version-v2 .v2-boost-meta > span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: calc(0.61rem + 1px);
}

body.ui-version-v2 .v2-boost-meta > span > i {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ink-muted);
}

body.ui-version-v2 .v2-memory-sidebar[data-story-status="updating"] .v2-boost-meta > span > i {
  background: var(--lime-default);
  box-shadow: 0 0 7px color-mix(in srgb, var(--lime-default) 40%, transparent);
}

body.ui-version-v2 .v2-memory-sidebar[data-story-status="updated"] .v2-boost-meta > span > i,
body.ui-version-v2 .v2-memory-sidebar[data-story-status="unchanged"] .v2-boost-meta > span > i,
body.ui-version-v2 .v2-memory-sidebar[data-story-status="ready"] .v2-boost-meta > span > i {
  background: var(--success);
}

body.ui-version-v2 .v2-boost-meta button {
  display: inline-flex;
  min-width: 0;
  max-width: 66%;
  align-items: baseline;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-canvas) 50%, transparent);
  color: var(--ink-secondary);
  font: inherit;
  cursor: pointer;
}

body.ui-version-v2 .v2-boost-meta button strong {
  overflow: hidden;
  color: var(--ink-primary);
  font-size: calc(0.61rem + 1px);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-boost-meta button:disabled {
  cursor: default;
  opacity: 0.5;
}

body.ui-version-v2 .v2-boost-cost {
  margin-top: 7px;
  color: var(--ink-muted);
}

body.ui-version-v2 .v2-boost-card-child {
  position: relative;
  margin-top: 11px;
  margin-left: 8px;
  padding: 9px 9px 8px 15px;
  border-color: color-mix(in srgb, var(--lime-strong) 13%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 34%, transparent);
}

body.ui-version-v2 .v2-boost-card-child::before {
  content: '';
  position: absolute;
  top: -12px;
  bottom: 9px;
  left: 6px;
  width: 1px;
  background: color-mix(in srgb, var(--lime-strong) 28%, transparent);
}

body.ui-version-v2 .v2-boost-card-child[data-requirement-met="false"] {
  border-color: color-mix(in srgb, var(--ink-primary) 7%, transparent);
}

body.ui-version-v2 .v2-boost-requirement {
  margin-top: 6px;
  color: var(--lime-strong);
}

/* The Boost rail has three bounded surfaces: live output, installed controls,
   and a modal catalog. The rail itself stays fixed while only its active pane
   scrolls, so settings and output never become one long document. */
body.ui-version-v2 .v2-memory-sidebar:not(.collapsed) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.ui-version-v2 .v2-memory-view {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

body.ui-version-v2 .v2-memory-rail-toggle {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
}

body.ui-version-v2 .v2-memory-rail-toggle svg {
  width: 18px;
  height: 18px;
}

body.ui-version-v2 .v2-memory-rail-toggle:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--lime-strong) 27%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 9%, transparent);
  color: var(--lime-default);
  outline: 0;
}

body.ui-version-v2 .v2-boost-pane {
  min-height: 0;
  flex: 1 1 auto;
  padding-right: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  touch-action: pan-y;
}

body.ui-version-v2 .v2-boost-pane[hidden] {
  display: none;
}

body.ui-version-v2 .v2-boost-empty {
  display: grid;
  place-items: start;
  gap: 6px;
  margin: 5px 0;
  padding: 17px 14px;
  border: 1px dashed color-mix(in srgb, var(--ink-primary) 13%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-canvas) 40%, transparent);
}

body.ui-version-v2 .v2-boost-empty[hidden] {
  display: none;
}

body.ui-version-v2 .v2-boost-empty strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.76rem;
  font-weight: 650;
}

body.ui-version-v2 .v2-boost-empty p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-empty button,
body.ui-version-v2 .v2-boost-setup-toolbar button {
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 28%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
  color: var(--lime-default);
  font-family: var(--font-v2-display);
  font-size: 0.64rem;
  font-weight: 600;
}

body.ui-version-v2 :is(.v2-boost-dashboard-list, .v2-boost-setup-list) {
  display: grid;
  gap: 7px;
}

body.ui-version-v2 :is(.v2-boost-dashboard-card, .v2-boost-setup-card) {
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-default) 72%, transparent);
}

body.ui-version-v2 :is(.v2-boost-dashboard-card, .v2-boost-setup-card)[data-open="true"],
body.ui-version-v2 .v2-boost-setup-card[data-enabled="true"] {
  border-color: color-mix(in srgb, var(--lime-strong) 26%, transparent);
}

body.ui-version-v2 .v2-boost-dashboard-card[hidden] {
  display: none;
}

body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  color: inherit;
  text-align: left;
}

body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) > span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) strong {
  overflow: hidden;
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.73rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-muted);
  font-family: var(--font-v2-prose);
  font-size: 0.75rem;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.ui-version-v2 [data-package-headline] {
  display: block;
  min-width: 0;
}

body.ui-version-v2 .pkg-headline {
  display: grid;
  min-width: 0;
  gap: 2px;
}

body.ui-version-v2 .pkg-headline-line {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: 0.7rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

body.ui-version-v2 .pkg-headline-line.is-primary {
  color: var(--ink-secondary);
}

body.ui-version-v2 .pkg-headline[data-status="error"] .pkg-headline-line.is-primary {
  color: var(--error);
}

body.ui-version-v2 .pkg-headline[data-status="off"] .pkg-headline-line {
  color: var(--ink-muted);
}

body.ui-version-v2 .pkg-headline-meter {
  display: grid;
  grid-template-columns: auto minmax(42px, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: var(--ink-secondary);
  font: 600 0.61rem var(--font-v2-display);
}

body.ui-version-v2 .pkg-headline-meter-track {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink-primary) 10%, transparent);
}

body.ui-version-v2 .pkg-headline-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--lime-strong);
}

body.ui-version-v2 .pkg-headline-meter-value {
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) > i {
  flex: 0 0 auto;
  color: var(--ink-muted);
  font-size: 1rem;
  font-style: normal;
  transform: rotate(0deg);
  transition: transform 140ms ease, color 140ms ease;
}

body.ui-version-v2 .v2-boost-setup-card[data-open="true"] [data-boost-setup-expand] > i,
body.ui-version-v2 .v2-boost-dashboard-card[data-open="true"] [data-boost-dashboard-expand] > i {
  color: var(--lime-default);
  transform: rotate(90deg);
}

body.ui-version-v2 .v2-boost-setup-summary {
  display: flex;
  align-items: center;
  padding-right: 10px;
}

body.ui-version-v2 .v2-boost-setup-summary .v2-boost-switch {
  margin: 0;
}

body.ui-version-v2 :is(.v2-boost-dashboard-detail, .v2-boost-setup-details) {
  padding: 0 10px 10px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 7.5%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 30%, transparent);
}

body.ui-version-v2 :is(.v2-boost-dashboard-detail, .v2-boost-setup-details)[hidden] {
  display: none;
}

body.ui-version-v2 .v2-boost-setup-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 0 8px;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
}

body.ui-version-v2 .v2-boost-setup-toolbar .v2-boost-catalog-add {
  display: flex;
  width: auto;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  gap: 3px;
  padding: 4px 8px 4px 6px;
  border-radius: 4px;
  background: transparent;
  font-size: 0.61rem;
}

body.ui-version-v2 .v2-boost-catalog-add svg {
  width: 16px;
  height: 16px;
}

body.ui-version-v2 .v2-boost-setup-details .v2-boost-cost,
body.ui-version-v2 .v2-boost-setup-details .v2-boost-requirement {
  margin: 8px 0 0;
}

body.ui-version-v2 .v2-boost-setup-details .v2-boost-meta {
  margin: 9px 0 0;
}

body.ui-version-v2 .v2-boost-setup-details .v2-boost-meta b {
  overflow: hidden;
  font-weight: 540;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-boost-setting-button {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-canvas) 50%, transparent);
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.64rem;
  text-align: left;
}

body.ui-version-v2 .v2-boost-setting-button strong {
  overflow: hidden;
  color: var(--ink-primary);
  font-size: inherit;
  font-weight: 560;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-boost-setting-button i {
  color: var(--ink-muted);
  font-style: normal;
}

body.ui-version-v2 .v2-boost-settings-group {
  display: grid;
  gap: 8px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .v2-boost-settings-heading,
body.ui-version-v2 .v2-boost-setting-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

body.ui-version-v2 .v2-boost-settings-heading > strong,
body.ui-version-v2 .v2-boost-setting-name {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.68rem;
  font-weight: 650;
}

body.ui-version-v2 .v2-boost-settings-heading > small,
body.ui-version-v2 .v2-boost-setting-copy > small {
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: 0.7rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-canvas) 44%, transparent);
  cursor: pointer;
}

body.ui-version-v2 .v2-boost-setting-row :is(input[type="text"], input[type="number"], select) {
  width: 70px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 16%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
  color: var(--ink-primary);
  font: 600 0.72rem var(--font-v2-display);
  text-align: center;
}

body.ui-version-v2 .v2-boost-setting-row :is(input, select):focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 72%, transparent);
  outline: 2px solid color-mix(in srgb, var(--lime-strong) 18%, transparent);
  outline-offset: 1px;
}

body.ui-version-v2 .v2-boost-setting-toggle {
  width: 18px;
  height: 18px;
  margin: 0 3px;
  accent-color: var(--lime-strong);
}

/* Bounded list settings: one stacked draft row per entry so the editor reads
 * the same at 292px and on a full-width mobile drawer. */
body.ui-version-v2 .v2-boost-list-field,
body.ui-version-v2 .v2-boost-list-rows {
  display: grid;
  gap: 7px;
}

body.ui-version-v2 .v2-boost-list-row {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-canvas) 44%, transparent);
}

body.ui-version-v2 .v2-boost-list-cell {
  display: grid;
  min-width: 0;
  gap: 3px;
}

body.ui-version-v2 .v2-boost-list-cell > span {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
  font-weight: 600;
}

body.ui-version-v2 .v2-boost-list-cell > input {
  width: 100%;
  min-height: 30px;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 16%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
  color: var(--ink-primary);
  font: 500 0.72rem var(--font-v2-prose);
}

body.ui-version-v2 .v2-boost-list-cell > input[type="number"] {
  text-align: center;
}

body.ui-version-v2 .v2-boost-list-cell > input:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 72%, transparent);
  outline: 2px solid color-mix(in srgb, var(--lime-strong) 18%, transparent);
  outline-offset: 1px;
}

body.ui-version-v2 .v2-boost-list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

body.ui-version-v2 :is(.v2-boost-list-add, .v2-boost-list-save) {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 12%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-canvas) 50%, transparent);
  color: var(--ink-secondary);
  font: 600 0.66rem/1 var(--font-v2-display);
  cursor: pointer;
}

body.ui-version-v2 .v2-boost-list-save {
  border-color: color-mix(in srgb, var(--lime-strong) 30%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
  color: var(--lime-default);
}

body.ui-version-v2 :is(.v2-boost-list-add, .v2-boost-list-save):is(:hover, :focus-visible):not(:disabled) {
  border-color: color-mix(in srgb, var(--lime-strong) 46%, transparent);
  color: var(--ink-primary);
  outline: none;
}

body.ui-version-v2 :is(.v2-boost-list-add, .v2-boost-list-save, .v2-boost-list-remove):disabled {
  opacity: 0.45;
  cursor: default;
}

body.ui-version-v2 .v2-boost-list-remove {
  justify-self: start;
  padding: 3px 0;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
  cursor: pointer;
}

body.ui-version-v2 .v2-boost-list-remove:is(:hover, :focus-visible):not(:disabled) {
  color: var(--error);
  outline: none;
}

body.ui-version-v2 .v2-boost-list-status {
  margin: 0;
  font-family: var(--font-v2-prose);
  font-size: 0.66rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-list-status[data-tone="hint"] {
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-boost-list-status[data-tone="error"] {
  color: var(--error);
}

body.ui-version-v2 .v2-story-progress {
  display: grid;
  gap: 6px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 24%, transparent);
  border-left: 3px solid color-mix(in srgb, var(--lime-strong) 72%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-default) 58%, transparent);
}

body.ui-version-v2 .v2-story-progress[hidden] {
  display: none;
}

body.ui-version-v2 .v2-story-progress > strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.74rem;
  font-weight: 650;
}

body.ui-version-v2 .v2-story-progress > p {
  margin: 0;
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: 0.72rem;
  line-height: 1.42;
}

body.ui-version-v2 .v2-story-progress > button {
  justify-self: start;
  min-height: 30px;
  margin-top: 2px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 42%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--lime-strong) 10%, transparent);
  color: var(--lime-default);
  font: 650 0.65rem var(--font-v2-display);
}

body.ui-version-v2 .v2-story-progress > button:hover,
body.ui-version-v2 .v2-story-progress > button:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 72%, transparent);
  color: var(--lime-default);
  outline: none;
}

body.ui-version-v2 .v2-story-progress > button:disabled {
  cursor: default;
  opacity: 0.58;
}

body.ui-version-v2 .v2-boost-remove {
  margin-top: 9px;
  padding: 3px 0;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
}

body.ui-version-v2 .v2-boost-remove:hover,
body.ui-version-v2 .v2-boost-remove:focus-visible {
  color: var(--error);
  outline: none;
}

body.ui-version-v2 .v2-boost-setup-card[data-error]::after {
  content: attr(data-error);
  display: block;
  padding: 0 10px 9px;
  color: var(--error);
  font-size: 0.65rem;
  line-height: 1.35;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card {
  padding: 3px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-sections {
  display: grid;
  min-width: 0;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-section {
  min-width: 0;
  padding: 11px 3px 12px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 7.5%, transparent);
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-section-label {
  margin: 0 0 7px;
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
  font-size: 0.58rem;
  font-weight: 720;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-items {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 7px;
  padding-left: 11px;
  overflow-wrap: anywhere;
  color: var(--ink-primary);
  font-size: 0.74rem;
  line-height: 1.48;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item[hidden] {
  display: none;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item::before {
  position: absolute;
  top: 0.64em;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--lime-strong) 80%, transparent);
  content: '';
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item-text {
  min-width: 0;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item-value {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.67rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item-meta {
  color: var(--ink-muted);
  font-size: 0.7rem;
  line-height: inherit;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-item-new {
  padding: 1px 4px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 24%, transparent);
  border-radius: 3px;
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
  font-size: 0.5rem;
  font-weight: 720;
  letter-spacing: 0.06em;
  line-height: 1.25;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-show-more {
  min-height: 26px;
  margin: 7px 0 0 11px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--lime-strong);
  font: 650 0.61rem var(--font-v2-display);
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-show-more:is(:hover, :focus-visible) {
  color: var(--lime-default);
  outline: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-lines {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 9px 3px 2px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 7.5%, transparent);
  list-style: none;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-line {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-label {
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
  font-size: 0.52rem;
  font-weight: 680;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-label:empty {
  display: none;
}

body.ui-version-v2 .v2-boost-dashboard-detail .pkg-card-value {
  color: var(--ink-secondary);
  font-size: 0.66rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-output-empty {
  margin: 6px 0 0;
  color: var(--ink-muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-output-empty[hidden] {
  display: none;
}

body.ui-version-v2 .v2-boost-output-list {
  display: grid;
  gap: 5px;
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

body.ui-version-v2 .v2-boost-output-list li {
  padding: 7px 8px;
  border-left: 2px solid color-mix(in srgb, var(--lime-strong) 26%, transparent);
  background: color-mix(in srgb, var(--ink-primary) 3.5%, transparent);
  color: var(--ink-secondary);
  font-size: 0.69rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-output-list button {
  display: grid;
  width: 100%;
  gap: 2px;
  color: inherit;
  text-align: left;
}

body.ui-version-v2 .v2-boost-output-list button strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.66rem;
  font-weight: 620;
}

body.ui-version-v2 .v2-boost-output-list button small {
  color: var(--ink-muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 :is([data-boost-dashboard-expand], [data-boost-setup-expand]) > i {
    transition: none;
  }

}

/* One stable footer meter; the click target opens the detailed graphical view. */
body.ui-version-v2 .status-context-control {
  position: relative;
  display: block;
  flex: 1 1 120px;
  min-width: 72px;
  max-width: 160px;
  margin: 0 10px;
}

body.ui-version-v2 .footer-context {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 22px;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 2px;
  padding: 6px 4px 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

body.ui-version-v2 .status-context-trigger { cursor: pointer; }

@media (hover: hover) {
  body.ui-version-v2 .status-context-trigger:hover {
    background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
    color: var(--ink-secondary);
  }
}

body.ui-version-v2 .status-context-trigger:focus-visible,
body.ui-version-v2 .status-context-trigger[aria-expanded="true"] {
  background: transparent;
  color: var(--ink-secondary);
  outline: none;
  box-shadow: none;
}

body.ui-version-v2 .status-context-trigger:focus-visible .status-context-track {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-primary) 9%, transparent), 0 0 0 1px color-mix(in srgb, var(--lime-strong) 28%, transparent);
}

body.ui-version-v2 .status-context-track {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-primary) 5%, transparent);
}

body.ui-version-v2 .status-context-track > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--lime-default);
  transition: width 180ms ease;
}

body.ui-version-v2 .footer-context-label {
  min-width: 0;
  overflow: hidden;
  font-size: calc(0.61rem + 1px - 2pt);
  line-height: 1.1;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .footer-context > .status-context-track {
  grid-column: 1 / -1;
  grid-row: 1;
}

body.ui-version-v2 .footer-context > .footer-context-label {
  grid-column: 1;
  grid-row: 2;
}

/* The opened card is the focal surface: backdrop 149, footer anchor 150, card 151. */
body.ui-version-v2 .status-context-overlay {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 151;
  display: grid;
  width: min(410px, calc(100vw - 18px));
  gap: 12px;
  opacity: 0;
  outline: 0;
  transform: translateY(14px);
  transition: opacity 180ms ease-out, transform 210ms cubic-bezier(0.2, 0.72, 0.2, 1);
  pointer-events: none;
  will-change: opacity, transform;
}

body.ui-version-v2 .status-context-overlay.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.ui-version-v2 .status-context-overlay[hidden] {
  display: none;
}

body.ui-version-v2 .v2-context-backdrop {
  position: fixed;
  inset: 0;
  z-index: 149;
  content: "";
  background: color-mix(in srgb, var(--surface-canvas) 32%, transparent);
  -webkit-backdrop-filter: blur(7px) saturate(0.82);
  backdrop-filter: blur(7px) saturate(0.82);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease-out, visibility 0s linear 180ms;
  pointer-events: none;
}

body.ui-version-v2.v2-context-open .v2-context-backdrop {
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease-out, visibility 0s;
  pointer-events: auto;
}

/* The context surface lives inside Chat's isolated scene canvas. Raise that
 * canvas as one stack so the card cannot fall behind sibling drawers. */
body.ui-version-v2.v2-context-open .chat-area {
  z-index: 150;
}

body.ui-version-v2.v2-context-open .status-bar {
  z-index: 150;
}

body.ui-version-v2 .status-context-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

body.ui-version-v2 .status-context-heading > div {
  display: grid;
  gap: 2px;
}

body.ui-version-v2 .status-context-capacity {
  justify-items: end;
  text-align: right;
}

body.ui-version-v2 .status-context-capacity-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

body.ui-version-v2 .status-context-heading strong,
body.ui-version-v2 .status-context-heading b {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: calc(0.75rem + 1px);
  font-weight: 650;
}

body.ui-version-v2 .status-context-heading small,
body.ui-version-v2 .status-context-action p {
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: calc(0.64rem + 1px);
  line-height: 1.35;
}

body.ui-version-v2 .status-context-heading small:empty {
  display: none;
}

body.ui-version-v2 .status-context-swatch {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 2px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink-primary) 18%, transparent);
}

body.ui-version-v2 .status-context-stack {
  display: flex;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 4px;
  background: var(--surface-default);
}

body.ui-version-v2 .status-context-stack i {
  min-width: 1px;
  height: 100%;
  border-right: 1px solid color-mix(in srgb, var(--surface-canvas) 45%, transparent);
}

body.ui-version-v2 .status-context-stack i:last-child {
  border-right: 0;
}

body.ui-version-v2 .status-context-breakdown {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  border-radius: 6px;
}

body.ui-version-v2 .status-context-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
}

body.ui-version-v2 .status-context-row > span,
body.ui-version-v2 .status-context-row > b {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: calc(0.65rem + 1px);
}

body.ui-version-v2 .status-context-row > b {
  color: var(--ink-primary);
  font-weight: 600;
}
body.ui-version-v2 .status-context-detail + .status-context-detail {
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .status-context-detail > summary {
  list-style: none;
  cursor: pointer;
}

body.ui-version-v2 .status-context-detail > summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 .status-context-detail > summary > span {
  display: flex;
  align-items: center;
  gap: 6px;
}

body.ui-version-v2 .status-context-detail > summary > span::after {
  width: 0;
  height: 0;
  flex: none;
  border-top: 5px solid transparent;
  border-right: 0;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--ink-muted);
  content: "";
}

body.ui-version-v2 .status-context-detail[open] > summary > span::after {
  border-top: 8px solid var(--ink-muted);
  border-right: 5px solid transparent;
  border-bottom: 0;
  border-left: 5px solid transparent;
}

body.ui-version-v2 .status-context-detail > summary:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 4%, transparent);
  outline: none;
}

body.ui-version-v2 .status-context-detail > summary:focus-visible {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lime-strong) 52%, transparent);
}

body.ui-version-v2 .status-context-detail-list {
  padding: 3px 10px 7px 22px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 6%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 28%, transparent);
}

body.ui-version-v2 .status-context-detail:not([open]) > .status-context-detail-list {
  display: none;
}

body.ui-version-v2 .status-context-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: calc(0.61rem + 1px);
}

body.ui-version-v2 .status-context-detail-row > span {
  display: grid;
  gap: 1px;
}

body.ui-version-v2 .status-context-detail-row small {
  color: var(--ink-muted);
  font: inherit;
  font-size: calc(0.57rem + 1px);
}

body.ui-version-v2 .status-context-detail-row > b {
  color: var(--ink-secondary);
  font-weight: 550;
}

body.ui-version-v2 .status-context-world-lines {
  max-height: 220px;
  margin: 5px 0;
  overflow: auto;
  color: var(--ink-secondary);
  font: 0.68rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

body.ui-version-v2 .status-context-world-lines + small {
  color: var(--ink-muted);
  font-size: 0.66rem;
}

body.ui-version-v2 .status-context-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
}

body.ui-version-v2 .status-context-action p {
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
}

body.ui-version-v2 .status-context-action p[hidden] {
  display: none;
}

body.ui-version-v2 .status-context-action p[data-state="success"] {
  color: var(--success);
}

body.ui-version-v2 .status-context-action p[data-state="error"] {
  color: var(--error);
}

body.ui-version-v2 .status-context-action button {
  min-height: 32px;
  flex: none;
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 32%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--lime-strong) 9%, transparent);
  color: var(--ink-primary);
  font: 600 calc(0.64rem + 1px) var(--font-v2-display);
  cursor: pointer;
}

body.ui-version-v2 .status-context-action button:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--lime-strong) 58%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 15%, transparent);
  outline: none;
}

body.ui-version-v2 .status-context-action button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  body.ui-version-v2 .status-context-control {
    flex: 0 1 clamp(72px, 28vw, 120px);
    min-width: 72px;
    max-width: 120px;
    margin: 0 2px;
  }

  body.ui-version-v2 .footer-context { padding-inline: 2px; }

  body.ui-version-v2 .status-context-overlay {
    position: fixed;
    right: calc(5px + var(--safe-right));
    bottom: calc(var(--statusbar-height) + 7px + var(--safe-bottom));
    left: calc(5px + var(--safe-left));
    width: auto;
    max-height: min(72vh, 560px);
    overflow-y: auto;
    opacity: 0;
    transform: translateY(18px);
  }

  body.ui-version-v2 .status-context-overlay.is-open {
    transform: translateY(0);
  }

  body.ui-version-v2 .status-left {
    min-width: 0;
    max-width: 100px;
    flex: 0 1 auto;
    overflow: hidden;
  }

  body.ui-version-v2 .status-left .status-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.ui-version-v2 .status-right {
    min-width: 0;
    max-width: 42vw;
    flex: 0 1 42vw;
  }

  body.ui-version-v2 .status-right .status-model-control {
    width: auto;
    max-width: 100%;
  }

  body.ui-version-v2 #statusModel {
    max-width: calc(42vw - 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .v2-context-backdrop,
  body.ui-version-v2 .status-context-overlay {
    transition: none;
  }

  body.ui-version-v2 *,
  body.ui-version-v2 *::before,
  body.ui-version-v2 *::after {
    scroll-behavior: auto !important;
  }
}

/* Reference-led V2 workspace: image-first navigation, scene hero, and Story so far. */
body.ui-version-v2 {
  --v2-peel-fill: var(--surface-strong);
  --v2-peel-fill-hover: var(--surface-strong);
  --sidebar-width: 310px;
  --input-area-min: 132px;
  --v2-transcript-fade-depth: 48px;
  /* Minimum gap above the composer rail; the measured rail adds the rest. */
  --v2-transcript-bottom-clearance: 5px;
  --font-v2-display: var(--font-interface);
  --font-v2-prose: var(--font-reading);
  --chat-transcript-font-size: 16px;
}

body.ui-version-v2 .top-bar-inner,
body.ui-version-v2 .main-layout,
body.ui-version-v2 .status-bar-inner {
  max-width: 1600px;
}

body.ui-version-v2 .shell-opening-title,
body.ui-version-v2 .open-library-btn,
body.ui-version-v2 .chat-item-title {
  font-family: var(--font-v2-display);
}

body.ui-version-v2 .sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 18px 16px 15px;
}

body.ui-version-v2 .v2-sidebar-heading {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 1px 2px 2px;
}

body.ui-version-v2 .v2-sidebar-heading span {
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
  font-size: 0.59rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-sidebar-heading strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

body.ui-version-v2 .v2-chat-search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 39px;
  padding: 0 11px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-canvas) 40%, transparent);
  color: var(--ink-muted);
}

body.ui-version-v2 .v2-chat-search:focus-within {
  border-color: color-mix(in srgb, var(--lime-strong) 48%, transparent);
}

body.ui-version-v2 .v2-chat-search span {
  font-family: var(--font-v2-display);
  font-size: 1.15rem;
}

body.ui-version-v2 .v2-chat-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.77rem;
}

body.ui-version-v2 .v2-chat-search input::placeholder {
  color: var(--ink-muted);
}

body.ui-version-v2 .chat-list {
  padding: 9px 10px 16px;
}

body.ui-version-v2 .chat-item {
  position: relative;
  align-items: flex-start;
  gap: 12px;
  min-height: 79px;
  margin: 0 0 7px;
  padding: 10px 52px 10px 10px;
  background: color-mix(in srgb, var(--ink-primary) 1.8%, transparent);
}

body.ui-version-v2 .chat-item[hidden] {
  display: none;
}

body.ui-version-v2 .v2-chat-portrait {
  width: 52px;
  height: 59px;
  flex-basis: 52px;
  border-radius: 5px;
  object-position: 50% 32%;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.32);
}

body.ui-version-v2 .chat-item-content {
  padding-top: 2px;
}

/* A chat's first real title arrives once, instead of replacing a placeholder. */
@keyframes sandcat-title-arrive {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: none; }
}
body.ui-version-v2 .title-arrive { animation: sandcat-title-arrive 260ms ease-out; }

/* Changing conversation wipes the header title and compact identity at once;
 * the incoming conversation's settled header then fades in (app.js). */
body.ui-version-v2 #chatTitleText { transition: opacity 160ms ease-out; }
body.ui-version-v2.v2-header-wiped :is(#chatTitleText, .v2-sticky-header) {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .title-arrive { animation: none; }
  body.ui-version-v2 #chatTitleText { transition: none; }
}

body.ui-version-v2 .chat-item-title {
  color: var(--ink-primary);
  font-size: 0.88rem;
  line-height: 1.15;
}

body.ui-version-v2 .chat-item-subtitle {
  margin-top: 5px;
  color: var(--ink-secondary);
  font-family: var(--font-v2-prose);
  font-size: 0.78rem;
  font-style: italic;
}

body.ui-version-v2 .chat-item-meta {
  justify-content: flex-start;
  margin-top: 7px;
}

body.ui-version-v2 .chat-item-date {
  font-family: var(--font-v2-display);
  font-size: 0.62rem;
}

body.ui-version-v2 .chat-item-prompt,
body.ui-version-v2 .chat-item-delete {
  position: absolute;
  top: 9px;
  width: 22px;
  height: 22px;
}

body.ui-version-v2 .chat-item-prompt {
  right: 29px;
}

body.ui-version-v2 .chat-item-delete {
  right: 6px;
}

body.ui-version-v2 .chat-item-generation {
  position: absolute;
  top: 50%;
  right: 9px;
  bottom: auto;
  color: color-mix(in srgb, var(--ink-primary) 52%, transparent);
  transform: translateY(-50%);
}
body.ui-version-v2 .chat-area {
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
}

body.ui-version-v2 .messages-container {
  padding: 18px clamp(20px, 3vw, 46px) calc(var(--input-area-min) + 26px);
}

body.ui-version-v2 .powered-by-tagline-in-chat {
  max-width: 930px;
  margin-bottom: 9px;
  font-family: var(--font-v2-display);
  font-size: 0.56rem;
  letter-spacing: 0.05em;
}

body.ui-version-v2 .chat-header {
  position: sticky;
  top: 0;
  z-index: 18;
  grid-template-columns: 116px minmax(0, 1fr);
  grid-template-rows: auto auto auto auto auto;
  column-gap: 23px;
  width: 100%;
  max-width: 930px;
  min-height: 214px;
  margin: 0 auto 12px;
  padding: 28px 30px;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--lime-default) 30%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-canvas) 88%, transparent);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.36);
  transition: min-height 180ms ease, padding 180ms ease, grid-template-columns 180ms ease, background-position 220ms ease;
}

body.ui-version-v2 .v2-character-portrait {
  grid-column: 1;
  grid-row: 1 / 6;
  width: 116px;
  height: 132px;
  align-self: center;
  border-radius: 6px;
  object-position: 50% 30%;
  box-shadow: 9px 9px 0 var(--portrait-offset), 0 14px 32px rgba(0, 0, 0, 0.4);
  transition: width 180ms ease, height 180ms ease, box-shadow 180ms ease;
}

body.ui-version-v2 .v2-character-kicker {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--font-v2-display);
}

body.ui-version-v2 .chat-header-title {
  grid-column: 2;
  grid-row: 2;
  font-family: var(--font-v2-display);
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  font-weight: 500;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .chat-header-meta {
  grid-column: 2;
  grid-row: 3;
  font-family: var(--font-v2-display);
  font-size: 0.72rem;
}

body.ui-version-v2 .v2-character-description {
  grid-column: 1 / -1;
  grid-row: 4;
  min-width: 0;
  width: 100%;
  margin: 10px 0 0;
  color: var(--ink-primary);
  font-family: var(--font-v2-prose);
  font-size: 1rem;
  line-height: 1.45;
  text-align: left;
}

body.ui-version-v2 .v2-character-description-content {
  display: flow-root;
  max-height: 6lh;
  overflow: hidden;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .v2-character-description-content.is-expanded {
  max-height: none;
}

body.ui-version-v2 .v2-character-description-content.is-plain-text {
  white-space: pre-wrap;
}

body.ui-version-v2 .v2-character-description-content :is(p, blockquote, ul, ol, pre, h1, h2, h3, h4, h5, h6) {
  margin: 0 0 0.65em;
}

body.ui-version-v2 .v2-character-description-content > :last-child {
  margin-bottom: 0;
}

body.ui-version-v2 .v2-character-description-content :is(h1, h2, h3, h4, h5, h6) {
  font-size: 1.15em;
  line-height: 1.3;
}

body.ui-version-v2 .v2-character-description-content :is(ul, ol) {
  padding-left: 1.5em;
}

body.ui-version-v2 .v2-character-description-content pre {
  white-space: pre-wrap;
}

body.ui-version-v2 .v2-character-description-content :is(img, table) {
  max-width: 100%;
}

body.ui-version-v2 .v2-character-description-content img {
  display: block;
  height: auto;
  border-radius: 4px;
}

body.ui-version-v2 .v2-character-description-content a {
  color: var(--lime-default);
  text-decoration: underline;
}

body.ui-version-v2 .v2-character-description-toggle {
  margin-top: 6px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--lime-default);
  font: 600 0.75rem/1.4 var(--font-v2-display);
  cursor: pointer;
}

body.ui-version-v2 .v2-character-description-toggle[hidden] {
  display: none;
}

body.v2-character-display-open {
  overflow: hidden;
}

body.ui-version-v2 .v2-character-display {
  z-index: 1300;
}

body.ui-version-v2 .v2-character-display-modal {
  width: min(92vw, 980px);
  max-width: 980px;
  max-height: min(90dvh, 900px);
  border-radius: 10px;
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-display-modal > .modal-header {
  min-height: 64px;
  flex: 0 0 auto;
  padding: 9px 10px 9px 24px;
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-display-heading {
  min-width: 0;
}

body.ui-version-v2 .v2-character-display-heading small {
  display: block;
  overflow: hidden;
  margin-bottom: 2px;
  color: var(--lime-strong);
  font: 600 0.57rem/1.2 var(--font-v2-display);
  letter-spacing: 0.11em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body.ui-version-v2 .v2-character-display-heading h2 {
  overflow: hidden;
  color: var(--ink-primary);
  font: 500 clamp(1.05rem, 2vw, 1.35rem)/1.15 var(--font-v2-display);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-character-display-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: color-mix(in srgb, var(--lime-strong) 38%, transparent) transparent;
  scrollbar-width: thin;
}

body.ui-version-v2 .v2-character-display-media {
  display: grid;
  min-height: 0;
  margin: 0;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 82%, black);
}

body.ui-version-v2 .v2-character-display-media[hidden] {
  display: none;
}

body.ui-version-v2 .v2-character-display-media img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: 50% 20%;
}

body.ui-version-v2 .v2-character-display[data-media-shape="landscape"] .v2-character-display-media img,
body.ui-version-v2 .v2-character-display[data-media-shape="pending"] .v2-character-display-media img {
  width: 100%;
}

body.ui-version-v2 .v2-character-display:is(
  [data-media-shape="portrait"],
  [data-media-shape="square"]
) .v2-character-display-media img {
  width: auto;
  max-height: 68dvh;
}

body.ui-version-v2 .v2-character-display-copy {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 30px 38px 46px;
  color: var(--ink-primary);
  font-family: var(--font-v2-prose);
  font-size: 1rem;
  line-height: 1.58;
}

body.ui-version-v2 .v2-character-display-copy .v2-character-description-content {
  max-height: none;
  overflow: visible;
}

body.ui-version-v2 .v2-character-display-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

body.ui-version-v2 .v2-character-display-tags span {
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--lime-default) 30%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--lime-default) 7%, transparent);
  color: var(--ink-secondary);
  font: 600 0.62rem/1.25 var(--font-v2-display);
}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-character-display {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    overflow: hidden;
    transition-property: opacity, visibility;
  }

  body.ui-version-v2 .v2-character-display-modal {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    flex: 1 1 auto;
    border: 0;
    border-radius: 0;
    transform: none;
  }

  body.ui-version-v2 .v2-character-display-modal > .modal-header {
    min-height: calc(58px + var(--safe-top));
    padding: var(--safe-top) calc(4px + var(--safe-right)) 0 calc(16px + var(--safe-left));
  }

  body.ui-version-v2 .v2-character-display:is(
    [data-media-shape="portrait"],
    [data-media-shape="square"]
  ) .v2-character-display-media img {
    width: 100%;
    max-height: none;
  }

  body.ui-version-v2 .v2-character-display-copy {
    padding: 23px calc(18px + var(--safe-right)) calc(38px + var(--safe-bottom)) calc(18px + var(--safe-left));
    font-size: 0.96rem;
    line-height: 1.55;
  }
}

body.ui-version-v2 .v2-hero-badges {
  grid-column: 2;
  grid-row: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

body.ui-version-v2 .v2-hero-badges span {
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 24%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-canvas) 55%, transparent);
  color: var(--lime-default);
  font-family: var(--font-v2-display);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.ui-version-v2 .greeting-selector,
body.ui-version-v2 .message {
  max-width: 900px;
}

body.ui-version-v2 .message {
  padding: 25px 22px;
}

body.ui-version-v2 .message.assistant {
  background: transparent;
}

body.ui-version-v2 .message.user {
  padding-left: clamp(70px, 10vw, 150px);
  background: transparent;
}

body.ui-version-v2 .message-role {
  font-family: var(--font-v2-display);
}

body.ui-version-v2 .message-text,
body.ui-version-v2 .message.user .message-text {
  font-family: var(--font-v2-prose);
  font-size: var(--chat-transcript-font-size);
  line-height: 1.74;
}

body.ui-version-v2 .message.assistant .message-text q {
  color: var(--ink-primary);
  font-size: 1.035em;
  font-weight: 500;
}

body.ui-version-v2 .message.assistant .message-text > p > em {
  color: var(--ink-secondary);
  font-size: 0.97em;
  letter-spacing: 0.005em;
}

body.ui-version-v2 .message-external-event {
  position: relative;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(24px, 0.16fr) minmax(0, 1fr) minmax(24px, 0.16fr);
  align-items: center;
  gap: 18px;
  width: calc(100% - 36px);
  max-width: 900px;
  margin: 2px auto 16px;
  padding: 18px 22px;
  overflow: hidden;
  border-block: 1px solid color-mix(in srgb, var(--accent-primary) 62%, transparent);
  background: var(--surface-muted);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), inset 0 1px color-mix(in srgb, var(--ink-primary) 4%, transparent);
  animation: v2-external-event-reveal 420ms ease-out both;
}

body.ui-version-v2 .message-external-event > span {
  height: 1px;
  background: var(--lime-default);
}

body.ui-version-v2 .message-external-event > span:last-child {
  background: var(--lime-default);
}

body.ui-version-v2 .message-external-event p {
  margin: 0;
  color: var(--ink-primary);
  font-family: var(--font-v2-prose);
  font-size: 18px;
  font-style: italic;
  line-height: 1.55;
  text-align: center;
  white-space: pre-wrap;
  text-wrap: pretty;
}

@keyframes v2-external-event-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: brightness(1.35);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: brightness(1);
  }
}

@media (max-width: 768px) {
  body.ui-version-v2 .message-external-event {
    grid-template-columns: 18px minmax(0, 1fr) 18px;
    gap: 10px;
    width: calc(100% - 20px);
    margin-bottom: 12px;
    padding: 15px 12px;
  }

  body.ui-version-v2 .message-external-event p {
    font-size: 16px;
    line-height: 1.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .message-external-event {
    animation: none;
  }
}

body.ui-version-v2 .input-area {
  padding-top: 18px;
}

body.ui-version-v2 .message-turn-primary,
body.ui-version-v2 .message-model-flow {
  width: min(100%, 760px);
  min-width: 0;
}

body.ui-version-v2 .message-turn-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 9px;
}

/* One footer row per reply: the turn summary on the left, the reply actions on
 * the right. The flow is transparent to layout so its summary and its opened
 * body are direct row items; the body always takes a full line below. When the
 * two do not fit, the actions wrap to their own line. */
body.ui-version-v2 .message-turn-footer {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 12px;
  margin-top: 2px;
}

body.ui-version-v2 .message-turn-footer > .message-model-flow {
  display: contents;
}

body.ui-version-v2 .message-turn-footer > .message-model-flow[hidden],
body.ui-version-v2 .message-turn-primary[hidden] {
  display: none;
}

body.ui-version-v2 .message-turn-footer .message-model-turn-summary {
  order: 1;
  width: auto;
  flex: 0 1 auto;
}

body.ui-version-v2 .message-turn-footer > .message-turn-primary {
  order: 2;
  width: auto;
  flex-wrap: nowrap;
  gap: 5px;
  margin: 0 0 0 auto;
}

body.ui-version-v2 .message-turn-footer .message-model-turn-body {
  order: 3;
  flex: 0 0 100%;
  min-width: 0;
  max-width: 760px;
}

/* One disclosure caret for every transcript and footer trigger: the solid
 * triangle the model picker introduced, sized from the surrounding text so it
 * reads alike wherever it sits. Closed points down; open points up. */
body.ui-version-v2 {
  --disclosure-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 3h8L5 8z'/%3E%3C/svg%3E");
}

body.ui-version-v2 .disclosure-caret,
body.ui-version-v2 .message.assistant .message-thinking-toggle::after,
body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal, .message-model-step-attempt, .studio-carried-discussion) > summary::after,
body.ui-version-v2 .message-prompt-boost-package > summary::before {
  content: '';
  display: inline-block;
  flex: 0 0 auto;
  width: 0.9em;
  height: 0.9em;
  margin: 0;
  border: 0;
  background: currentColor;
  -webkit-mask: var(--disclosure-caret) center / contain no-repeat;
  mask: var(--disclosure-caret) center / contain no-repeat;
  color: var(--ink-muted);
  font-size: inherit;
  vertical-align: -0.12em;
  transform: none;
  transition: transform 140ms ease;
}

body.ui-version-v2 [aria-expanded="true"] > .disclosure-caret,
body.ui-version-v2 details[open] > summary > .disclosure-caret,
body.ui-version-v2 .message.assistant .message-thinking-toggle:not(.collapsed)::after,
body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal, .message-model-step-attempt, .studio-carried-discussion)[open] > summary::after,
body.ui-version-v2 .message-prompt-boost-package[open] > summary::before {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .disclosure-caret,
  body.ui-version-v2 .message.assistant .message-thinking-toggle::after,
  body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal, .message-model-step-attempt, .studio-carried-discussion) > summary::after,
  body.ui-version-v2 .message-prompt-boost-package > summary::before {
    transition: none;
  }
}

/* A rejected edit lists one invalid operation per line. */
body.ui-version-v2 .studio-tool-error {
  white-space: pre-line;
}

body.ui-version-v2 .studio-carried-discussion > summary {
  list-style: none;
}

body.ui-version-v2 .studio-carried-discussion > summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 .studio-carried-discussion > summary::after {
  margin-left: 4px;
}

/* Turn activity keeps one primary rail. A contributor with an explicit parent
 * receives one bounded extra indent beneath that consumer; expanded evidence
 * stays inside its own row rather than creating another transcript level. */
body.ui-version-v2 .message-model-flow {
  --turn-gutter: 14px;
  --turn-rail: color-mix(in srgb, var(--lime-strong) 22%, transparent);
  display: block;
  margin-top: 6px;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: calc(0.61rem + 1pt);
  line-height: 1.35;
}

body.ui-version-v2 .message-model-flow:not(:has(.message-model-step:not([hidden]))) {
  display: none;
}

body.ui-version-v2 .message-model-turn-summary {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

body.ui-version-v2 .message-model-turn-stage {
  display: inline-flex;
  max-width: min(34%, 12rem);
  min-width: 0;
  flex: 0 1 auto;
  align-items: center;
  padding: 1px 5px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink-primary) 5%, transparent);
  color: var(--ink-secondary);
  font: 650 calc(0.47rem + 1pt)/1.25 var(--font-v2-display);
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-turn-stage[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-turn-summary:is(:hover, :focus-visible) .message-model-turn-label {
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-model-turn-summary:focus-visible {
  border-radius: 2px;
  outline: 1px solid color-mix(in srgb, var(--lime-strong) 70%, transparent);
  outline-offset: 2px;
}

body.ui-version-v2 .message-model-turn-mark {
  display: grid;
  width: var(--turn-gutter);
  flex: 0 0 var(--turn-gutter);
  place-items: center start;
  color: var(--ink-secondary);
  font-size: calc(0.68rem + 1pt);
  font-weight: 900;
}

body.ui-version-v2 .message-model-flow[data-turn-state="done"] .message-model-turn-mark {
  color: var(--success);
}

body.ui-version-v2 .message-model-flow[data-turn-state="attention"] .message-model-turn-mark {
  color: var(--error);
}

body.ui-version-v2 .message-model-flow[data-turn-state="notice"] .message-model-turn-mark {
  color: var(--lime-strong);
}

body.ui-version-v2 .message-model-flow[data-turn-state="warning"] .message-model-turn-mark {
  color: var(--warning);
}

body.ui-version-v2 .message-model-turn-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.ui-version-v2 .message-model-turn-counter {
  flex: 0 0 auto;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-turn-counter[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-flow[data-turn-state="attention"] .message-model-turn-label {
  color: var(--error);
}

body.ui-version-v2 .message-model-flow[data-turn-state="warning"] .message-model-turn-label {
  color: var(--warning);
}

body.ui-version-v2 .message-model-turn-summary > .message-model-turn-chevron {
  margin-left: 4px;
}

body.ui-version-v2 .message-model-turn-body {
  position: relative;
  padding: 1px 0 3px var(--turn-gutter);
}

body.ui-version-v2 .message-model-turn-body[hidden] {
  display: none;
}

/* Boosts run: one tinted card that names every participating Boost before
 * the stage rail, so ownership reads first and step evidence follows. */
body.ui-version-v2 .message-model-turn-boosts {
  margin: 4px 0 7px calc(-1 * var(--turn-gutter));
  padding: 5px 9px 6px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 14%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--lime-strong) 5%, var(--surface-muted));
}

body.ui-version-v2 .message-model-turn-boosts[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-turn-boosts-heading,
body.ui-version-v2 .message-model-turn-totals-title {
  margin: 0;
  color: var(--ink-secondary);
  font-size: calc(0.5rem + 1pt);
  font-weight: 650;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

body.ui-version-v2 .message-model-turn-boosts ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

body.ui-version-v2 .message-model-turn-boosts li {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 10px;
}

body.ui-version-v2 .message-model-turn-boosts li strong {
  color: var(--ink-primary);
  font-weight: 600;
}

body.ui-version-v2 .message-model-turn-boost-states {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

body.ui-version-v2 .message-model-turn-boost-chip {
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-primary) 7%, transparent);
  color: var(--ink-muted);
  font-size: calc(0.52rem + 1pt);
  white-space: nowrap;
}

body.ui-version-v2 .message-model-turn-boost-chip[data-state="ran"] {
  background: color-mix(in srgb, var(--success) 13%, transparent);
  color: color-mix(in srgb, var(--success) 82%, var(--ink-primary));
}

body.ui-version-v2 .message-model-turn-boost-chip[data-state="running"] {
  background: color-mix(in srgb, var(--lime-strong) 14%, transparent);
  color: var(--lime-strong);
}

body.ui-version-v2 .message-model-steps {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* The one rail: every step marker sits on it, whatever its owner or stage. */
body.ui-version-v2 .message-model-steps::before {
  position: absolute;
  top: 2px;
  bottom: 6px;
  left: calc(3px - var(--turn-gutter));
  width: 1px;
  background: var(--turn-rail);
  content: '';
}

/* Closing ledger, aligned with the Boosts card so the expanded turn reads
 * as one bounded block. */
body.ui-version-v2 .message-model-turn-totals {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  margin: 6px 0 0 calc(-1 * var(--turn-gutter));
  padding: 5px 0 0 9px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
  color: var(--ink-muted);
  font-size: calc(0.58rem + 1pt);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .message-model-turn-totals b {
  color: var(--ink-secondary);
  font-weight: 600;
}

body.ui-version-v2 .message-model-turn-totals[hidden] {
  display: none;
}

body.ui-version-v2 :is(.message-turn-actions, .message-turn-user-actions) {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 5px;
}

body.ui-version-v2 .message-turn-action {
  display: inline-flex;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
  line-height: 0;
}

body.ui-version-v2 .message-turn-action-label {
  display: none;
}

body.ui-version-v2 .message-turn-action-icon {
  display: block;
  width: 15px;
  height: 15px;
}

body.ui-version-v2 .message-turn-editor-actions button {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 15%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--surface-default) 72%, transparent);
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
  font-weight: 600;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

body.ui-version-v2 .message-turn-action:hover,
body.ui-version-v2 .message-turn-actions > .message-action.message-raw-toggle:hover {
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-turn-action:focus-visible {
  outline: 2px solid var(--lime-strong);
  outline-offset: 2px;
}

body.ui-version-v2 .message-turn-editor-actions button:hover,
body.ui-version-v2 .message-turn-editor-actions button:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 55%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 10%, transparent);
  color: var(--lime-default);
  outline: none;
}

body.ui-version-v2 :is(.message-turn-action-delete, .message-turn-user-delete):hover,
body.ui-version-v2 :is(.message-turn-action-delete, .message-turn-user-delete):focus-visible {
  color: var(--error);
}

body.ui-version-v2 .message.user .message-turn-primary {
  justify-content: flex-end;
  margin-left: auto;
}

body.ui-version-v2 .message-model-step-retry {
  width: max-content;
  margin-top: 2px;
}

body.ui-version-v2 .message-turn-editor {
  display: grid;
  gap: 9px;
  margin-top: 7px;
}

body.ui-version-v2 .message-turn-editor-input {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 42%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-canvas) 88%, transparent);
  color: var(--ink-primary);
  font-family: var(--font-v2-prose);
  font-size: 17px;
  line-height: 1.6;
}

body.ui-version-v2 .message-turn-editor-input:focus {
  border-color: color-mix(in srgb, var(--lime-strong) 72%, transparent);
  outline: 2px solid color-mix(in srgb, var(--lime-strong) 10%, transparent);
  outline-offset: 1px;
}

body.ui-version-v2 .message-turn-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

body.ui-version-v2 .input-wrapper {
  font-family: var(--font-v2-prose);
}

body.ui-version-v2 #messageInput {
  font-family: var(--font-v2-prose);
  font-size: calc(17px - 1pt);
}

body.ui-version-v2 .v2-memory-sidebar {
  /* Open and closed desktop states share one track width, so releasing the
   * column by a negative margin cannot drift from the panel's painted width. */
  --v2-memory-track: max(320px, var(--v2-memory-width, 340px));
  width: var(--v2-memory-width, 292px);
  min-width: var(--v2-memory-width, 292px);
  padding: 17px 15px 24px;
  overflow-y: auto;
  scroll-padding-top: 48px;
  overscroll-behavior: none;
  touch-action: pan-y;
  border-left: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  background: var(--surface-default);
  --busy-surface: var(--surface-default);
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-boost-status-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body.ui-version-v2 .v2-memory-view[hidden] {
  display: none;
}

body.ui-version-v2 .v2-memory-label {
  display: block;
  margin-bottom: 8px;
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

body.ui-version-v2 .message-variant-button {
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  place-items: center;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
  line-height: 0;
}

body.ui-version-v2 .message-variant-icon {
  display: block;
  width: 13px;
  height: 13px;
}

body.ui-version-v2 .message-variant-button:hover {
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-variant-button:focus-visible {
  outline: 2px solid var(--lime-strong);
  outline-offset: 2px;
}

/* Boosts and World need a selected conversation. The workspace Assistant does not.
   Desktop only: a phone drawer's closed state is its offscreen transform, so removing
   it from display on the same frame as the transform would skip the slide. */
@media (min-width: 769px) {
  body.ui-version-v2.v2-no-chat .v2-memory-sidebar:not([data-side-panel="assistant"]) {
    display: none !important;
  }
}

/* The rail gap, not the message's inter-turn padding, spaces the final row.
   Structural, so a pending reply owns it from the frame it is inserted. */
body.ui-version-v2 .messages-container:not([data-transcript-more-below]) > .message:not(:has(~ .message)) {
  padding-bottom: 0;
}

/* Final cascade guards for the overlay header and responsive memory drawer. */

/* Transcript density, legibility, and split-image hero polish. */

body.ui-version-v2 .message-text pre {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-text pre code {
  /* Relative sizing must bypass the authored fixed-size font scaler. */
  --message-code-font-size: calc(0.875em - 1pt);
  padding: var(--space-3);
  background: var(--code-block-bg);
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  font-size: var(--message-code-font-size);
}

body.ui-version-v2 [hidden] {
  display: none !important;
}

body.ui-version-v2 .message-variant-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 3px;
}

body.ui-version-v2 .message-variant-count {
  min-width: 30px;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: 0.62rem;
  text-align: center;
}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-memory-sidebar {
    display: none;
  }
}

@media (max-width: 1000px) and (min-width: 769px) {
  body.ui-version-v2 {
    --sidebar-width: 280px;
  }

  body.ui-version-v2 .chat-header {
    grid-template-columns: 92px minmax(0, 1fr);
    min-height: 190px;
    padding: 23px;
  }

  body.ui-version-v2 .v2-character-portrait {
    width: 92px;
    height: 112px;
  }
}

@media (max-width: 768px) {
  body.ui-version-v2 {
    --sidebar-width: 300px;
    --input-area-min: 126px;
  }

  body.ui-version-v2 .sidebar-header {
    padding: 14px;
  }

  body.ui-version-v2 .messages-container {
    padding-top: 10px;
    padding-bottom: calc(var(--input-area-min) + 22px);
  }

  body.ui-version-v2 .powered-by-tagline-in-chat {
    margin-bottom: 6px;
  }

  body.ui-version-v2 .chat-header {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    min-height: 184px;
    padding: 17px;
    column-gap: 15px;
    background: color-mix(in srgb, var(--surface-canvas) 92%, transparent);
  }

  body.ui-version-v2 .v2-character-portrait {
    width: 72px;
    height: 86px;
    grid-row: 1 / 4;
    align-self: start;
  }

  body.ui-version-v2 .chat-header-title {
    font-size: 1.45rem;
  }

  body.ui-version-v2 .v2-character-description {
    grid-column: 1 / -1;
    margin-top: 14px;
    font-size: 0.92rem;
  }

  body.ui-version-v2 .v2-hero-badges {
    grid-column: 1 / 3;
    margin-top: 10px;
  }

  body.ui-version-v2 .message {
    padding: 21px 15px;
  }

  body.ui-version-v2 .message.user {
    padding-left: 36px;
  }

  body.ui-version-v2 .message-text,
  body.ui-version-v2 .message.user .message-text {
    font-size: var(--chat-transcript-font-size);
    line-height: 1.7;
  }

}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .chat-header,
  body.ui-version-v2 .v2-character-portrait {
    transition: none;
  }
}

/* Integrated transcript hero, per-thread challenges, and full-scene canvas. */
body.ui-version-v2 .chat-area {
  --v2-scene-image: none;
  container-type: inline-size;
  isolation: isolate;
  background: var(--surface-canvas);
}

body.ui-version-v2 .chat-area::before,
body.ui-version-v2 .chat-area::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

body.ui-version-v2 .chat-area::before {
  z-index: 0;
  background: var(--v2-scene-image) center / cover no-repeat;
  filter: saturate(0.72) contrast(1.05);
  opacity: 0.34;
  transform: scale(1.015);
}

body.ui-version-v2 .chat-area::after {
  z-index: 0;
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
}

body.ui-version-v2 .chat-empty,
body.ui-version-v2 .chat-active {
  z-index: 1;
}

body.ui-version-v2 .messages-container {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0 0 max(var(--v2-transcript-bottom-clearance), var(--v2-transcript-dock-clearance, 0px));
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: transparent;
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--v2-transcript-fade-depth)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--v2-transcript-fade-depth)),
    transparent 100%
  );
  opacity: 1;
  transition: opacity 120ms ease-out;
}

body.ui-version-v2 .powered-by-tagline-in-chat {
  display: none;
}

body.ui-version-v2 .chat-header {
  grid-template-columns: 116px minmax(280px, 1fr) minmax(176px, 220px);
  grid-template-rows: auto auto auto auto auto;
  column-gap: 24px;
  width: 100%;
  max-width: none;
  min-height: 226px;
  margin: 0;
  padding: 34px clamp(25px, 5vw, 68px) 30px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 12%, transparent);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body.ui-version-v2 .v2-character-portrait,
body.ui-version-v2 .v2-chat-portrait {
  display: block;
  flex-shrink: 0;
  background: var(--v2-portrait-image) 50% 25% / cover no-repeat;
}

body.ui-version-v2 .v2-character-portrait {
  display: grid;
  place-items: center;
  background-color: var(--accent-muted);
  color: var(--accent-primary);
  font: 700 clamp(1.2rem, 4vw, 2.4rem)/1 var(--font-v2-display);
  letter-spacing: 0.04em;
}

body.ui-version-v2 .v2-character-portrait {
  width: 116px;
  height: 150px;
}

body.ui-version-v2 .greeting-selector,
body.ui-version-v2 .message {
  width: calc(100% - clamp(34px, 7vw, 92px));
  max-width: 900px;
}

body.ui-version-v2 .message.assistant {
  background: transparent;
}

body.ui-version-v2 .message.user {
  background: transparent;
}

body.ui-version-v2 .chat-item {
  min-height: 96px;
}

body.ui-version-v2 .chat-item.v2-seeded-thread {
  padding-right: 10px;
}

body.ui-version-v2 .chat-item.v2-seeded-thread .chat-item-prompt,
body.ui-version-v2 .chat-item.v2-seeded-thread .chat-item-delete {
  display: none;
}

body.ui-version-v2 .v2-chat-portrait {
  width: 52px;
  height: 64px;
  flex-basis: 52px;
}

@media (max-width: 1100px) and (min-width: 769px) {
  body.ui-version-v2 .chat-header {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto;
    min-height: 244px;
    padding: 27px clamp(24px, 4vw, 48px) 24px;
  }

  body.ui-version-v2 .v2-character-portrait {
    width: 92px;
    height: 122px;
    grid-row: 1 / 6;
  }

}

@media (max-width: 768px) {
  body.ui-version-v2 .chat-area::before {
    opacity: 0.27;
  }

  body.ui-version-v2 .messages-container {
    padding: 0 0 max(var(--v2-transcript-bottom-clearance), var(--v2-transcript-dock-clearance, 0px));
  }

  body.ui-version-v2 .chat-header {
    grid-template-columns: 70px minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto;
    min-height: 238px;
    padding: 22px calc(17px + var(--safe-right)) 20px calc(17px + var(--safe-left));
    column-gap: 15px;
  }

  body.ui-version-v2 .v2-character-portrait {
    width: 70px;
    height: 94px;
  }

  body.ui-version-v2 .greeting-selector,
  body.ui-version-v2 .message {
    width: calc(100% - 26px - var(--safe-left) - var(--safe-right));
  }
}

/* Final cascade guards for the overlay header and responsive memory drawer. */
body.ui-version-v2 .messages-container > .v2-character-hero {
  position: relative;
  top: auto;
  z-index: 1;
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  body.ui-version-v2 .main-layout > .v2-memory-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 105;
    display: block;
    width: min(360px, calc(100vw - 44px));
    min-width: 0;
    height: auto;
    padding: 0 15px 24px;
    overflow-y: auto;
    overscroll-behavior: none;
    touch-action: pan-y;
    backface-visibility: hidden;
    visibility: hidden;
    transform: translate3d(100%, 0, 0);
    pointer-events: none;
    will-change: transform;
    transition: transform var(--transition-normal), visibility 0s linear 200ms;
  }

  body.ui-version-v2.v2-memory-open .main-layout > .v2-memory-sidebar {
    visibility: visible;
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    transition: transform var(--transition-normal), visibility 0s;
  }
}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-sticky-header .v2-sticky-goal {
    grid-template-columns: 1fr;
    gap: 3px;
    padding-left: 9px;
  }

  body.ui-version-v2 .main-layout > .v2-memory-sidebar {
    width: min(334px, calc(100vw - 30px));
  }
}

/* Transcript density, legibility, and split-image hero polish. */
body.ui-version-v2 .chat-area::before {
  filter: saturate(0.8) contrast(1.04) brightness(0.9);
  opacity: 0.56;
}

body.ui-version-v2 .chat-area::after {
  background: color-mix(in srgb, var(--surface-canvas) 72%, transparent);
}

body.ui-version-v2 .chat-header.v2-character-hero {
  --v2-hero-image-width: clamp(190px, 24%, 230px);
  grid-template-columns: minmax(0, 1fr);
  min-height: 246px;
  max-width: none;
  padding-left: calc(var(--v2-hero-image-width) + clamp(28px, 4vw, 52px));
  overflow: hidden;
}

body.ui-version-v2 .chat-header.v2-character-hero > :not(.v2-character-portrait) {
  position: relative;
  z-index: 1;
}

body.ui-version-v2 .chat-header.v2-character-hero .v2-character-portrait {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 0;
  grid-column: auto;
  grid-row: auto;
  align-self: auto;
  width: var(--v2-hero-image-width);
  height: 100%;
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--ink-primary) 13%, transparent);
  border-radius: 0;
  background-position: 50% 22%;
  box-shadow: inset -38px 0 42px -34px color-mix(in srgb, var(--surface-canvas) 90%, transparent);
}

body.ui-version-v2 .chat-header.v2-character-hero .v2-character-kicker,
body.ui-version-v2 .chat-header.v2-character-hero .chat-header-title,
body.ui-version-v2 .chat-header.v2-character-hero .chat-header-meta,
body.ui-version-v2 .chat-header.v2-character-hero .v2-hero-badges {
  grid-column: 1;
}

body.ui-version-v2 .message {
  padding-top: 17px;
  padding-bottom: 17px;
}

body.ui-version-v2 .message-body,
body.ui-version-v2 .message.user .message-body {
  gap: 6px;
}

body.ui-version-v2 .message-text,
body.ui-version-v2 .message.user .message-text {
  white-space: normal;
}

body.ui-version-v2 .message-text p + p {
  margin-top: 0.5lh;
}

/* Latest-turn flow: finite runway is shared by layout growth and reader travel. */
body.ui-version-v2 .messages-container::after {
  display: none;
  height: 0;
}

body.ui-version-v2 .chat-active.turn-flow-active:not(.turn-flow-runway-released) .messages-container::after,
body.ui-version-v2 .chat-active.turn-flow-retained .messages-container::after {
  display: block;
  height: var(--v2-turn-runway-height, clamp(190px, 42vh, 430px));
}

body.ui-version-v2 .message.user {
  justify-content: flex-end;
  padding-left: clamp(42px, 11vw, 170px);
  background: transparent;
}

body.ui-version-v2 .message.user .message-body {
  align-items: flex-end;
}

body.ui-version-v2 .message.user .message-role {
  display: none;
}

body.ui-version-v2 .message.user .message-content {
  width: auto;
  max-width: min(100%, 760px);
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  border-radius: 15px 15px 4px 15px;
  background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

body.ui-version-v2 .message.user .message-text {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-primary);
}

body.ui-version-v2 .message.user .message-text > * {
  background-color: transparent;
}

body.ui-version-v2 .message-flight-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  margin: 0 0 7px;
}

body.ui-version-v2 .message-role .message-flight-indicator {
  min-height: 0;
  margin: -3px 0;
}

body.ui-version-v2 .message-flight-status {
  color: var(--ink-muted);
  font: 450 0.58rem/1 var(--font-v2-display);
  letter-spacing: 0.035em;
  text-transform: none;
}

body.ui-version-v2 .message.assistant .message-thinking {
  width: 100%;
  margin: 0 0 9px;
}

body.ui-version-v2 .message.assistant .message-thinking-toggle {
  width: 100%;
  padding: 0 0 4px;
  color: var(--ink-muted);
  font: 500 0.72rem/1.3 var(--font-v2-display);
}

body.ui-version-v2 .message.assistant .message-thinking-toggle::before {
  display: none;
}

body.ui-version-v2 .message.assistant .message-thinking-toggle::after {
  margin-left: 2px;
}

body.ui-version-v2 .message.assistant .message-thinking-body {
  width: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
  font-family: var(--font-v2-prose);
  font-size: 0.86rem;
  font-style: italic;
  line-height: 1.5;
  white-space: normal;
}

/* Partial Markdown can temporarily look like a heading until the next chunk
   resolves its syntax. Keep provisional type at the surrounding stream size. */
body.ui-version-v2 .message.assistant .message-thinking-body :is(h1, h2, h3, h4, h5, h6),
body.ui-version-v2 .message.assistant .message-text :is(h1, h2, h3, h4, h5, h6) {
  font-size: inherit;
  line-height: inherit;
}

body.ui-version-v2 .message.assistant .message-thinking[data-live="true"] .message-thinking-body {
  height: 4em;
  max-height: 4em;
  overflow: hidden;
}

body.ui-version-v2 .message.assistant .message-thinking[data-live="true"].thinking-expanded .message-thinking-body {
  height: auto;
  max-height: none;
  overflow: visible;
}

body.ui-version-v2 .message.assistant .message-thinking:not([data-live="true"]) .message-thinking-toggle:not(.collapsed) + .message-thinking-body {
  width: calc(100% - 16px);
  margin: 0 8px 16px;
}

body.ui-version-v2 .message.assistant .message-thinking-body p {
  margin: 0;
}

body.ui-version-v2 .message.assistant .message-thinking-body p + p {
  margin-top: 0.5lh;
}

body.ui-version-v2 .message.assistant .message-thinking-body strong,
body.ui-version-v2 .message.assistant .message-thinking-body b {
  color: var(--ink-muted);
}

body.ui-version-v2 .message.assistant .message-thinking-body pre {
  white-space: pre-wrap;
}

body.ui-version-v2 .message-model-step {
  /* The marker centres on the summary's first text line, not a fixed offset, so
   * it follows the activity type scale, the summary padding and a stage label. */
  --step-marker-line: calc(3px + (1lh - 11px) / 2);
  --step-marker-top: var(--step-marker-line);
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: calc(0.61rem + 1pt);
  line-height: 1.35;
}

/* Contribution handlers are visible parts of their consumer's pipeline, not
 * competing top-level work. The runtime supplies a trusted parent identity;
 * deeper chains cap their visual offset so narrow transcripts stay usable. */
body.ui-version-v2 .message-model-step[data-parent-step-id] {
  width: calc(100% - var(--model-step-indent, 14px));
  margin-left: var(--model-step-indent, 14px);
}

/* Stage label: printed once where the turn enters a new phase, inline with
 * the rail rather than as another container. */
body.ui-version-v2 .message-model-step[data-phase-label] {
  /* The label's own line box plus its 6px padding; both scale with the interface. */
  --phase-label-block: calc(1.2 * (0.5rem + 1pt) * var(--chat-font-scale, 1) + 6px);
  --step-marker-top: calc(var(--phase-label-block) + var(--step-marker-line));
}

body.ui-version-v2 .message-model-step[data-phase-label]::before {
  display: block;
  padding: 5px 0 1px;
  color: color-mix(in srgb, var(--lime-strong) 58%, var(--ink-muted));
  content: attr(data-phase-label);
  font-size: calc(0.5rem + 1pt);
  font-weight: 650;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* One state language at every depth: amber pulses while a step runs, green
 * means complete, and terminal problems keep their explicit warning colours. */
body.ui-version-v2 .message-model-step::after {
  position: absolute;
  top: var(--step-marker-top);
  left: calc(-1 * var(--turn-gutter, 14px) - 2px);
  box-sizing: border-box;
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: var(--ink-muted);
  content: '';
}

body.ui-version-v2 .message-model-step[data-live="true"]::after {
  border: 0;
  background: var(--activity-live);
  animation: activity-pulse 1.35s ease-in-out infinite;
  transform-origin: center;
}

body.ui-version-v2 .message-model-step:is([data-status="updated"], [data-status="unchanged"], [data-status="complete"])::after {
  background: var(--success);
}

body.ui-version-v2 .message-model-step:is([data-status="failed"], [data-status="timeout"])::after {
  background: var(--error);
}

body.ui-version-v2 .message-model-step:is([data-status="stopped"], [data-status="unconfirmed"])::after {
  background: var(--lime-strong);
}

body.ui-version-v2 .message-model-step[data-status="warning"]::after {
  background: var(--warning);
}

body.ui-version-v2 .message-model-step-summary {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  list-style: none;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-heading {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

body.ui-version-v2 .message-generation-metadata {
  align-self: stretch;
}

body.ui-version-v2 .message-generation-metadata .generation-receipt-summary {
  justify-content: flex-start;
}

body.ui-version-v2 .message-model-step-summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 .message-model-step[data-has-details="true"] .message-model-step-summary {
  cursor: pointer;
}

body.ui-version-v2 .message-model-step-heading,
body.ui-version-v2 .message-model-step-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
}

body.ui-version-v2 .message-model-step-metrics {
  display: inline-flex;
  max-width: min(44%, 240px);
  min-width: 0;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: calc(0.58rem + 1pt);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-call-icon {
  display: inline-grid;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  place-items: center;
  color: var(--lime-strong);
}

body.ui-version-v2 .message-model-step-call-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

body.ui-version-v2 .message-model-step-call-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.ui-version-v2 .message-model-step-call-count {
  flex: 0 0 auto;
  color: var(--ink-muted);
}

body.ui-version-v2 .message-receipt-model {
  min-width: 4ch;
  overflow: hidden;
  flex: 0 1 auto;
  color: var(--ink-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .message-receipt-tokens,
body.ui-version-v2 .message-receipt-tps,
body.ui-version-v2 .message-receipt-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  white-space: nowrap;
}

body.ui-version-v2 .message-receipt-separator {
  color: var(--ink-muted);
}

body.ui-version-v2 .message-model-step-summary strong {
  overflow: hidden;
  color: var(--ink-secondary);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step small {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The rail marker carries state; the per-subject icon is not repeated. */
body.ui-version-v2 .message-model-step-icon {
  display: none;
}

body.ui-version-v2 .message-model-step-status {
  flex: 0 0 auto;
  overflow: visible;
}
/* The rail already carries nested state. Suppress its duplicate inline mark;
 * the adjacent label still names the running or terminal result. */
body.ui-version-v2 .message-model-step-status-mark {
  display: none;
}

body.ui-version-v2 .message-model-step[data-live="true"] .message-model-step-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

body.ui-version-v2 .message-model-step-status-label[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step[data-status="updated"] .message-model-step-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--success);
  line-height: 1;
}

body.ui-version-v2 .message-model-step[data-status="unchanged"] .message-model-step-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--success);
  line-height: 1;
}

body.ui-version-v2 .message-model-step[data-status="failed"] .message-model-step-status {
  display: inline-block;
  color: var(--error);
  font-size: calc(0.72rem + 1pt);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 6px color-mix(in srgb, var(--error) 20%, transparent);
  -webkit-text-stroke: 0.25px currentColor;
}

body.ui-version-v2 .message-model-step[data-status="timeout"] .message-model-step-status {
  display: inline-block;
  color: var(--error);
  font-size: calc(0.64rem + 1pt);
  font-weight: 700;
  line-height: 1;
}

body.ui-version-v2 .message-model-step[data-status="stopped"] .message-model-step-status,
body.ui-version-v2 .message-model-step[data-status="unconfirmed"] .message-model-step-status {
  display: inline-block;
  color: var(--lime-strong);
  font-size: calc(0.64rem + 1pt);
  font-weight: 700;
  line-height: 1;
}

body.ui-version-v2 .message-model-step[data-status="warning"] .message-model-step-status {
  display: inline-block;
  color: var(--warning);
  font-size: calc(0.64rem + 1pt);
  font-weight: 700;
  line-height: 1;
}

body.ui-version-v2 .message-model-step[data-review-complete="false"]:is([data-status="updated"], [data-status="unchanged"]) :is(.message-model-step-error, .message-model-step-status) {
  color: var(--text-secondary);
}

body.ui-version-v2 .message-model-step-summary > .message-model-step-chevron {
  grid-column: 2;
  grid-row: 1;
}

body.ui-version-v2 .message-model-step[data-open="true"]:not(:has(.message-model-step-role:not([hidden]))) > .message-model-step-summary strong,
body.ui-version-v2 .message-model-step[data-open="true"] > .message-model-step-summary .message-model-step-role:not([hidden]) {
  text-decoration: underline;
  text-decoration-color: var(--lime-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* Expanded evidence is a child of its stage row, not another transcript row. */
body.ui-version-v2 .message-model-step-details,
body.ui-version-v2 .message-model-step > .message-generation-details {
  display: grid;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  gap: 5px;
  margin: 2px 0 5px;
  padding: 4px 9px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink-primary) 3.5%, transparent);
}

body.ui-version-v2 .message-model-step:not([data-open="true"]) > :not(.message-model-step-summary) {
  display: none;
}

body.ui-version-v2 .message-model-step-details[hidden] {
  display: none;
}

/* One header line: tabs on the left, the call's usage ledger on the right. */
body.ui-version-v2 .message-model-step-detail-head {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .message-model-step-detail-head:not(:has(> :not([hidden]))) {
  display: none;
}

body.ui-version-v2 .message-model-step-expanded-accounting {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 0;
  padding: 3px 0 4px;
  color: var(--ink-muted);
  font-size: calc(0.58rem + 1pt);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .message-model-step-expanded-accounting[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step-accounting-value {
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-accounting-missing {
  color: var(--ink-muted);
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-accounting-separator {
  padding: 0 5px;
  color: var(--ink-muted);
  user-select: none;
}

body.ui-version-v2 .message-model-step-tabs {
  display: flex;
  min-width: 0;
  gap: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}

body.ui-version-v2 .message-model-step-tabs::-webkit-scrollbar {
  display: none;
}

body.ui-version-v2 .message-model-step-tabs[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step-tab {
  min-width: 0;
  margin: 0 0 -1px;
  padding: 3px 0 4px;
  flex: 0 0 auto;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  font: inherit;
  font-size: calc(0.62rem + 1pt);
}

body.ui-version-v2 .message-model-step-tab[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step-tab[aria-selected="true"] {
  border-bottom-color: var(--lime-strong);
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-model-step-tab:focus-visible {
  border-radius: 2px;
  outline: 1px solid color-mix(in srgb, var(--lime-strong) 70%, transparent);
  outline-offset: 2px;
}

body.ui-version-v2 .message-model-step-tab-count {
  margin-left: 4px;
  color: var(--ink-muted);
  font-size: calc(0.55rem + 1pt);
}

body.ui-version-v2 .message-model-step-tab-panel {
  min-width: 0;
  max-width: 100%;
  padding-top: 1px;
}

body.ui-version-v2 .message-model-step-tab-panel[hidden] {
  display: none;
}


body.ui-version-v2 .message-prompt-boosts {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding: 9px 0 4px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .message-prompt-boosts[hidden] {
  display: none;
}

body.ui-version-v2 .message-prompt-boosts-heading {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: calc(0.64rem + 1pt);
  font-weight: 650;
}

body.ui-version-v2 .message-prompt-boosts-intro,
body.ui-version-v2 .message-prompt-boosts-omitted {
  color: var(--ink-muted);
  font-size: calc(0.63rem + 1pt);
  line-height: 1.45;
}

body.ui-version-v2 .message-prompt-boosts-list {
  display: grid;
  gap: 2px;
}

body.ui-version-v2 .message-prompt-boost-package {
  min-width: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 7%, transparent);
}

body.ui-version-v2 .message-prompt-boost-package > summary {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  color: var(--ink-secondary);
  cursor: pointer;
  list-style: none;
}

body.ui-version-v2 .message-prompt-boost-package > summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 .message-prompt-boost-package > summary::before {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

body.ui-version-v2 .message-prompt-boost-package > summary strong {
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
  padding-left: 14px;
  overflow: hidden;
  font-size: calc(0.66rem + 1pt);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .message-prompt-boost-package > summary span {
  grid-column: 2;
  color: var(--ink-muted);
  font-size: calc(0.59rem + 1pt);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.ui-version-v2 .message-prompt-boost-rules {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 2px 0 9px 14px;
  list-style: none;
}

body.ui-version-v2 .message-prompt-boost-rules:empty {
  display: none;
}

body.ui-version-v2 .message-prompt-boost-rules li {
  min-width: 0;
  padding-left: 9px;
  border-left: 1px solid color-mix(in srgb, var(--ink-primary) 11%, transparent);
}

body.ui-version-v2 .message-prompt-boost-rules li > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 3px 10px;
  color: var(--ink-secondary);
  font-size: calc(0.62rem + 1pt);
}

body.ui-version-v2 .message-prompt-boost-rule-state {
  color: var(--ink-muted);
  font-weight: 450;
}

body.ui-version-v2 .message-prompt-boost-rule-state[data-state="included"] {
  color: var(--success);
}

body.ui-version-v2 .message-prompt-boost-rule-state[data-state="matched_before_transform"] {
  color: var(--lime-strong);
}

body.ui-version-v2 .message-prompt-boost-rules p {
  color: var(--ink-muted);
  font-size: calc(0.58rem + 1pt);
  line-height: 1.45;
}

body.ui-version-v2 .message-model-step .message-model-step-metadata {
  max-width: 100%;
  margin: 0;
  padding: 6px 8px;
  border-color: color-mix(in srgb, var(--ink-primary) 8%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 38%, transparent);
  color: var(--ink-secondary);
  font-size: calc(0.56rem + 1pt);
  line-height: 1.45;
}

body.ui-version-v2 :is(.message-model-step-technical-key, .message-model-step-technical-missing) {
  color: var(--ink-muted);
}

body.ui-version-v2 .message-model-step-details > * {
  min-width: 0;
  max-width: 100%;
}

body.ui-version-v2 .message-model-step-output[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step-output > span {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: calc(0.58rem + 1pt);
  font-weight: 500;
  line-height: 1.3;
}

body.ui-version-v2 .message-model-step-output pre {
  margin: 0;
  padding: 7px 8px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-canvas) 46%, transparent);
  color: var(--ink-muted);
  font-family: var(--font-mono, monospace);
  font-size: calc(0.61rem + 1pt);
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

body.ui-version-v2 .message-model-step[data-live="true"] .message-model-step-output pre {
  height: calc(6lh + 14px);
  max-height: calc(6lh + 14px);
  overflow: hidden;
}

body.ui-version-v2 .message.assistant .message-thinking[data-live="true"] .message-thinking-body {
  height: 4lh;
  max-height: 4lh;
  overflow: hidden;
}

body.ui-version-v2 .message-streaming .message-flight-indicator {
  display: none;
}

/* Verb first, owner second: "Adds prompt context · local ✓ · Story Memory". */
body.ui-version-v2 .message-model-step:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary :is(.message-model-step-heading, .message-model-step-label) {
  flex: 0 1 auto;
  overflow: hidden;
}

body.ui-version-v2 .message-model-step:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary .message-model-step-heading {
  flex-shrink: 1;
}

body.ui-version-v2 .message-model-step-role {
  min-width: 0;
  flex: 0 1 auto;
  order: 1;
  overflow: hidden;
  color: var(--ink-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-role[hidden] {
  display: none;
}

body.ui-version-v2 .message-model-step:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary .message-model-step-status {
  order: 2;
}

body.ui-version-v2 .message-model-step:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary .message-model-step-label strong {
  flex: 0 1000 auto;
  order: 3;
  color: var(--ink-muted);
  font-weight: 400;
}

body.ui-version-v2 .message-model-step:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary .message-model-step-label strong::before {
  margin-right: 4px;
  content: '·';
}

/* The Character owns the reply; its action names the step on its own. */
body.ui-version-v2 .message-model-step--response:has(> .message-model-step-summary .message-model-step-role:not([hidden])) > .message-model-step-summary .message-model-step-label strong {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body.ui-version-v2 .message-model-step-story-activity {
  margin-top: 0;
  color: var(--text-secondary);
  font-size: calc(0.66rem + 1pt);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-model-step-story-current-label {
  margin: 2px 0 3px;
  color: var(--ink-muted);
  font-size: calc(0.52rem + 1pt);
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* A single attempt needs no "current" qualifier; it is the only check. */
body.ui-version-v2 .message-model-step:has([data-model-step-tab="history"][hidden]) .message-model-step-story-current-label {
  display: none;
}

body.ui-version-v2 .message-model-step-story-attempts {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Attempt header carries its verdict on the same line; the reasoning and
 * proposal disclosures follow as compact rows beneath it. */
body.ui-version-v2 .message-model-step-story-attempt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 8px;
  row-gap: 1px;
  padding: 0;
}

body.ui-version-v2 .message-model-step-story-attempt > * {
  grid-column: 1 / -1;
  min-width: 0;
}

body.ui-version-v2 .message-model-step-story-attempt + .message-model-step-story-attempt {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .message-model-step-story-attempt-name {
  display: block;
  grid-row: 1;
  grid-column: 1;
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: calc(0.64rem + 1pt);
  font-weight: 600;
}

body.ui-version-v2 .message-model-step-story-attempt > .message-model-step-story-attempt-verdict {
  grid-row: 1;
  grid-column: 2;
  margin: 0;
}

body.ui-version-v2 .message-model-step-story-attempt-verdict::before {
  margin-right: 6px;
  color: var(--ink-muted);
  content: '·';
}

body.ui-version-v2 .message.assistant .message-model-step-story-attempt .message-thinking {
  margin: 0;
}

body.ui-version-v2 .message.assistant .message-model-step-story-attempt .message-thinking-toggle {
  width: auto;
  padding: 1px 0;
  font-size: calc(0.62rem + 1pt);
}

body.ui-version-v2 .message.assistant .message-model-step-story-attempt .message-thinking.message-model-step-thinking .message-thinking-toggle + .message-thinking-body {
  width: auto;
  margin: 2px 0 3px;
  padding-left: 8px;
  border-left: 1px solid color-mix(in srgb, var(--ink-primary) 12%, transparent);
  font-size: calc(0.66rem + 1pt);
}

body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal) {
  margin-top: 0;
  color: var(--ink-muted);
}

body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal) > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  cursor: pointer;
  font: 500 calc(0.62rem + 1pt)/1.3 var(--font-v2-display);
  list-style: none;
}

body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal) > summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 :is(.message-model-step-story-evidence, .message-model-step-story-proposal) > summary::after {
  margin-left: 2px;
}

body.ui-version-v2 .message-model-step-story-proposal pre {
  margin-top: 3px;
  padding: 5px 7px;
  font-size: calc(0.56rem + 1pt);
}

body.ui-version-v2 .message-model-step-story-evidence pre {
  margin: 3px 0 0;
  color: var(--ink-muted);
  font-family: var(--font-mono, monospace);
  font-size: calc(0.56rem + 1pt);
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

body.ui-version-v2 .message-model-step-story-attempt-verdict {
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-model-step-story-attempt-verdict[data-tone="success"] {
  color: var(--ink-secondary);
}

body.ui-version-v2 .message-model-step-story-attempt-verdict[data-tone="failed"] {
  color: var(--error);
}

body.ui-version-v2 .message-model-step-story-history {
  color: var(--text-secondary);
  font-size: calc(0.7rem + 1pt);
}

body.ui-version-v2 .message-model-step-story-history ol {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-model-step-story-history li + li {
  margin-top: 4px;
}

body.ui-version-v2 .message-model-step-attempt {
  margin-top: 8px;
  color: var(--ink-secondary);
  font-size: calc(0.7rem + 1pt);
}

body.ui-version-v2 .message-model-step-attempt > summary {
  cursor: pointer;
  list-style: none;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-model-step-attempt > summary::-webkit-details-marker {
  display: none;
}

body.ui-version-v2 .message-model-step-attempt > summary::after {
  margin-left: 4px;
}

/* Settled evidence expands with its disclosure; only live streams are clamped. */
body.ui-version-v2 .message-model-step-attempt-evidence {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-model-step-details p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .message-model-step-error {
  color: var(--error);
}

body.ui-version-v2 .message-model-step[data-status="warning"] .message-model-step-error {
  color: var(--warning);
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .message-flight-indicator > span {
    animation: none;
  }
  body.ui-version-v2 .message-model-step-status-mark,
  body.ui-version-v2 .message-model-step::after,
  body.ui-version-v2 .message-model-turn-mark::before {
    animation: none;
  }

}

body.ui-version-v2 .message.user.turn-copy-clamped .message-text {
  position: relative;
  max-height: var(--turn-copy-max);
  overflow: hidden;
  mask-image: none;
}

body.ui-version-v2 .message.user.turn-copy-expanded .message-text {
  max-height: none;
  overflow: visible;
  mask-image: none;
}

body.ui-version-v2 .turn-copy-toggle {
  margin: 6px 0 0 auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--lime-default);
  font: 600 0.66rem/1.2 var(--font-v2-display);
  cursor: pointer;
}

@media (max-width: 1100px) {
  body.ui-version-v2 .chat-header.v2-character-hero {
    --v2-hero-image-width: clamp(156px, 25%, 210px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(5, auto);
    padding-left: calc(var(--v2-hero-image-width) + clamp(22px, 3.5vw, 38px));
  }

}

@media (max-width: 768px) {
  body.ui-version-v2 .chat-area::before {
    opacity: 0.5;
  }

  body.ui-version-v2 .chat-header.v2-character-hero {
    --v2-hero-image-width: clamp(112px, 31vw, 132px);
    min-height: 0;
    padding: 20px calc(17px + var(--safe-right)) 20px calc(var(--v2-hero-image-width) + 16px + var(--safe-left));
    column-gap: 0;
  }

  body.ui-version-v2 .message {
    padding-top: 13px;
    padding-bottom: 13px;
  }

  body.ui-version-v2 .message.assistant {
    position: relative;
    width: calc(100% - 38px - var(--safe-left) - var(--safe-right));
    padding-right: 0;
    padding-left: 0;
  }

  body.ui-version-v2 .message.user {
    padding-right: 0;
  }

  body.ui-version-v2 .message-model-flow {
    margin-top: 4px;
    font-size: calc(0.61rem - 1px + 1pt);
  }

  body.ui-version-v2 .message-model-turn-summary {
    padding: 1px 0;
  }

  body.ui-version-v2 .message-model-step {
    --step-marker-line: calc(5px + (1lh - 11px) / 2);
    --step-marker-top: var(--step-marker-line);
    font-size: calc(0.61rem - 1px + 1pt);
  }

  body.ui-version-v2 .message-model-step[data-phase-label] {
    --step-marker-top: calc(var(--phase-label-block) + var(--step-marker-line));
  }

  body.ui-version-v2 .message-model-step-summary {
    padding: 5px 0;
  }

  body.ui-version-v2 .message-model-step-metrics {
    gap: 4px;
    font-size: calc(0.58rem - 1px + 1pt);
  }

  body.ui-version-v2 .message-model-step-chevron {
    margin: 0 2px;
  }

  body.ui-version-v2 :is(.message-turn-actions, .message-turn-user-actions) {
    gap: 4px;
  }

  body.ui-version-v2 .message-model-step-retry {
    width: max-content;
    min-width: max-content;
    padding: 2px 8px;
    line-height: 1;
    white-space: nowrap;
  }

  body.ui-version-v2 .message-turn-action-label {
    display: none;
  }

  body.ui-version-v2 .message-turn-action-icon {
    display: block;
    width: 15px;
    height: 15px;
  }

  body.ui-version-v2 .message-turn-actions > .message-action.message-raw-toggle {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
  }

  /* Keep metadata left and the complete response-control cluster right. */
  body.ui-version-v2 .message-turn-footer .message-model-turn-summary {
    flex: 1 1 0;
  }

  body.ui-version-v2 .message-turn-footer > .message-turn-primary {
    order: 2;
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    margin: 0 0 0 auto;
  }
}

/* Compact supporting rails keep the transcript as the focal reading surface. */
body.ui-version-v2 .sidebar-header {
  gap: 8px;
  padding: 12px;
  flex-shrink: 0;
}
body.ui-version-v2 .v2-sidebar-heading {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
}
body.ui-version-v2 .v2-sidebar-open {
  position: relative;
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
}
/* One action pill: Studio's slim Open, Chat's Open, the Library's Create and its details actions share one
 * height, padding and type. The height is the sidebar search field's (set below from the same token), so Open and
 * the search beside it cannot drift apart. */
body.ui-version-v2 {
  --action-pill-height: 34px;
}
body.ui-version-v2 .v2-sidebar-open .open-library-btn,
body.ui-version-v2 .studio #studioOpenSource,
body.ui-version-v2 .studio #studioOpenExisting,
body.ui-version-v2 .v2-asset-library-create,
body.ui-version-v2 .v2-asset-library-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  height: var(--action-pill-height);
  min-height: 0;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-family: var(--font-interface);
  font-size: calc(0.62rem * var(--chat-font-scale, 1));
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
/* Open and Create share the same high-contrast action surface in every header. */
body.ui-version-v2 .v2-sidebar-open .open-library-btn,
body.ui-version-v2 .studio #studioOpenSource,
body.ui-version-v2 .studio #studioOpenExisting,
body.ui-version-v2 .v2-asset-library-create,
body.ui-version-v2 .v2-asset-library-action.is-primary {
  border-color: var(--lime-strong);
  background: var(--lime-strong);
  color: var(--lime-strong-on);
}
body.ui-version-v2 .v2-sidebar-open .open-library-btn:is(:hover, :focus-visible),
body.ui-version-v2 .studio #studioOpenSource:not(:disabled):is(:hover, :focus-visible),
body.ui-version-v2 .studio #studioOpenExisting:not(:disabled):is(:hover, :focus-visible),
body.ui-version-v2 .v2-asset-library-create:is(:hover, :focus-visible),
body.ui-version-v2 .v2-asset-library-action.is-primary:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--lime-strong) 86%, var(--ink-primary));
  color: var(--lime-strong-on);
}
body.ui-version-v2 .studio #studioOpenSource > .disclosure-caret,
body.ui-version-v2 .v2-asset-library-create > .disclosure-caret {
  margin: 0;
  color: currentColor;
}
body.ui-version-v2 .v2-chat-view-control {
  position: relative;
  flex: 0 0 auto;
}
/* Fold and order ride on the list's first group header: a zero-height anchor
 * placed before that group, with the buttons overlaid on the header's right end. */
body.ui-version-v2 .v2-chat-list-tools {
  position: relative;
  height: 0;
}
body.ui-version-v2 .v2-chat-list-tools-row {
  position: absolute;
  top: -1px;
  right: 2px;
  display: flex;
  align-items: center;
  gap: 1px;
}
body.ui-version-v2 :is(.v2-chat-view-button, .v2-chat-fold-button) {
  display: grid;
  width: 24px;
  height: 24px;
  min-height: 0;
  flex: 0 0 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}
body.ui-version-v2 :is(.v2-chat-view-button, .v2-chat-fold-button)[hidden] {
  display: none;
}
body.ui-version-v2 :is(.v2-chat-view-button, .v2-chat-fold-button):is(:hover, :focus-visible, [aria-expanded="true"]) {
  background: color-mix(in srgb, var(--ink-primary) 8%, transparent);
  color: var(--ink-secondary);
}
body.ui-version-v2 :is(.v2-chat-view-button, .v2-chat-fold-button) svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
body.ui-version-v2 .v2-chat-view-button svg {
  stroke-width: 1.6;
}
body.ui-version-v2 .v2-chat-fold-button svg {
  stroke-width: 1.9;
}
body.ui-version-v2 .v2-chat-view-menu button span {
  color: inherit;
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}
body.ui-version-v2 .v2-chat-view-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 72;
  width: min(216px, calc(var(--sidebar-width) - 24px), calc(100vw - 16px));
}
body.ui-version-v2 .v2-chat-view-menu strong {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--lime-strong);
  font-size: 0.66rem;
  font-weight: 600;
}
body.ui-version-v2 .v2-chat-search {
  height: var(--action-pill-height);
  min-height: 0;
  min-width: 0;
  flex: 1;
}
body.ui-version-v2 .chat-list {
  min-height: 0;
  padding: 6px 8px 12px;
}
/* Group folds carry their own scroll anchoring, so the browser must not also
 * re-anchor the list and undo it. */
body.ui-version-v2 #chatList {
  overflow-anchor: none;
}
/* Chat and Assistant history reveal one bounded page at a time with the same
 * centered, content-sized control. The list IDs make this shared chrome win
 * over each independently themed surface's generic button typography; colour
 * still follows that surface's accessible palette. */
body.ui-version-v2 :is(#chatList, #studioThreadList) > .list-load-more {
  display: block;
  width: max-content;
  max-width: calc(100% - 16px);
  min-height: 24px;
  margin: 8px auto 4px;
  padding: 3px 11px;
  border: 1px solid color-mix(in srgb, var(--ink-secondary) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-primary) 6%, transparent);
  color: var(--ink-secondary);
  cursor: pointer;
  font: 650 0.62rem/1.2 var(--font-interface);
}
body.ui-version-v2 :is(#chatList, #studioThreadList) > .list-load-more:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--lime-strong) 45%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 10%, transparent);
  color: var(--ink-primary);
  outline: none;
}
body.ui-version-v2 :is(#chatList, #studioThreadList) > .list-load-more:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
}
body.ui-version-v2 :is(#chatList, #studioThreadList) > .list-load-more:disabled {
  cursor: wait;
  opacity: 0.65;
}
body.ui-version-v2 .chat-group {
  margin: 0;
}
body.ui-version-v2 .chat-group + .chat-group {
  margin-top: 3px;
}
body.ui-version-v2 .chat-group[hidden] {
  display: none;
}
body.ui-version-v2 .chat-group-summary {
  display: flex;
  min-height: 22px;
  align-items: center;
  gap: 6px;
  padding: 3px 7px 2px;
  border-radius: 3px;
  color: var(--ink-muted);
  font-family: var(--font-v2-display);
  font-size: 0.61rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0.02em;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
body.ui-version-v2 .chat-group-summary::-webkit-details-marker {
  display: none;
}
body.ui-version-v2 .chat-group-summary::before {
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  content: "";
  transform: rotate(45deg) translate(-1px, -1px);
  transform-origin: center;
}
body.ui-version-v2 .chat-group:not([open]) > .chat-group-summary::before {
  transform: rotate(-45deg);
}
body.ui-version-v2 .chat-group-summary:hover,
body.ui-version-v2 .chat-group-summary:focus-visible {
  background: color-mix(in srgb, var(--ink-primary) 4%, transparent);
  color: var(--ink-secondary);
  outline: none;
}
body.ui-version-v2 .chat-item {
  align-items: center;
  min-height: 34px;
  gap: 5px;
  margin: 1px 0;
  padding: 4px 5px 4px 12px;
  background: transparent;
}
body.ui-version-v2 .chat-item.active {
  background: color-mix(in srgb, var(--lime-strong) 7.5%, transparent);
}
@media (hover: hover) {
  body.ui-version-v2 .chat-item:hover:not(.active) { background: color-mix(in srgb, var(--ink-primary) 3.5%, transparent); }
}
body.ui-version-v2 .chat-item .v2-chat-portrait { display: none; }
body.ui-version-v2 .chat-item-content { padding-top: 0; }
body.ui-version-v2 .chat-item-title { font-size: 0.76rem; }
body.ui-version-v2 .chat-item-subtitle { display: none; }
body.ui-version-v2 .chat-item-meta {
  margin-top: 1px;
}
body.ui-version-v2 .chat-item-date { margin-left: 0; font-size: 0.59rem; }
body.ui-version-v2 .chat-item-generation {
  position: static;
  min-width: 20px;
  flex-basis: 20px;
  transform: none;
}
body.ui-version-v2 .chat-item-menu-button { color: var(--ink-muted); }
body.ui-version-v2 .chat-item-menu {
  border-color: color-mix(in srgb, var(--lime-strong) 22%, transparent);
  background: var(--surface-default);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.46);
}
body.ui-version-v2 .chat-item.chat-item-ungrouped {
  min-height: 44px;
  gap: 6px;
  margin: 1px 0;
  padding: 4px 5px 4px 4px;
  border: 1px solid transparent;
}
body.ui-version-v2 .chat-item.chat-item-ungrouped.active {
  border-color: color-mix(in srgb, var(--lime-strong) 16%, transparent);
  box-shadow: inset 2px 0 0 var(--accent-primary);
}
body.ui-version-v2 .chat-item-portrait {
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: color-mix(in srgb, var(--lime-strong) 7%, transparent);
  color: var(--lime-strong);
  font-family: var(--font-v2-display);
}
body.ui-version-v2 .chat-item-portrait img {
  border-radius: inherit;
}
body.ui-version-v2 a.chat-item {
  color: inherit;
  text-decoration: none;
}
body.ui-version-v2 .chat-item-character {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
}
/* A row's first line, in the sidebar and in Library alike: kind glyph, name, then one trailing mark. */
body.ui-version-v2 .chat-item-character .prompt-kind-icon,
body.ui-version-v2 .v2-asset-library-titleline > .v2-asset-library-kind-icon {
  width: 13px;
  height: 13px;
  color: var(--prompt-kind-icon-tone);
  transform: translateY(-1px);
}
body.ui-version-v2 .chat-item-character .prompt-kind-icon[data-prompt-kind="general"],
body.ui-version-v2 .v2-asset-library-titleline > .v2-asset-library-kind-icon[data-prompt-kind="general"] {
  width: 14px;
  height: 14px;
}
/* The mark says what mode a session runs in (Preview) or what is unfinished about an asset (Draft,
 * Needs review). It is one chip; only the tone tells the two axes apart. */
body.ui-version-v2 .row-mark {
  --mark: var(--lime-default);
  display: inline-block;
  flex: none;
  padding: 1px 4px;
  border: 1px solid color-mix(in srgb, var(--mark) 46%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--mark) 10%, transparent);
  color: var(--mark);
  font: 700 0.55rem/1.4 var(--font-interface);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
body.ui-version-v2 .row-mark:is([data-mark="draft"], [data-mark="issue"]) {
  --mark: color-mix(in srgb, var(--activity-live) 62%, var(--ink-primary));
}
body.ui-version-v2 .chat-item-character > .row-mark {
  margin-left: 3px;
}
body.ui-version-v2 .chat-item-ungrouped-copy .chat-item-title {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.67rem;
}
body.ui-version-v2 .chat-item-plain .chat-item-title {
  white-space: normal;
  overflow-wrap: anywhere;
}
body.ui-version-v2 .chat-item-relative-time {
  color: var(--ink-muted);
  font-size: 0.56rem;
}
/* Mobile conversation list text is one point larger than desktop; layout is unchanged. */
@media (max-width: 768px) {
  body.ui-version-v2 #chatList .chat-group-summary { font-size: calc(0.61rem + 1pt); }
  body.ui-version-v2 :is(#chatList,#studioRecentEdits) .chat-item-character { font-size: calc(0.72rem + 1pt); }
  body.ui-version-v2 :is(#chatList,#studioRecentEdits) .chat-item-ungrouped-copy .chat-item-title { font-size: calc(0.67rem + 1pt); }
  body.ui-version-v2 :is(#chatList,#studioRecentEdits) .chat-item-relative-time { font-size: calc(0.56rem + 1pt); }
}
body.ui-version-v2 .chat-item > .busy-indicator {
  min-height: 24px;
  color: var(--ink-secondary);
  font-size: 0.56rem;
  white-space: nowrap;
}
body.ui-version-v2 .v2-memory-sidebar { padding-top: 0; padding-bottom: 14px; }
body.ui-version-v2 .v2-memory-rail-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
}
body.ui-version-v2 .v2-memory-rail-toggle:hover,
body.ui-version-v2 .v2-memory-rail-toggle:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 38%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
  color: var(--lime-default);
}
body.ui-version-v2 .v2-memory-rail-toggle svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 769px) {
  /* One track width owns the open and closed column, so the negative margin
   * releases exactly the space the panel occupies. The panel keeps that width
   * while it slides out of the clipped layout; only `transform` transitions. */
  body.ui-version-v2 .main-layout > .v2-memory-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--v2-memory-track);
    min-width: var(--v2-memory-track);
    padding: 0;
    overflow: hidden;
    transition: transform var(--transition-normal), visibility 0s linear 0s;
  }
  body.ui-version-v2 .main-layout > .v2-memory-sidebar.collapsed,
  body.ui-version-v2 .main-layout.v2-rail-exiting > .v2-memory-sidebar {
    margin-left: calc(var(--v2-memory-track) * -1);
    padding: 0;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--transition-normal), visibility 0s linear 200ms;
  }
}

body.ui-version-v2 .v2-memory-label { margin-bottom: 4px; }

/* On desktop the compact character state becomes part of the single app bar. */
@container (max-width: 760px) {
  body.ui-version-v2 .chat-header.v2-character-hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(5, auto);
  }
}


@media (min-width: 1024px) {
  body.ui-version-v2 .top-bar-inner {
    position: relative;
    display: flex;
    gap: 8px;
    padding-right: 8px;
    padding-left: 8px;
  }

  body.ui-version-v2 .top-bar-left {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow: visible;
  }

  body.ui-version-v2 .top-bar-right {
    flex: 0 0 auto;
    height: 100%;
    justify-content: flex-end;
  }

  body.ui-version-v2 .top-bar-left .app-title {
    min-width: 0;
    flex-wrap: nowrap;
  }

  body.ui-version-v2 .app-title-text {
    font-size: 1.0625rem;
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated {
    position: absolute;
    left: max(160px, var(--v2-header-left, var(--sidebar-width)));
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 0 10px 0 14px;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    transform: none;
  }

  body.ui-version-v2.v2-sticky-visible .top-bar-inner > .v2-sticky-header-integrated {
    position: static;
    right: auto;
    left: auto;
    grid-column: 2;
    transform: none;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-inner {
    display: grid;
    grid-template-columns: calc(max(160px, var(--v2-header-left, var(--sidebar-width))) - 8px) minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-left {
    grid-column: 1;
    overflow: hidden;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-right {
    grid-column: 3;
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated .v2-sticky-portrait {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    box-shadow: 2px 2px 0 var(--portrait-offset);
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated .v2-sticky-character {
    gap: 8px;
  }

  body.ui-version-v2.v2-sticky-visible #chatTitleText {
    display: none;
  }
}

/* Phones: the open conversations drawer covers the canvas, so it owns the fixed header, as Studio's drawers
 * do. The header names the drawer and drops the conversation's identity and the right-panel toggle, which
 * would open a second panel over the first. The Sandcat icon stays and closes the drawer. */
body.ui-version-v2 .app-drawer-title { display: none; }
@media (max-width: 768px) {
  body.ui-version-v2:has(#sidebar.open) .top-bar :is(#appTitleText, #helpTitleText, .shell-opening-title, .v2-sticky-header, #appHeaderActions) { display: none !important; }
  body.ui-version-v2:has(#sidebar.open) .app-drawer-title {
    display: block;
    color: var(--ink-primary);
    font: 600 .95rem/1.2 var(--font-v2-display);
    white-space: nowrap;
  }
}

body.ui-version-v2.v2-character-browser-open {
  overflow: hidden;
}

body.ui-version-v2.v2-asset-library-open {
  overflow: hidden;
}

body.ui-version-v2 .v2-asset-library {
  /* Accent text on the accent's own tint, mixed a little toward the ink so every accent keeps 4.5:1. */
  --library-accent-ink: color-mix(in srgb, var(--accent-primary) 78%, var(--ink-primary));
  padding: 24px;
  overflow: hidden;
}

body.ui-version-v2 .v2-asset-library-shell {
  position: relative;
  width: min(980px, 100%);
  height: min(760px, calc(100dvh - 48px));
  max-width: 980px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  transform: none;
}

body.ui-version-v2 .v2-asset-library-header {
  gap: 10px;
}

body.ui-version-v2 .v2-asset-library-header h2 {
  min-width: 0;
  flex: 1;
  margin: 0;
  color: var(--ink-primary);
  font: 600 1rem/1.2 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-create-menu {
  position: fixed;
  inset: auto;
  z-index: 4;
  width: 260px;
  margin: 0;
}

/* Sections stay on the left while the right side switches between the index and one asset's detail page. */
body.ui-version-v2 .v2-asset-library-body {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: 200px minmax(0, 1fr);
}

body.ui-version-v2 .v2-asset-library-rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-library-rail :is([data-library-filter], .v2-asset-library-browse) {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-secondary);
  font: 600 0.78rem/1 var(--font-interface);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-rail [data-library-filter][hidden] {
  display: none;
}

body.ui-version-v2 .v2-asset-library-rail [data-library-filter] b {
  color: var(--ink-muted);
  font: 600 0.66rem/1 var(--font-interface);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-asset-library-rail :is([data-library-filter], .v2-asset-library-browse):is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 6%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-asset-library-rail [data-library-filter][aria-pressed="true"] {
  background: var(--accent-muted);
  color: var(--accent-primary);
}

body.ui-version-v2 .v2-asset-library-rail [data-library-filter][aria-pressed="true"] b {
  color: inherit;
}

/* All comes first; narrower sections keep tone-coloured group titles and rules. The phone dropdown mirrors this order. */
body.ui-version-v2 :is(.v2-asset-library-group, .v2-asset-library-section-menu [data-group]) {
  --group-tone: var(--library-accent-ink);
}

body.ui-version-v2 .v2-asset-library-group {
  display: grid;
  gap: 2px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* Nothing sits above the first group now, so it needs no rule or gap. */
body.ui-version-v2 .v2-asset-library-group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

body.ui-version-v2 :is(.v2-asset-library-group, .v2-asset-library-section-menu [data-group])[data-group="addons"] {
  --group-tone: color-mix(in srgb, var(--activity-live) 62%, var(--ink-primary));
}

body.ui-version-v2 .v2-asset-library-group[hidden] {
  display: none;
}

/* External discovery and Create stay separate from the owned-asset filters. */
body.ui-version-v2 :is(.v2-asset-library-browse, .v2-asset-library-create-group .v2-asset-library-create) {
  width: 100%;
}

body.ui-version-v2 .v2-asset-library-browse {
  justify-content: flex-start;
}

body.ui-version-v2 .v2-asset-library-browse img {
  width: 16px;
  height: 16px;
  flex: none;
}

body.ui-version-v2 .v2-asset-library-group-heading {
  display: grid;
  gap: 3px;
  padding: 2px 10px 6px;
}

body.ui-version-v2 .v2-asset-library-group-heading strong {
  color: var(--group-tone);
  font: 750 0.72rem/1.2 var(--font-interface);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-asset-library-group-heading small {
  color: var(--ink-secondary);
  font: 500 0.64rem/1.3 var(--font-interface);
  letter-spacing: 0;
  text-transform: none;
}

/* Phones swap the rail for one dropdown beside the title. */
body.ui-version-v2 .v2-asset-library-section-picker {
  display: none;
}

/* The phone section trigger wears the rail's selected-section colour, so it reads as the current place. */
body.ui-version-v2 .v2-asset-library-section-trigger {
  display: flex;
  max-width: 100%;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 2px 9px 2px 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent-muted);
  color: var(--accent-primary);
  font: 650 calc(0.8rem + 1pt)/1.15 var(--font-interface);
  white-space: nowrap;
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-section-trigger:is(:hover, :focus-visible, [aria-expanded="true"]) {
  border-color: color-mix(in srgb, var(--accent-primary) 45%, transparent);
}

body.ui-version-v2 :is(.v2-asset-library-section-trigger, .v2-asset-library-section-menu) b {
  color: var(--ink-muted);
  font: 600 0.66rem/1 var(--font-interface);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-asset-library-section-trigger b {
  color: inherit;
  font-size: calc(0.66rem + 1pt);
}

body.ui-version-v2 .v2-asset-library-section-menu {
  position: fixed;
  inset: auto;
  width: min(220px, calc(100vw - 16px));
  margin: 0;
}

body.ui-version-v2 .v2-asset-library-section-menu .sandcat-menu-heading {
  color: var(--group-tone);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-asset-library-section-menu .sandcat-menu-heading small {
  display: block;
  margin-top: 1px;
  color: var(--ink-secondary);
  font: 500 0.62rem/1.3 var(--font-interface);
  letter-spacing: 0;
  text-transform: none;
}

body.ui-version-v2 .v2-asset-library-section-menu b {
  margin-left: auto;
}

body.ui-version-v2 .v2-asset-library-section-menu [data-group="all"] {
  margin-bottom: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-library-section-menu [data-group="addons"] {
  margin-top: 4px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Create is the same lime pill as the rail's Create, full width at the menu's end. */
body.ui-version-v2 .v2-asset-library-section-menu .sandcat-menu-item.v2-asset-library-section-create {
  justify-content: center;
  min-height: var(--action-pill-height);
  margin-top: 6px;
  border-radius: 4px;
  background: var(--lime-strong);
  color: var(--lime-strong-on);
  font: 650 calc(0.62rem * var(--chat-font-scale, 1))/1 var(--font-interface);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-asset-library-section-menu .sandcat-menu-item.v2-asset-library-section-create:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--lime-strong) 86%, var(--ink-primary));
  color: var(--lime-strong-on);
}

/* The main column is a size container: the asset page stacks its poster above the text when the column is narrow
 * (tablets and phones), whatever the viewport. */
body.ui-version-v2 .v2-asset-library-main {
  --busy-surface: var(--bg-elevated);
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  container: asset-library-main / inline-size;
}

body.ui-version-v2 .v2-asset-library-index {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

body.ui-version-v2 .v2-asset-library-index[hidden] {
  display: none;
}

body.ui-version-v2 .v2-asset-library-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-library-tools label {
  display: flex;
  min-width: 0;
  min-height: 34px;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  color: var(--ink-muted);
  background: var(--surface-default);
}

body.ui-version-v2 .v2-asset-library-tools input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-primary);
  font: 500 0.78rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-views {
  display: flex;
  gap: 2px;
}

/* Filtering and ordering share one explicit menu. The trigger names both current
 * choices, so changing one never makes the other state disappear. */
body.ui-version-v2 .v2-asset-library-organize {
  position: relative;
  flex: none;
}

body.ui-version-v2 .v2-asset-library-organize-trigger {
  display: flex;
  width: 222px;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  background: var(--surface-default);
  color: var(--ink-secondary);
  font: 500 0.73rem/1.15 var(--font-interface);
  text-align: left;
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-organize-trigger [data-library-organize-label] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-library-organize[data-active="true"] .v2-asset-library-organize-trigger {
  border-color: var(--accent-primary);
  background: var(--accent-muted);
  color: var(--library-accent-ink);
}

/* Phones show an icon instead of the summary; the summary stays the trigger's accessible name. */
body.ui-version-v2 .v2-asset-library-organize-icon {
  display: none;
}

body.ui-version-v2 .v2-asset-library-organize-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

body.ui-version-v2 .v2-asset-library-organize-menu {
  position: fixed;
  width: min(226px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
}

body.ui-version-v2 .v2-asset-library-organize-menu:popover-open,
body.ui-version-v2 .v2-asset-library-organize-group {
  display: grid;
}

body.ui-version-v2 .v2-asset-library-organize-menu .sandcat-menu-item {
  min-height: 32px;
  font-size: 0.75rem;
}

body.ui-version-v2 .v2-asset-library-organize-subheading {
  padding-top: 9px;
}

body.ui-version-v2 .v2-asset-library-organize-sort {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border-subtle);
}

/* View sits beside search on desktop and, on phones, as one row at the end of this menu. */
body.ui-version-v2 .v2-asset-library-organize-group.v2-asset-library-organize-view {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-top: 5px;
  padding: 5px 4px 0 0;
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-library-organize-view .v2-asset-library-views button {
  width: 40px;
  min-height: 40px;
}

body.ui-version-v2 .v2-asset-library-organize-menu .sandcat-menu-item[aria-checked="true"]::after {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-left: auto;
  background: currentColor;
  content: "";
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
}

body.ui-version-v2 .v2-asset-library-views button {
  width: 34px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 1rem;
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-views button:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 6%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-asset-library-views button:is([aria-pressed="true"], [aria-checked="true"]) {
  background: var(--accent-muted);
  color: var(--accent-primary);
}

body.ui-version-v2 .v2-asset-library-views button {
  display: grid;
  place-items: center;
}

body.ui-version-v2 .v2-asset-library-views svg {
  display: block;
  width: 20px;
  height: 20px;
}

body.ui-version-v2 .v2-asset-library-results {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 1px;
  padding: 6px 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

/* DataCat card size: about 240px wide, three across in the desktop Library, two on narrower columns. */
body.ui-version-v2 .v2-asset-library-results[data-view="grid"] {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-items: start;
  gap: 16px;
  padding: 14px;
}

/* A row is the conversation list's row: no container, the hover alone sets it apart. */
body.ui-version-v2 .v2-asset-library-item {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  border-radius: 6px;
}

body.ui-version-v2 .v2-asset-library-item:is(:hover, :focus-within) {
  background: color-mix(in srgb, var(--ink-primary) 4%, transparent);
}

body.ui-version-v2 .v2-asset-library-open {
  display: flex;
  min-width: 0;
  min-height: 44px;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-action-control {
  display: flex;
  position: relative;
}

body.ui-version-v2 .v2-asset-library-chip {
  display: grid;
  width: var(--library-chip-hit);
  height: var(--library-chip-hit);
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-chip.v2-asset-library-menu-trigger {
  width: var(--library-more-width);
}

body.ui-version-v2 .v2-asset-library-chip:is(:hover, :focus-visible, [aria-expanded="true"]) {
  background: color-mix(in srgb, var(--ink-primary) 7%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-asset-library-chip:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

/* A row's menu and the details bar's ⋯ share one surface; a long conversations page scrolls inside it. */
body.ui-version-v2 .v2-asset-library-action-menu {
  position: fixed;
  inset: auto;
  width: min(264px, calc(100vw - 16px));
  max-height: min(440px, calc(100dvh - 16px));
  overflow-y: auto;
  z-index: 160;
}

body.ui-version-v2 .v2-asset-library-action-menu .sandcat-menu-heading {
  display: block;
}

/* A destructive row keeps its own colour for its icon too. */
body.ui-version-v2 .v2-asset-library-action-menu .sandcat-menu-item.is-danger svg {
  color: currentColor;
}

/* A built-in's Delete stays in place but reads as unavailable, not dangerous. */
body.ui-version-v2 .v2-asset-library-action-menu .sandcat-menu-item.is-danger:disabled {
  color: var(--ink-muted);
}

/* The conversations page: each conversation under way, then when it last moved. */
body.ui-version-v2 .v2-asset-library-chat-option .sandcat-menu-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-library-chat-time {
  flex: none;
  color: var(--ink-muted);
  font: 500 0.72rem/1.2 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-action-icon {
  display: grid;
  place-items: center;
}

body.ui-version-v2 .v2-asset-library-action-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

body.ui-version-v2 .v2-asset-library-menu-trigger .v2-asset-library-action-icon svg {
  width: 22px;
  height: 22px;
}

/* Grid view is DataCat's card: a 3 / 4 poster with 12px corners carrying only its marks, then two text lines — the
 * name, and the kind with ⋯ at its right. Every card is the same height. */
body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-item {
  display: block;
  border-radius: 12px;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-item:is(:hover, :focus-within) {
  background: transparent;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-open {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border-radius: 12px;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-open:focus-visible {
  outline: 2px solid var(--lime-default);
  outline-offset: 2px;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-item .v2-asset-library-visual {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 12px;
  background: var(--surface-muted);
  font-size: 2.6rem;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-visual img {
  object-position: top center;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-visual svg {
  width: 34%;
}


body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-copy {
  gap: 0;
  padding: 6px 8px 8px;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-copy strong {
  margin-bottom: 2px;
  font: 500 0.8125rem/1.3 var(--font-interface);
}

/* A card's second line is the kind, as a row's is. */
body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-copy small {
  display: flex;
  align-items: center;
  color: var(--ink-muted);
  font: 500 0.6875rem/1.2 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-visual {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 7px;
  background: var(--bg-elevated);
  color: var(--accent-primary);
  font: 700 1rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-item .v2-asset-library-visual {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  font-size: 0.85rem;
}

body.ui-version-v2 .v2-asset-library-visual :is(img, svg) {
  width: 100%;
  height: 100%;
}

body.ui-version-v2 .v2-asset-library-visual img {
  object-fit: cover;
}

body.ui-version-v2 .v2-asset-library-visual svg {
  width: 54%;
}

body.ui-version-v2 .v2-asset-library-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

body.ui-version-v2 .v2-asset-library-copy :is(strong, small) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-library-copy strong {
  color: var(--ink-primary);
  font: 650 0.8rem/1.25 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-copy small {
  color: var(--ink-muted);
  font: 500 0.66rem/1.3 var(--font-interface);
}

/* Line 2 in a row and on the asset page: the type word, a row's source and mark, then the one detail, which alone
 * may shorten. */
body.ui-version-v2 .v2-asset-library-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

body.ui-version-v2 .v2-asset-library-meta .v2-asset-badge-icon {
  width: 14px;
  height: 14px;
}

/* The type word under the name. The asset page, which has no row glyph, keeps the glyph beside it. */
body.ui-version-v2 .v2-asset-library-kind {
  display: inline-flex;
  min-width: 0;
  flex: none;
  align-items: center;
  gap: 3px;
  color: var(--ink-muted);
  font-size: 0.58rem;
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-library-kind[data-prompt-kind] {
  color: var(--prompt-kind-tone);
}

body.ui-version-v2 .v2-asset-library-kind-icon {
  display: block;
  width: 12px;
  height: 12px;
  flex: none;
  color: currentColor;
}

/* The detail heading's second line: the kind under the title. */
body.ui-version-v2 .v2-asset-page-heading small.v2-asset-library-meta {
  color: var(--ink-secondary);
  font: 500 0.8125rem/1.3 var(--font-interface);
}

body.ui-version-v2 .v2-asset-library-note {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-badge {
  --badge: var(--ink-muted);
  flex: none;
  padding: 1px 5px 0;
  border: 1px solid color-mix(in srgb, var(--badge) 40%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--badge) 10%, transparent);
  color: var(--badge);
  font: 700 0.58rem/1.5 var(--font-interface);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-badge[data-badge="builtin"] {
  --badge: var(--ink-secondary);
}

/* DataCat is its favicon, not its name, so there is no chip frame around it; "Edited" follows it a little smaller and
 * plain. The pixel-art cat is drawn crisp and keeps the favicon's own white ground, which holds its outline on dark. */
body.ui-version-v2 .v2-asset-badge[data-badge="datacat"] {
  --badge: var(--library-accent-ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
}

body.ui-version-v2 .v2-asset-badge-icon {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 2px;
  image-rendering: pixelated;
}

body.ui-version-v2 .v2-asset-badge-note {
  font-size: 0.52rem;
  font-weight: 500;
}

/* The name behind its kind glyph; on the asset page the source badge and the mark follow it. */
body.ui-version-v2 .v2-asset-library-titleline {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

body.ui-version-v2 .v2-asset-library-titleline > :is(strong, h3) {
  min-width: 0;
}

/* The glyph sits as close to the name as it does on a session row. */
body.ui-version-v2 .v2-asset-library-titleline > .v2-asset-library-kind-icon {
  margin-right: -3px;
}

/* The grid uses the duplicate presentation badge on the picture instead of spending a text row below it. */
body.ui-version-v2 .v2-asset-library-picture > .v2-asset-library-picture-source {
  display: none;
}

/* On a card the picture carries the source and Draft, so line 2 drops them. */
body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-meta > :is(.v2-asset-badge, .row-mark[data-mark="draft"]) {
  display: none;
}

/* On a card the source is DataCat's translucent pill in the poster's top right, where DataCat puts its date. */
body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-picture > .v2-asset-library-picture-source {
  position: absolute;
  z-index: 1;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.56);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.88);
  font: 500 calc(9px + 0.5pt)/1.35 var(--font-interface);
  letter-spacing: 0.01em;
  text-transform: none;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-library-picture-source[data-badge="datacat"] {
  padding: 2px 6px 2px 3px;
}

body.ui-version-v2 .v2-asset-library-picture-source .v2-asset-badge-icon {
  width: 14px;
  height: 14px;
}

body.ui-version-v2 .v2-asset-library-picture-source .v2-asset-badge-note {
  font-size: inherit;
}

/* A card's picture carries Draft at top left and source provenance at top right. */
body.ui-version-v2 .v2-asset-library-picture {
  position: relative;
  display: block;
  flex: none;
}

/* A list row marks Draft on line 2. Only a card puts it on the picture: small, and solid amber so it reads
 * over any artwork. */
body.ui-version-v2 .v2-asset-state {
  display: none;
}

body.ui-version-v2 .v2-asset-library-results[data-view="grid"] .v2-asset-state {
  position: absolute;
  top: 8px;
  left: 8px;
  display: block;
  padding: 2px 4px 1px;
  border-radius: 3px;
  background: var(--activity-live);
  box-shadow: 0 0 0 1px rgba(8, 12, 8, 0.55);
  color: #10130d;
  font: 800 0.5rem/1 var(--font-interface);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-library-status {
  margin: 0;
  padding: 6px 14px 10px;
  color: var(--ink-muted);
  font: 500 0.68rem/1.3 var(--font-interface);
}

/* The asset page follows DataCat's character view inside Library's main column: a header (back, title, edit), a body
 * with the poster beside a scrolling text column, and a bottom action bar. Header and bar sit outside the loader. */
body.ui-version-v2 .v2-asset-library-detail {
  display: grid;
  min-width: 0;
  min-height: 0;
  flex: 1;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg-elevated);
}

body.ui-version-v2 .v2-asset-library-detail[hidden] {
  display: none;
}

body.ui-version-v2 .v2-asset-page-header {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-default);
}

/* A bare round chevron, as DataCat's close is bare; its hit area extends to 44px. */
body.ui-version-v2 .v2-asset-library-detail-back {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-primary);
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-library-detail-back::after {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  content: '';
}

body.ui-version-v2 .v2-asset-library-detail-back svg {
  width: 22px;
  height: 22px;
}

body.ui-version-v2 .v2-asset-library-detail-back:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 8%, transparent);
}

body.ui-version-v2 .v2-asset-library-detail-back:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

body.ui-version-v2 .v2-asset-page-heading {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

body.ui-version-v2 .v2-asset-page-heading h3 {
  margin: 0;
  overflow: hidden;
  color: var(--ink-primary);
  font: 700 1.25rem/1.2 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.ui-version-v2 .v2-asset-page-body {
  --busy-surface: var(--bg-elevated);
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: clamp(220px, 40%, 330px) minmax(0, 1fr);
  overflow: hidden;
}

body.ui-version-v2 .v2-asset-page-body.has-no-art {
  grid-template-columns: minmax(0, 1fr);
}

body.ui-version-v2 .v2-asset-page-poster {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-muted);
}

body.ui-version-v2 .v2-asset-page-poster[hidden] {
  display: none;
}

body.ui-version-v2 .v2-asset-page-poster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

body.ui-version-v2 .v2-asset-page-info {
  min-width: 0;
  min-height: 0;
  padding: 16px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Without art the text spans the page at a readable measure. */
body.ui-version-v2 .v2-asset-page-body.has-no-art .v2-asset-page-info > * {
  max-width: 680px;
}

body.ui-version-v2 .v2-asset-page-info > p.v2-asset-library-detail-lead {
  margin: 0 0 10px;
  color: var(--ink-primary);
  font: 600 0.875rem/1.5 var(--font-interface);
}

body.ui-version-v2 .v2-asset-page-info > p.v2-asset-library-detail-lead[hidden] {
  display: none;
}

/* The description is limited HTML, rendered as the chat header's author description is. The header clamps it; the
 * asset page shows it whole and scrolls. */
body.ui-version-v2 .v2-asset-library-detail-description {
  color: var(--ink-primary);
  font-size: calc(0.8125rem + 0.5pt);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .v2-asset-library-detail-description .v2-character-description-content {
  max-height: none;
  overflow: visible;
}

body.ui-version-v2 .v2-asset-page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

body.ui-version-v2 .v2-asset-page-tags:empty {
  display: none;
}

body.ui-version-v2 .v2-asset-page-tags span {
  max-width: 14rem;
  overflow: hidden;
  padding: 3px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font: 500 0.6875rem/1.3 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Facts are DataCat's provenance rows: label and value on hairline-separated rows. */
body.ui-version-v2 .v2-asset-page-facts {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(0, 2fr);
  margin: 16px 0 0;
  font: 0.75rem/1.45 var(--font-interface);
}

body.ui-version-v2 .v2-asset-page-facts:empty {
  display: none;
}

body.ui-version-v2 .v2-asset-page-facts :is(dt, dd) {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-page-facts dt {
  padding-right: 12px;
  color: var(--ink-muted);
}

body.ui-version-v2 .v2-asset-page-facts dd {
  color: var(--ink-primary);
  overflow-wrap: anywhere;
}

body.ui-version-v2 .v2-asset-versions {
  margin-top: 22px;
}

body.ui-version-v2 .v2-asset-versions[hidden] {
  display: none;
}

body.ui-version-v2 .v2-asset-versions h4 {
  margin: 0 0 6px;
  color: var(--ink-primary);
  font: 650 0.82rem/1.4 var(--font-interface);
}

body.ui-version-v2 .v2-asset-version-list {
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-version {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-asset-version > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--ink-secondary);
  font: 0.72rem/1.4 var(--font-interface);
}

body.ui-version-v2 .v2-asset-version > header strong {
  color: var(--ink-primary);
  font-weight: 650;
}

body.ui-version-v2 .v2-asset-version-copy {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.ui-version-v2 .v2-asset-version-copy.is-nested {
  padding: 8px 0 0 12px;
}

body.ui-version-v2 .v2-asset-version-copy-text {
  display: grid;
  min-width: 0;
  gap: 2px;
  color: var(--ink-muted);
  font: 0.69rem/1.4 var(--font-interface);
}

body.ui-version-v2 .v2-asset-version-copy-text strong {
  overflow: hidden;
  color: var(--ink-primary);
  font: 600 0.75rem/1.35 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-asset-version-copy-text .row-mark {
  vertical-align: middle;
}

body.ui-version-v2 .v2-asset-version-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

body.ui-version-v2 .v2-asset-version-action {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  background: var(--surface-default);
  color: var(--ink-secondary);
  font: 600 0.68rem/1.1 var(--font-interface);
  cursor: pointer;
}

body.ui-version-v2 .v2-asset-version-action:is(:hover, :focus-visible) {
  border-color: var(--accent-primary);
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-asset-version-action.is-danger {
  border-color: color-mix(in srgb, var(--error) 48%, var(--border-default));
  color: var(--error);
}

body.ui-version-v2 .v2-asset-version-copies > summary {
  min-height: 32px;
  padding: 6px 0;
  color: var(--ink-secondary);
  font: 600 0.72rem/1.4 var(--font-interface);
  cursor: pointer;
}

/* The bar carries the row's controls, labelled: Chat, Edit, then ⋯ opening upward. */
body.ui-version-v2 .v2-asset-library-detail-actions {
  --library-chip-hit: var(--action-pill-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-default);
}

/* There ⋯ is the same bare icon, as tall as its neighbours and narrower than them. */
body.ui-version-v2 .v2-asset-library-detail-actions .v2-asset-library-menu-trigger {
  --library-more-width: 28px;
}

body.ui-version-v2 .v2-asset-library-detail-actions:empty {
  display: none;
}

/* A narrow main column stacks the page: the poster on top with DataCat's fade into the text, all one scroll. */
@container asset-library-main (max-width: 600px) {
  body.ui-version-v2 .v2-asset-page-header {
    gap: 8px;
    padding: 10px 12px 10px 6px;
  }

  body.ui-version-v2 .v2-asset-page-heading h3 {
    font-size: 1.0625rem;
  }

  body.ui-version-v2 .v2-asset-page-body {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.ui-version-v2 .v2-asset-page-poster {
    height: min(44dvh, 390px);
  }

  body.ui-version-v2 .v2-asset-page-poster::after {
    position: absolute;
    inset: auto 0 0;
    height: 23%;
    background: linear-gradient(to bottom, transparent, var(--bg-elevated));
    content: '';
    pointer-events: none;
  }

  body.ui-version-v2 .v2-asset-page-info {
    padding: 14px 16px 18px;
    overflow: visible;
  }

  body.ui-version-v2 .v2-asset-library-detail-actions {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  body.ui-version-v2 .v2-asset-library-detail-actions .v2-asset-library-action {
    flex: 1 1 0;
  }

  body.ui-version-v2 .v2-asset-version-copy {
    align-items: flex-start;
    flex-direction: column;
  }

  body.ui-version-v2 .v2-asset-version-actions {
    width: 100%;
    justify-content: flex-start;
  }

  body.ui-version-v2 .v2-asset-version-action {
    min-height: 36px;
  }
}

/* A secondary Library action is the pill's outline; the primary one takes Create's lime (above) and the destructive
 * one is outlined in the error colour (below). */
body.ui-version-v2 .v2-asset-library-action {
  border-color: var(--border-default);
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-asset-library-action:is(:hover, :focus-visible) {
  background: var(--accent-muted);
  color: var(--library-accent-ink);
}

/* Edit is an accent outline beside the filled Chat. */
body.ui-version-v2 .v2-asset-library-action.is-edit {
  border-color: var(--accent-primary);
  color: var(--library-accent-ink);
}

body.ui-version-v2 .v2-asset-library-detail-actions .v2-asset-library-action {
  min-width: 112px;
}

body.ui-version-v2 .v2-asset-library-action.is-danger {
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
  color: var(--error);
}

body.ui-version-v2 .v2-asset-library-action.is-danger:is(:hover, :focus-visible) {
  background: var(--error-muted);
  color: var(--error);
}

/* What deleting a Library item takes with it, listed in the confirmation. */
body.ui-version-v2 .library-delete-dialog {
  width: min(460px, calc(100vw - 24px));
}

body.ui-version-v2 .library-delete-list {
  display: grid;
  max-height: min(44dvh, 320px);
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

body.ui-version-v2 .library-delete-list > li {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-left: 2px solid var(--error);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--error) 7%, transparent);
  color: var(--ink-secondary);
  font-size: 0.8rem;
  line-height: 1.4;
}

body.ui-version-v2 .library-delete-list strong {
  color: var(--ink-primary);
  font-weight: 650;
}

body.ui-version-v2 .library-delete-list ul {
  display: grid;
  gap: 2px;
  margin: 4px 0 0;
  padding-left: 16px;
  color: var(--ink-muted);
  font-size: 0.74rem;
}

body.ui-version-v2 .library-delete-list .library-delete-more {
  list-style: none;
  font-style: italic;
}

/* Phones: full screen with the close at the top right (as DataCat); sections become a dropdown beside the title. */
@media (max-width: 768px) {
  body.ui-version-v2 .v2-asset-library {
    padding: 0;
  }

  body.ui-version-v2 .v2-asset-library-shell {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  body.ui-version-v2 .v2-asset-library-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  body.ui-version-v2 .v2-asset-library-rail {
    display: none;
  }

  body.ui-version-v2 .v2-asset-library-header h2 {
    flex: none;
  }

  body.ui-version-v2 .v2-asset-library-section-picker {
    display: block;
    min-width: 0;
    margin-right: auto;
  }

  /* One row: search, then one control for filter, sort and view. */
  body.ui-version-v2 .v2-asset-library-tools {
    padding: 8px 10px;
  }

  body.ui-version-v2 .v2-asset-library-tools label {
    min-height: 38px;
  }

  body.ui-version-v2 .v2-asset-library-tools > .v2-asset-library-views {
    display: none;
  }

  body.ui-version-v2 .v2-asset-library-organize-trigger {
    width: auto;
    min-height: 38px;
    gap: 4px;
    padding: 4px 6px 4px 9px;
  }

  body.ui-version-v2 .v2-asset-library-organize-trigger [data-library-organize-label] {
    display: none;
  }

  body.ui-version-v2 .v2-asset-library-organize-icon,
  body.ui-version-v2 .v2-asset-library-organize-group.v2-asset-library-organize-view {
    display: grid;
  }

  body.ui-version-v2 .v2-asset-library-results {
    padding: 4px 6px;
  }

  body.ui-version-v2 .v2-asset-library-results[data-view="grid"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 8px;
    padding: 10px;
  }

}

body.ui-version-v2 .v2-character-browser {
  padding: 24px;
  overflow: hidden;
}

body.ui-version-v2 .v2-character-browser .v2-character-browser-shell {
  position: relative;
  width: min(1380px, 100%);
  max-width: 1380px;
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  transform: none;
}

body.ui-version-v2 .v2-character-browser-header {
  grid-row: 1;
  gap: 10px;
}

body.ui-version-v2 .v2-character-browser-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-primary);
  font: 600 1rem/1.1 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The account-owned Library is a separate surface; this browser is only the
 * public DataCat/Boost catalog. */
body.ui-version-v2 .v2-character-browser:not([data-collection="boosts"]) .v2-catalog-collections {
  display: none;
}

body.ui-version-v2 .v2-character-search {
  grid-row: 2;
  display: flex;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-search input {
  min-width: 0;
  min-height: 32px;
  flex: 1;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 16%, transparent);
  border-radius: 4px;
  padding: 5px 9px;
  background: var(--surface-default);
  color: var(--ink-primary);
  font: 500 0.78rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-catalog-search-field > button,
body.ui-version-v2 .v2-character-import {
  border: 0;
  border-radius: 4px;
  padding: 7px 13px;
  background: var(--lime-default);
  color: var(--lime-on);
  font: 600 0.75rem/1 var(--font-interface);
  cursor: pointer;
}

body.ui-version-v2 .v2-catalog-collections {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

body.ui-version-v2 .v2-catalog-collections button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: 600 0.8rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-catalog-collections button[aria-pressed="true"] {
  background: var(--accent-muted);
  color: var(--accent-primary);
}

/* Boosts are a whole-feature switch: with them off, DataCat has no Boost collection to switch to. */
body.ui-version-v2 .v2-catalog-collections button[hidden] {
  display: none;
}

body.ui-version-v2 :is(.v2-catalog-collections, .v2-character-search) svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

body.ui-version-v2 .v2-catalog-search-field {
  display: flex;
  flex: 1;
  min-width: 0;
}

body.ui-version-v2 .v2-catalog-search-field input {
  width: 100%;
  border-radius: 5px 0 0 5px;
}

body.ui-version-v2 .v2-catalog-search-field > button {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  padding: 0;
  border-radius: 0 5px 5px 0;
}

body.ui-version-v2 .v2-catalog-character-controls {
  display: flex;
  gap: 6px;
}

body.ui-version-v2 .v2-catalog-character-controls > .sandcat-select {
  width: 154px;
  flex: 0 0 154px;
}

body.ui-version-v2 :is(.v2-catalog-character-controls, .v2-catalog-tag-controls) .sandcat-select-trigger {
  min-height: 32px;
  padding: 4px 8px;
  border-color: var(--border-default);
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font: 500 0.73rem/1.15 var(--font-interface);
}

body.ui-version-v2 :is(.v2-catalog-character-controls, .v2-catalog-tags-toggle strong, .v2-catalog-tag-selected, .v2-catalog-tag-more)[hidden] {
  display: none;
}

body.ui-version-v2 .v2-catalog-tags-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font: 500 0.73rem/1.15 var(--font-interface);
}

body.ui-version-v2 .v2-catalog-tags-toggle.is-filtered {
  border-color: var(--accent-primary);
  background: var(--accent-muted);
  color: var(--accent-primary);
}

body.ui-version-v2 .v2-catalog-tags-toggle strong {
  font-size: 0.72em;
}

/* Desktop keeps tag discovery visible; mobile presents the same surface as a sheet. */
body.ui-version-v2 .v2-catalog-tag-sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  width: 178px;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 8px 8px 12px;
  border-right: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  background: var(--surface-default);
}

body.ui-version-v2 .v2-catalog-tag-sidebar > header {
  display: flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 5px;
}

body.ui-version-v2 .v2-catalog-tag-sidebar > header strong {
  color: var(--accent-primary);
  font: 650 0.65rem/1 var(--font-interface);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-catalog-tag-close {
  display: none;
  touch-action: manipulation;
}

body.ui-version-v2 .v2-catalog-tag-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

body.ui-version-v2 .v2-catalog-tag-search-field {
  position: relative;
  grid-column: 1 / -1;
  min-width: 0;
}

body.ui-version-v2 .v2-catalog-tag-search {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 5px 31px 5px 7px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font: 500 0.72rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-catalog-tag-controls > .sandcat-select {
  width: 100%;
  min-width: 0;
}

body.ui-version-v2 .v2-catalog-tag-clear {
  position: absolute;
  top: 50%;
  right: 2px;
  z-index: 1;
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  transform: translateY(-50%);
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font: 700 1rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-catalog-tag-clear:not(:disabled):hover {
  color: var(--accent-primary);
}

body.ui-version-v2 .v2-catalog-tag-clear:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

body.ui-version-v2 .v2-catalog-tag-clear[hidden] {
  display: none;
}

body.ui-version-v2 .v2-catalog-tag-help,
body.ui-version-v2 .v2-catalog-tag-status {
  margin: 6px 0;
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 1.25;
}

body.ui-version-v2 .v2-catalog-tag-status.is-error {
  color: var(--error);
}
body.ui-version-v2 .v2-catalog-tag-results {
  --busy-surface: var(--surface-default);
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

body.ui-version-v2 .v2-catalog-tag-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  scrollbar-width: thin;
}

body.ui-version-v2 .v2-catalog-tag-cloud {
  display: flex;
  flex-direction: column;
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 5px 4px;
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) calc(8% + var(--heat) * 8%), transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-primary) calc(2% + var(--heat) * 3%), transparent);
  font-size: calc(0.62rem + var(--heat) * 0.11rem);
  line-height: 1;
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag:hover {
  border-color: color-mix(in srgb, var(--accent-primary) 45%, transparent);
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag[aria-pressed="true"] {
  border-color: var(--accent-primary);
  background: var(--accent-muted);
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag-indicator {
  display: none;
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-catalog-tag-cloud.is-cloud .v2-catalog-tag small {
  font-size: 0.52rem;
}

body.ui-version-v2 .v2-catalog-tag-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 6px;
}

body.ui-version-v2 .v2-catalog-tag {
  --heat: 1;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  padding: 3px 2px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: 500 0.69rem/1.25 var(--font-interface);
  text-align: left;
}

body.ui-version-v2 .v2-catalog-tag:hover {
  color: var(--text-primary);
}

body.ui-version-v2 .v2-catalog-tag-indicator {
  width: 7px;
  height: 7px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
}

body.ui-version-v2 .v2-catalog-tag-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.ui-version-v2 .v2-catalog-tag small {
  color: var(--text-muted);
  font-size: 0.56rem;
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-catalog-tag[aria-pressed="true"] {
  color: var(--accent-primary);
}

body.ui-version-v2 .v2-catalog-tag[aria-pressed="true"] .v2-catalog-tag-indicator {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
}

body.ui-version-v2 .v2-catalog-tag[aria-pressed="true"] small {
  display: none;
}

body.ui-version-v2 .v2-catalog-tag:disabled {
  opacity: 0.45;
  cursor: default;
}

body.ui-version-v2 .v2-catalog-tag-selected .v2-catalog-tag {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid var(--accent-primary);
  border-radius: 999px;
  background: var(--accent-muted);
  color: var(--accent-primary);
  font-size: 0.62rem;
}

body.ui-version-v2 .v2-catalog-tag-more {
  width: 100%;
  margin-top: 5px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 600 0.62rem/1 var(--font-interface);
  text-align: left;
}

body.ui-version-v2 .v2-catalog-tag-more:hover {
  color: var(--text-primary);
}

body.ui-version-v2 .v2-catalog-tag-scrim {
  display: none;
}

body.ui-version-v2 .v2-character-browser-body {
  grid-row: 3;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  overflow: hidden;
}

body.ui-version-v2 .v2-character-browser[data-collection="boosts"] .v2-character-browser-body {
  grid-template-columns: minmax(0, 1fr);
}

body.ui-version-v2 .v2-character-browser[data-collection="boosts"] .v2-catalog-tag-sidebar {
  display: none;
}

body.ui-version-v2 .v2-character-results {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 14px;
}

body.ui-version-v2 .v2-character-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
}

body.ui-version-v2 .v2-character-grid.is-virtual {
  position: relative;
  display: block;
  width: 100%;
}

body.ui-version-v2 .v2-character-grid.is-virtual .v2-character-card {
  position: absolute;
  top: 0;
  left: 0;
}

/* DataCat public-grid geometry, typography and badges; shell colours stay themed. */
body.ui-version-v2 .v2-character-card {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-primary);
  font: 16px/1.5 'Space Grotesk', sans-serif;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.ui-version-v2 .v2-character-card:hover {
  transform: none;
  box-shadow: none;
}

body.ui-version-v2 .v2-character-card:focus-visible {
  outline: 2px solid var(--lime-default);
  outline-offset: 2px;
}

body.ui-version-v2 .v2-character-card-visual {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  background: var(--surface-muted);
}

body.ui-version-v2 .v2-character-card-visual img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: cover;
  object-position: top center;
}

body.ui-version-v2 .v2-character-content-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #ef4444;
  color: #1a0808;
  font-size: calc(10px + 0.5pt);
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

body.ui-version-v2 :is(.v2-catalog-tokens, .v2-catalog-date) {
  position: absolute;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.56);
  color: rgba(255, 255, 255, 0.88);
  font-size: calc(9px + 0.5pt);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

body.ui-version-v2 .v2-catalog-tokens {
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
}

body.ui-version-v2 .v2-catalog-date {
  top: 8px;
  right: 8px;
}

body.ui-version-v2 .v2-catalog-score {
  position: absolute;
  bottom: 3px;
  right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 5px;
  border-radius: 6px;
  background: rgba(71, 85, 105, 0.62);
  color: rgba(255, 255, 255, 0.95);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body.ui-version-v2 .v2-catalog-score.is-low { background: rgba(71, 85, 105, 0.45); }
body.ui-version-v2 .v2-catalog-score.is-mid { background: rgba(30, 58, 138, 0.42); }
body.ui-version-v2 .v2-catalog-score.is-pending { background: rgba(30, 58, 138, 0.62); }
body.ui-version-v2 .v2-catalog-score.is-top {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.5), rgba(146, 64, 14, 0.55));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(245, 158, 11, 0.2);
}

body.ui-version-v2 .v2-catalog-score-main {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}

body.ui-version-v2 .v2-catalog-score-niche {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: -1px;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}

body.ui-version-v2 .v2-catalog-score-niche i {
  width: 5px;
  height: 5px;
  margin-left: 2px;
  border-radius: 1px;
  background: #f59e0b;
  transform: rotate(45deg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
}

body.ui-version-v2 .v2-character-card-copy {
  display: block;
  min-width: 0;
  padding: 4px 12px 8px;
}

body.ui-version-v2 .v2-character-card-copy strong {
  display: block;
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--ink-primary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.ui-version-v2 .v2-catalog-author-row {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

body.ui-version-v2 .v2-catalog-author {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  gap: 2px;
  font-size: 11px;
  line-height: 1.2;
}

body.ui-version-v2 .v2-catalog-author small {
  color: var(--lime-default);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-catalog-author-name-row {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}

body.ui-version-v2 .v2-catalog-author-name {
  overflow: hidden;
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.ui-version-v2 .v2-catalog-source {
  display: inline-flex;
  align-items: center;
  min-height: 15px;
  margin-left: 4px;
  padding: 0.8px 3.52px;
  border: 1px solid rgba(96, 165, 250, 0.34);
  border-radius: 5.6px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--ink-secondary);
  font-size: calc(5.6px + 1pt);
  line-height: 1.1;
  letter-spacing: 0.02em;
  font-weight: 700;
}

body.ui-version-v2 .v2-catalog-age {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--ink-muted);
  font-size: 11px;
}

@media (min-width: 901px) and (max-width: 1200px) {
  body.ui-version-v2 .v2-character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-catalog-score-main { font-size: calc(13px + 0.5pt); }
  body.ui-version-v2 .v2-catalog-score-niche { font-size: calc(8px + 0.5pt); }
  body.ui-version-v2 .v2-character-card-copy { padding: 4px 8px 8px; }
}

body.ui-version-v2 .v2-character-catalog-status {
  min-height: 1.4em;
  margin: 13px 0 8px;
  color: var(--ink-muted);
  font-size: 0.75rem;
  text-align: center;
}

/* The single stock spinner and the shared in-flight tiers (chat/busy-feedback.js). */
.v2-action-spinner {
  display: inline-block;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.82;
  animation: appLoadSpin 0.8s linear infinite;
  vertical-align: -1px;
}

@keyframes appLoadSpin { to { transform: rotate(360deg); } }

.v2-character-catalog-status.is-loading > .v2-action-spinner {
  margin-right: 6px;
}

/* Element tier: the busy control or row takes no input. */
[data-busy-applied] {
  pointer-events: none;
}

[data-busy-applied] [data-busy-indicator] {
  display: none !important;
}

/* A leading spinner before a control's text; flex/grid controls space it with their own gap. */
[data-busy-lead] {
  margin-inline-end: 0.4em;
}

.busy-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Region tier: one opaque status surface over a panel. Page tier fixes it to the viewport. */
.busy-region {
  position: absolute;
  inset: 0;
  z-index: 44;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-secondary);
  background: var(--busy-surface, var(--surface-canvas));
  font-family: var(--font-interface);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease-out, visibility 0s linear 150ms;
}

/* A blocking surface is opaque on its first frame, so nothing it is about to
 * replace shows through; only its exit fades to reveal the settled content. */
.busy-region.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: none;
}

.busy-region:focus {
  outline: none;
}

/* Blocking surfaces show one larger spinner; the caption stays for screen readers only. */
.busy-region > .v2-action-spinner {
  width: 28px;
  height: 28px;
  border-width: 2.5px;
}

.busy-region strong {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* An idle surface keeps its node for the fade-out; its spinner must not keep running. */
.busy-region:not(.is-active) > .v2-action-spinner {
  animation: none;
}

.busy-page {
  position: fixed;
  z-index: 2000;
}

@media (prefers-reduced-motion: reduce) {
  .v2-action-spinner { animation: none; }
  .busy-region { transition: none; }
}

body.ui-version-v2 .v2-character-catalog-status.is-error,
body.ui-version-v2 .v2-character-preview-copy > [role="status"] {
  color: var(--error);
}

body.ui-version-v2 .v2-character-preview {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, #05080e 86%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 0s linear 150ms;
}

body.ui-version-v2 .v2-character-preview.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

body.ui-version-v2 .v2-character-preview-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  width: min(940px, 100%);
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  transform: translateY(8px) scale(0.99);
  transition: transform 150ms ease;
}

body.ui-version-v2 .v2-character-preview.active .v2-character-preview-shell {
  transform: translateY(0) scale(1);
}

body.ui-version-v2 .v2-character-preview-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-preview-header > div {
  min-width: 0;
  flex: 1;
}

body.ui-version-v2 .v2-character-preview-header small {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-muted);
  font-size: 0.68rem;
}

body.ui-version-v2 .v2-character-preview-header h3 {
  margin: 0;
  overflow: hidden;
  color: var(--ink-primary);
  font: 600 1.12rem/1.2 var(--font-interface);
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .v2-character-preview-tabs {
  display: flex;
  min-width: 0;
  gap: 6px;
  padding: 0 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-preview-tabs button {
  position: relative;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.72rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-character-preview-tabs button::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  content: "";
}

body.ui-version-v2 .v2-character-preview-tabs button[aria-selected="true"] {
  color: var(--ink-primary);
}

body.ui-version-v2 .v2-character-preview-tabs button[aria-selected="true"]::after {
  background: var(--accent-primary);
}

body.ui-version-v2 .v2-character-score-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--surface-default) 76%, var(--bg-subtle));
}

body.ui-version-v2 .v2-character-score-panel[hidden],
body.ui-version-v2 .v2-character-preview-content[hidden],
body.ui-version-v2 .v2-character-score-view[hidden] {
  display: none;
}

body.ui-version-v2 .v2-character-score-state {
  display: grid;
  min-height: 240px;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--ink-muted);
  text-align: center;
}

body.ui-version-v2 .v2-character-score-state p {
  max-width: 40ch;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

body.ui-version-v2 .v2-character-score-state p.is-error {
  color: var(--error);
}

body.ui-version-v2 .v2-character-score-state button,
body.ui-version-v2 .v2-character-score-breakdown button,
body.ui-version-v2 .v2-character-score-details-header button {
  border: 0;
  background: transparent;
  color: var(--accent-primary);
  font: 600 0.7rem/1 var(--font-interface);
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.ui-version-v2 .v2-character-score-view {
  box-sizing: border-box;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 24px 28px;
}

body.ui-version-v2 .v2-character-score-source,
body.ui-version-v2 .v2-character-score-footer {
  margin: 0;
  color: var(--ink-muted);
  font: 0.68rem/1.4 var(--font-interface);
}

body.ui-version-v2 .v2-character-score-source strong {
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-character-score-quote {
  margin: 14px 0 20px;
  padding: 12px 14px;
  border-left: 2px solid var(--accent-primary);
  background: color-mix(in srgb, var(--accent-primary) 6%, var(--surface-default));
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-character-score-quote p {
  margin: 0;
  font: italic 0.84rem/1.5 var(--font-interface);
}

body.ui-version-v2 .v2-character-score-top {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

body.ui-version-v2 .v2-character-score-badge {
  display: inline-flex;
  min-width: 0;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

body.ui-version-v2 .v2-character-score-badge.is-low {
  background: rgba(71, 85, 105, 0.48);
}

body.ui-version-v2 .v2-character-score-badge.is-mid {
  background: rgba(30, 58, 138, 0.45);
}

body.ui-version-v2 .v2-character-score-badge.is-top {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.52) 0%, rgba(146, 64, 14, 0.58) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 16px rgba(245, 158, 11, 0.22);
}

body.ui-version-v2 .v2-character-score-badge strong {
  font: 700 2.2rem/1.1 var(--font-interface);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-character-score-badge small {
  margin-top: 2px;
  color: inherit;
  font: 600 0.4375rem/1.1 var(--font-interface);
  letter-spacing: 0.06em;
  opacity: 0.8;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-character-score-badge span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: -1px;
  font: 500 0.6875rem/1 var(--font-interface);
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

body.ui-version-v2 .v2-character-score-bonus-mark {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: #f59e0b;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  opacity: 0.95;
  transform: rotate(45deg);
}

body.ui-version-v2 .v2-character-score-recommended {
  min-width: 0;
}

body.ui-version-v2 .v2-character-score-recommended small,
body.ui-version-v2 .v2-character-score-niche small {
  color: var(--ink-muted);
  font: 600 0.58rem/1 var(--font-interface);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-character-score-recommended p {
  margin: 7px 0 0;
  color: var(--ink-primary);
  font: 600 1rem/1.4 var(--font-interface);
}

body.ui-version-v2 .v2-character-score-niche {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-score-niche h4 {
  margin: 6px 0 0;
  color: var(--ink-primary);
  font: 600 0.95rem/1.3 var(--font-interface);
}

body.ui-version-v2 .v2-character-score-niche p {
  margin: 7px 0 0;
  color: var(--ink-secondary);
  font-size: 0.74rem;
  line-height: 1.45;
}

body.ui-version-v2 .v2-character-score-breakdown {
  padding: 15px 16px 17px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-score-breakdown > header,
body.ui-version-v2 .v2-character-score-details-header,
body.ui-version-v2 .v2-character-score-dimension > div,
body.ui-version-v2 .v2-character-score-reasons article > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.ui-version-v2 .v2-character-score-breakdown h4,
body.ui-version-v2 .v2-character-score-details-header h4 {
  margin: 0;
  color: var(--ink-primary);
  font: 650 0.73rem/1.2 var(--font-interface);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

body.ui-version-v2 .v2-character-score-dimension {
  margin-top: 14px;
}

body.ui-version-v2 .v2-character-score-dimension > div {
  color: var(--ink-secondary);
  font-size: 0.7rem;
}

body.ui-version-v2 .v2-character-score-dimension > div > span {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-character-score-bar {
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-primary) 9%, transparent);
}

body.ui-version-v2 .v2-character-score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-primary);
}

body.ui-version-v2 .v2-character-score-meta {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 7px 14px;
  margin: 18px 0 0;
  padding: 15px 16px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-muted);
  font-size: 0.68rem;
}

body.ui-version-v2 .v2-character-score-meta dd {
  margin: 0;
  color: var(--ink-secondary);
  line-height: 1.4;
}

body.ui-version-v2 .v2-character-score-details-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .v2-character-score-reasons {
  display: grid;
  gap: 10px;
}

body.ui-version-v2 .v2-character-score-reasons article {
  padding: 13px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-default);
}

body.ui-version-v2 .v2-character-score-reasons article > header {
  color: var(--ink-primary);
  font-size: 0.76rem;
}

body.ui-version-v2 .v2-character-score-reasons article > header > span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

body.ui-version-v2 .v2-character-score-reasons article > header button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font: 600 0.64rem/1 var(--font-interface);
}

body.ui-version-v2 .v2-character-score-reasons article > p {
  margin: 8px 0 0;
  color: var(--ink-secondary);
  font-size: 0.72rem;
  line-height: 1.48;
}

body.ui-version-v2 .v2-character-score-reasons .v2-character-score-reason-info {
  padding: 7px 9px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--ink-muted);
  font-size: 0.66rem;
}

body.ui-version-v2 .v2-character-score-footer {
  margin-top: 14px;
  overflow-wrap: anywhere;
}

body.ui-version-v2 .v2-character-preview-content {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
body.ui-version-v2 .v2-character-preview-content.has-no-art {
  grid-template-columns: minmax(0, 1fr);
}

body.ui-version-v2 .v2-character-preview-hero {
  position: sticky;
  top: 0;
  align-self: start;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--surface-muted);
}

body.ui-version-v2 .v2-character-preview-hero[hidden] {
  display: none;
}

body.ui-version-v2 .v2-character-preview-hero > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

body.ui-version-v2 .v2-character-preview-score {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: rgba(30, 58, 138, 0.72);
  color: #fff;
  font-family: inherit;
  text-align: right;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

body.ui-version-v2 .v2-character-preview-score[hidden] {
  display: none;
}

body.ui-version-v2 .v2-character-preview-score.is-top {
  background: rgba(180, 83, 9, 0.78);
}

body.ui-version-v2 .v2-character-preview-score:is(.is-low, .is-na) {
  background: rgba(51, 65, 85, 0.78);
}

body.ui-version-v2 .v2-character-preview-score strong {
  font-size: 1.15rem;
  line-height: 1;
}

body.ui-version-v2 .v2-character-preview-score span {
  margin-top: 3px;
  font-size: 0.58rem;
  opacity: 0.84;
}

body.ui-version-v2 .v2-character-preview-copy {
  min-width: 0;
  padding: 22px 24px 26px;
}

body.ui-version-v2 .v2-character-preview-copy > p {
  margin: 0 0 16px;
  color: var(--ink-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-line;
}

body.ui-version-v2 .v2-character-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 18px;
}

body.ui-version-v2 .v2-character-preview-tags span {
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--ink-secondary) 23%, transparent);
  border-radius: 999px;
  color: var(--ink-secondary);
  font-size: 0.62rem;
}

body.ui-version-v2 .v2-character-preview-copy dl {
  display: grid;
  grid-template-columns: minmax(100px, auto) 1fr;
  gap: 6px 14px;
  margin: 0 0 20px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 9%, transparent);
  color: var(--ink-muted);
  font-size: 0.7rem;
}

body.ui-version-v2 .v2-character-preview-copy dd {
  margin: 0;
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-character-import {
  width: 100%;
  padding-block: 10px;
}

body.ui-version-v2 .v2-character-import:disabled {
  opacity: 0.55;
  cursor: default;
}

body.ui-version-v2 .v2-character-preview-copy > [role="status"] {
  display: block;
  margin-top: 8px;
  color: var(--error);
  font-size: 0.7rem;
  line-height: 1.35;
}

@media (max-width: 900px) {
  body.ui-version-v2 .v2-character-browser-body {
    display: block;
  }

  body.ui-version-v2 .v2-catalog-tags-toggle {
    display: inline-flex;
  }

  body.ui-version-v2 .v2-character-results {
    width: 100%;
    height: 100%;
  }

  body.ui-version-v2 .v2-character-grid:not(.is-virtual) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.ui-version-v2 .v2-catalog-tag-scrim {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.54);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 150ms ease, visibility 0s linear 150ms;
  }

  body.ui-version-v2 .v2-catalog-tag-sidebar {
    position: absolute;
    inset: auto 0 0;
    z-index: 4;
    width: 100%;
    height: min(85dvh, calc(100dvh - 48px));
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 170ms ease, visibility 0s linear 170ms;
  }

  body.ui-version-v2 .v2-character-browser.is-filtering .v2-character-browser-body {
    overflow: visible;
  }

  body.ui-version-v2 .v2-character-browser.is-filtering .v2-catalog-tag-scrim {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  body.ui-version-v2 .v2-character-browser.is-filtering .v2-catalog-tag-sidebar {
    transform: translateY(0);
    visibility: visible;
    transition-delay: 0s;
  }

  body.ui-version-v2 .v2-catalog-tag-sidebar > header {
    min-height: 44px;
    padding-right: 48px;
  }

  body.ui-version-v2 .v2-catalog-tag-close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 1;
    display: flex;
  }

  body.ui-version-v2 .v2-catalog-tag-controls {
    grid-template-columns: minmax(0, 1fr) 132px auto;
  }

  body.ui-version-v2 .v2-catalog-tag-search-field {
    grid-column: auto;
  }

  body.ui-version-v2 .v2-catalog-tag-cloud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
  }

  body.ui-version-v2 .v2-character-preview {
    padding: 0;
  }

  body.ui-version-v2 .v2-character-preview-shell {
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  body.ui-version-v2 .v2-character-preview-header {
    position: relative;
    z-index: 2;
  }

  body.ui-version-v2 .v2-character-preview-content {
    display: block;
  }

  body.ui-version-v2 .v2-character-preview-hero {
    position: relative;
    aspect-ratio: auto;
    height: min(44dvh, 390px);
  }

  body.ui-version-v2 .v2-character-preview-copy {
    padding: 18px 20px 24px;
  }

  body.ui-version-v2 .v2-character-score-view {
    padding: 18px 20px 24px;
  }
}

@media (max-width: 768px) {
  body.ui-version-v2 .v2-character-browser {
    padding: 0;
  }

  body.ui-version-v2 .v2-character-browser .v2-character-browser-shell {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  body.ui-version-v2 .v2-catalog-collections button {
    width: 34px;
    min-height: 34px;
    padding: 0;
  }

  body.ui-version-v2 .v2-catalog-collections button > span {
    display: none;
  }
}

@media (max-width: 560px) {
  body.ui-version-v2 .v2-character-browser-header {
    gap: 6px;
  }

  body.ui-version-v2 .v2-character-search {
    padding: 6px 8px;
  }

  body.ui-version-v2 .v2-character-results {
    padding: 12px;
    scrollbar-gutter: auto;
  }

  body.ui-version-v2 .v2-character-grid:not(.is-virtual) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  body.ui-version-v2 .v2-catalog-character-controls > .sandcat-select {
    width: 126px;
    flex-basis: 126px;
  }

  body.ui-version-v2 .v2-catalog-tag-controls {
    grid-template-columns: minmax(0, 1fr) 150px;
  }

  body.ui-version-v2 .v2-character-preview-header h3 {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 :is(
    .v2-character-browser,
    .v2-catalog-tag-sidebar,
    .v2-catalog-tag-scrim,
    .v2-character-preview,
    .v2-character-preview-shell
  ) {
    transition: none;
  }
}

/* Mobile reserves the app bar for identity and three compact actions. */
@media (max-width: 768px) {
  body.ui-version-v2 {
    /* Ends the fade the same 4px above the input as desktop's 48px fade. */
    --v2-transcript-fade-depth: 42px;
  }
  body.ui-version-v2 .input-area {
    padding-top: 12px;
    padding-bottom: 4px;
  }

  body.ui-version-v2 .composer-rail-badge {
    height: 18px;
  }

  body.ui-version-v2 .scroll-bottom-btn {
    min-width: 100px;
    padding-inline: 10px;
  }

  body.ui-version-v2 .composer-boost-badge {
    padding-inline: 6px;
    letter-spacing: 0.06em;
  }

  body.ui-version-v2 .composer-rail-badge::before {
    content: '';
    position: absolute;
    inset: -3px 0;
  }

  body.ui-version-v2 .scroll-bottom-btn svg {
    width: 16px;
    height: 16px;
  }

  body.ui-version-v2 .top-bar-inner {
    position: relative;
    gap: 0;
    padding-right: calc(5px + var(--safe-right));
    padding-left: calc(3.75px + var(--safe-left));
  }

  body.ui-version-v2 .status-bar {
    padding: 0 4px;
    font-size: calc(0.75rem - 1px);
  }

  body.ui-version-v2 .status-bar-inner {
    justify-content: flex-start;
    padding: 0 calc(5px + var(--safe-right)) 0 calc(5px + var(--safe-left));
  }

  body.ui-version-v2 .status-left,
  body.ui-version-v2 .status-right {
    gap: 4px;
  }

  body.ui-version-v2 .status-dot {
    width: 6px;
    height: 6px;
  }

  body.ui-version-v2 .top-bar-left {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  body.ui-version-v2 .top-bar-left .app-title {
    min-width: 0;
    overflow: hidden;
  }

  body.ui-version-v2 .shell-opening-title {
    min-width: 0;
    max-width: none;
    overflow: hidden;
    flex: 1 1 auto;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.ui-version-v2 .top-bar-right {
    gap: 1.5px;
  }

  body.ui-version-v2 .menu-toggle-btn::before {
    content: none;
  }

  body.ui-version-v2 .menu-toggle-btn svg {
    display: block;
    width: 26.5px;
    min-width: 26.5px;
    height: 26.5px;
    flex-basis: 26.5px;
  }


  body.ui-version-v2 .menu-toggle-btn {
    width: 24px;
    height: 36px;
    flex: 0 0 24px;
    margin: 0 0 0 6px;
    padding: 0;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-inner {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-left {
    grid-column: 1;
    grid-row: 1;
    width: 36px;
    overflow: visible;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-left .app-title {
    display: none;
  }

  body.ui-version-v2.guest-workspace.v2-no-chat.v2-sticky-visible .top-bar-left .app-title {
    display: flex;
  }

  /* An open conversations drawer owns the header (see .app-drawer-title) and hides the identity beside the icon, so
   * the left group takes its width back and keeps its title; otherwise a General chat's always-visible identity
   * would leave the drawer's header nameless. */
  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)):has(#sidebar.open) .top-bar-left {
    grid-column: 1 / -1;
    width: auto;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)):has(#sidebar.open) .top-bar-left .app-title {
    display: flex;
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated {
    position: absolute;
    right: 0;
    left: 26px;
    grid-template-rows: 36px;
    column-gap: 5px;
    width: auto;
    min-width: 0;
    min-height: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  body.ui-version-v2.v2-sticky-visible .top-bar-inner > .v2-sticky-header-integrated {
    position: static;
    grid-column: 2;
    grid-row: 1;
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated .v2-sticky-character {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    height: 36px;
    gap: 8px;
  }

  body.ui-version-v2 .v2-memory-rail-toggle {
    width: 36px;
    height: 36px;
  }

  body.ui-version-v2.v2-sticky-visible:where(:not(.manuscript-reader-open, .help-page-open)) .top-bar-right {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    gap: 1.5px;
  }
}

/* Footer model routing and the shared settings shell use the model workspace language. */
body.ui-version-v2 .status-right {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 2px;
  margin-left: auto;
  overflow: visible;
}

body.ui-version-v2 .status-right > .status-sep,
body.ui-version-v2 #statusEndpointTrigger {
  display: none;
}

@media (min-width: 769px) {
  body.ui-version-v2 .status-bar {
    padding-right: 0;
    padding-left: 0;
  }

  body.ui-version-v2 .status-bar-inner {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }
}

body.ui-version-v2 .status-model-control {
  max-width: min(360px, 70vw);
  margin-left: auto;
}

body.ui-version-v2 .status-model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  height: 22px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
}

body.ui-version-v2 .status-model-trigger:hover,
body.ui-version-v2 .status-model-trigger:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 30%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 7%, transparent);
  color: var(--ink-primary);
}

body.ui-version-v2 .footer-model-label {
  min-width: 0;
  max-width: 26ch;
  overflow: hidden;
  color: inherit;
  font-size: calc(0.64rem - 1pt);
  line-height: 1.2;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Desktop reads the model label at its original size; phones keep it 1pt smaller. */
@media (min-width: 769px) {
  body.ui-version-v2 .footer-model-label {
    font-size: 0.64rem;
  }
}

body.ui-version-v2 .status-model-trigger > .disclosure-caret {
  color: var(--lime-strong);
}

body.ui-version-v2 .status-credits-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 2px;
  height: 22px;
  min-width: 0;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.64rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
}

body.ui-version-v2 .status-credits-trigger[hidden] {
  display: none;
}
/* The infinity glyph sits optically small at the numeric balance size. */
body.ui-version-v2 .status-credits-balance.is-unlimited {
  font-size: 1.05rem;
  line-height: 1;
}


body.ui-version-v2 .status-credits-trigger:hover,
body.ui-version-v2 .status-credits-trigger:focus-visible {
  border-color: color-mix(in srgb, var(--lime-strong) 30%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 7%, transparent);
  color: var(--ink-primary);
}

/* The Credits coin, as in JannyCloner's Credits view: a gold CSS coin with an inner ring and a highlight. */
.credit-coin-icon {
  --coin-size: 14px;
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  width: var(--coin-size);
  height: var(--coin-size);
  flex: 0 0 var(--coin-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff7b8 0 12%, transparent 13%),
    linear-gradient(135deg, #ffe47a 0%, #f5b942 48%, #d9901f 100%);
  border: 1px solid rgba(121, 77, 13, 0.42);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.75),
    inset 0 -1px 1px rgba(95, 56, 6, 0.36),
    0 0 0 1px rgba(255, 236, 150, 0.18);
}

.credit-coin-icon::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1px solid rgba(255, 247, 184, 0.55);
}

.credit-coin-icon::after {
  content: "";
  position: absolute;
  top: 23%;
  left: 27%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
}

body.ui-version-v2 .credits-settings-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}

body.ui-version-v2 .credits-balance-readout {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

body.ui-version-v2 .credits-balance-readout strong {
  color: var(--text-primary);
  font-family: var(--font-v2-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
}

body.ui-version-v2 .credits-balance-readout span,
body.ui-version-v2 .credits-settings-summary p {
  color: var(--text-secondary);
  font-family: var(--font-v2-display);
  font-size: 0.68rem;
  line-height: 1.35;
}

body.ui-version-v2 .credits-settings-summary p {
  margin: 0;
  text-align: right;
}

body.ui-version-v2 .credits-settings-summary p b {
  color: var(--text-primary);
  font-weight: 600;
}

body.ui-version-v2 .credits-section-tabs.model-picker-tabs {
  width: min(340px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 10px;
  padding: 0;
}

body.ui-version-v2 .credits-section-tabs .model-picker-tab {
  min-height: 34px;
  font-size: 0.72rem;
}

body.ui-version-v2 .credits-subsection[hidden] {
  display: none;
}

body.ui-version-v2 .credits-history-heading {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-family: var(--font-v2-display);
  font-size: 0.62rem;
}

body.ui-version-v2 .credits-history-status {
  padding: 18px 10px;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-v2-display);
  font-size: 0.64rem;
  text-align: center;
}

body.ui-version-v2 .credits-history {
  display: grid;
  max-height: min(480px, calc(100dvh - 330px));
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  list-style: none;
  overscroll-behavior: contain;
}

body.ui-version-v2 .credits-history[hidden] {
  display: none;
}

body.ui-version-v2 .credits-history-item {
  display: grid;
  min-width: 0;
  min-height: 32px;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
}

body.ui-version-v2 .credits-history-item + .credits-history-item {
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 .credits-history-copy,
body.ui-version-v2 .credits-history-amount {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 6px;
}

body.ui-version-v2 .credits-history-copy strong,
body.ui-version-v2 .credits-history-amount strong {
  flex: 0 0 auto;
  color: var(--text-primary);
  font-family: var(--font-v2-display);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

body.ui-version-v2 .credits-history-copy span,
body.ui-version-v2 .credits-history-amount span {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-v2-display);
  font-size: 0.58rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 .credits-history-copy span {
  flex: 1 1 auto;
}

body.ui-version-v2 .credits-history-amount {
  justify-content: flex-end;
  text-align: right;
}

body.ui-version-v2 .credits-history-item[data-kind="daily_refill"] .credits-history-amount strong {
  color: var(--accent-primary);
}

body.ui-version-v2 .credits-history-item.is-group {
  display: block;
  padding: 0;
}

body.ui-version-v2 .credits-history-summary {
  display: grid;
  width: 100%;
  min-height: 32px;
  grid-template-columns: minmax(0, 1fr) max-content 10px;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

body.ui-version-v2 .credits-history-summary:hover,
body.ui-version-v2 .credits-history-summary:focus-visible {
  background: var(--bg-hover);
}

body.ui-version-v2 .credits-history-summary:focus-visible {
  outline: 1px solid var(--accent-primary);
  outline-offset: -1px;
}

body.ui-version-v2 .credits-history-chevron {
  width: 10px;
  height: 10px;
  color: var(--text-muted);
}

body.ui-version-v2 .credits-history-chevron::before {
  display: block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: '';
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}

body.ui-version-v2 .credits-history-summary[aria-expanded="true"] .credits-history-chevron::before {
  transform: rotate(45deg);
}

body.ui-version-v2 .credits-history-item.is-group[data-turn-kind="assistant"] .credits-history-amount strong {
  color: var(--accent-primary);
}

body.ui-version-v2 .credits-history-calls {
  padding: 2px 8px 7px 20px;
  background: var(--bg-subtle);
}

body.ui-version-v2 .credits-history-calls[hidden] {
  display: none;
}

body.ui-version-v2 .credits-history-calls ol {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

body.ui-version-v2 .credits-history-call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
}

body.ui-version-v2 .credits-history-call + .credits-history-call {
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 .credits-history-call-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

body.ui-version-v2 .credits-history-call-copy strong {
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-family: var(--font-v2-display);
  font-size: 0.72rem;
  font-weight: 600;
}

body.ui-version-v2 .credits-history-call-copy span {
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-family: var(--font-v2-display);
  font-size: 0.68rem;
  line-height: 1.3;
}

body.ui-version-v2 .credits-history-call-amount {
  color: var(--text-primary);
  font-family: var(--font-v2-display);
  font-size: 0.62rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

body.ui-version-v2 .credits-history-call[data-charge="unknown"] .credits-history-call-amount,
body.ui-version-v2 .credits-history-call[data-charge="free"] .credits-history-call-amount {
  color: var(--text-muted);
  font-weight: 500;
}

body.ui-version-v2 .credits-pricing-list {
  margin: 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 .credits-pricing-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  padding: 11px 2px;
}

body.ui-version-v2 .credits-pricing-list > div + div {
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 .credits-pricing-list dt,
body.ui-version-v2 .credits-pricing-list dd {
  margin: 0;
  font-family: var(--font-v2-display);
  font-size: 0.72rem;
  line-height: 1.4;
}

body.ui-version-v2 .credits-pricing-list dt,
body.ui-version-v2 .credits-pricing-list dd strong {
  color: var(--text-primary);
  font-weight: 600;
}

body.ui-version-v2 .credits-pricing-list dd,
body.ui-version-v2 .credits-pricing-note {
  color: var(--text-secondary);
}

body.ui-version-v2 .credits-pricing-note {
  margin: 10px 2px 0;
  font-family: var(--font-v2-display);
  font-size: 0.64rem;
  line-height: 1.4;
}

@media (max-width: 520px) {
  body.ui-version-v2 .credits-settings-summary {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 5px 12px;
  }

  body.ui-version-v2 .credits-settings-summary p {
    text-align: left;
  }

  body.ui-version-v2 .credits-history-item {
    gap: 7px;
    padding-inline: 5px;
  }

  body.ui-version-v2 .credits-history-copy,
  body.ui-version-v2 .credits-history-amount {
    gap: 4px;
  }

  body.ui-version-v2 .credits-pricing-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-block: 9px;
  }
}

body.ui-version-v2 :is(
  #assetLibrary .sandcat-menu,
  #characterCatalogModal .sandcat-select-menu
)::backdrop {
  background: var(--menu-scrim);
}

/* A route whose endpoint dropped its model keeps its red state in the v2 palette. */
body.ui-version-v2 .status-model-trigger.is-model-unavailable,
body.ui-version-v2 .model-routing-card.is-model-unavailable .model-routing-card-route,
body.ui-version-v2 .model-picker-selection.is-model-unavailable,
body.ui-version-v2 .model-picker-item.is-unavailable {
  color: var(--error);
}

body.ui-version-v2 .message-model-step-live {
  color: var(--ink-secondary);
  font-family: var(--font-v2-display);
  font-size: calc(0.58rem + 1px + 1pt);
  font-weight: 500;
  line-height: 1.4;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal) {
  background: rgba(0, 0, 0, 0.58);
}

body.ui-version-v2 #settingsModal .settings-modal {
  width: min(1040px, 94vw);
  max-width: 1040px;
  height: min(760px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  transform: none;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #assetLibrary) .modal-header {
  padding: 0 10px 0 18px;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #assetLibrary, #adminAccessDialog) .modal-header h2 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
}

body.ui-version-v2 #settingsModal .modal-body {
  display: grid;
  min-height: 0;
  grid-template-columns: 250px minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
}

body.ui-version-v2 #settingsModal .settings-mobile-selector {
  display: none;
}

body.ui-version-v2 #settingsModal .settings-tabs {
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  margin: 0;
  padding: 18px 14px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  border-radius: 0;
  background: color-mix(in srgb, var(--bg-subtle) 48%, transparent 52%);
  overscroll-behavior: contain;
}
body.ui-version-v2 #settingsModal .settings-nav-group {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  border: 0;
}

body.ui-version-v2 #settingsModal .settings-nav-group h3 {
  margin: 5px 8px 3px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
}

body.ui-version-v2 #settingsModal .settings-nav-group:first-child h3 {
  margin-top: 0;
}

body.ui-version-v2 #settingsModal .settings-tab {
  width: 100%;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-elevated) 72%, transparent 28%);
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: left;
}

body.ui-version-v2 #settingsModal .settings-tab:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

body.ui-version-v2 #settingsModal .settings-tab.active {
  border-color: color-mix(in srgb, var(--accent-primary) 64%, var(--border-default) 36%);
  background: color-mix(in srgb, var(--accent-muted) 45%, var(--bg-subtle) 55%);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

/* Models opens a sub-view rather than a panel. */
body.ui-version-v2 #settingsModal .settings-tab-drill::after {
  content: '›';
  float: right;
  color: var(--text-muted);
}

body.ui-version-v2 #settingsModal .settings-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-column: 2;
  grid-row: 1;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer {
  min-height: 60px;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 16px;
  background: var(--bg-elevated);
}

body.ui-version-v2 #guestAccountPrompt {
  width: min(430px, calc(100vw - 32px));
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
}

body.ui-version-v2 #guestAccountPrompt .modal-body {
  padding: 20px 18px 22px;
}

body.ui-version-v2 #guestAccountPrompt .guest-account-prompt-copy {
  max-width: 34ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.6;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer button,
body.ui-version-v2 #settingsModal .account-settings-panel :is(.btn-primary, .btn-danger) {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer button,
body.ui-version-v2 #settingsModal .account-settings-panel :is(.btn-primary, .btn-danger),
body.ui-version-v2 #studioPage .writer-action-buttons button {
  font-size: 0.74rem;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer .btn-primary,
body.ui-version-v2 #settingsModal .account-settings-panel .btn-primary,
body.ui-version-v2 .chat-empty-actions .btn-primary {
  border-color: color-mix(in srgb, var(--accent-primary) 66%, var(--border-default) 34%);
  background: var(--accent-muted);
  color: var(--accent-primary);
  font-weight: 650;
}

body.ui-version-v2 #settingsModal .account-settings-panel .btn-danger {
  border-color: var(--error);
  background: var(--error-muted);
  color: var(--error);
  font-weight: 650;
}

body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer button:hover,
body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #guestAccountPrompt, #userIdentityModal, #chatRenameDialog, #adminAccessDialog) .modal-footer button:focus-visible,
body.ui-version-v2 #settingsModal .account-settings-panel .btn-primary:is(:hover, :focus-visible) {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  outline: none;
}

/* Access edit dialogs keep Delete apart from Cancel and Save. */
body.ui-version-v2 #adminAccessDialog .modal-footer .admin-access-delete {
  margin-right: auto;
  color: var(--error);
}

body.ui-version-v2 #adminAccessDialog .modal-footer .admin-access-delete:is(:hover, :focus-visible) {
  border-color: var(--error);
  color: var(--error);
}

body.ui-version-v2 #adminAccessDialog .modal-footer button:disabled {
  cursor: default;
  opacity: 0.45;
}

body.ui-version-v2 #settingsGeneral > .setting-group,
body.ui-version-v2 #settingsModal .account-settings-panel > .setting-group {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-subtle) 56%, transparent 44%);
}

body.ui-version-v2 #settingsModal .account-storage-section + .account-storage-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

body.ui-version-v2 #settingsModal .account-storage-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.015em;
}

body.ui-version-v2 #settingsModal .account-storage-section-heading::before {
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent-primary);
  content: '';
}

body.ui-version-v2 #settingsModal .account-storage-section-heading::after {
  height: 1px;
  flex: 1 1 auto;
  background: color-mix(in srgb, var(--border-default) 72%, transparent 28%);
  content: '';
}

body.ui-version-v2 #settingsModal .account-storage-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 0;
  color: var(--text-primary);
}

body.ui-version-v2 #settingsModal .account-storage-total span,
body.ui-version-v2 #settingsModal .account-storage-clear-size {
  color: var(--text-muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

body.ui-version-v2 #settingsModal .account-storage-meter {
  height: 5px;
  margin: 6px 0 8px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-subtle);
}

body.ui-version-v2 #settingsModal .account-storage-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-primary);
}

body.ui-version-v2 #settingsModal .account-storage-clear-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}


body.ui-version-v2 #settingsModal .account-storage-clear-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 31px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-subtle);
}

body.ui-version-v2 #settingsModal .account-storage-clear-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-version-v2 #settingsModal .account-storage-clear-row > button {
  min-height: 25px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.72rem;
}

body.ui-version-v2 #settingsModal .account-storage-clear-empty {
  padding: 5px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

body.ui-version-v2 #settingsModal :is(.account-storage-reclaiming, .account-storage-over-limit) {
  margin: 6px 0 0;
  font-size: 0.74rem;
  line-height: 1.35;
}

body.ui-version-v2 #settingsModal .account-storage-over-limit {
  color: var(--error);
}

@media (max-width: 560px) {
  body.ui-version-v2 #settingsModal .account-storage-clear-row {
    gap: 6px;
  }
}

body.ui-version-v2 #settingsModal .setting-input,
body.ui-version-v2 #settingsModal .setting-textarea {
  border-color: var(--border-subtle);
  border-radius: 6px;
}

@media (max-width: 768px) {
  body.ui-version-v2 .status-right {
    flex: 0 1 auto;
    margin-left: auto;
  }

  body.ui-version-v2 .status-model-control {
    width: auto;
    max-width: 64vw;
  }

  body.ui-version-v2 #statusModel {
    max-width: calc(42vw - 28px);
  }

  body.ui-version-v2 #settingsModal .settings-modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  body.ui-version-v2 :is(#settingsModal, #characterCatalogModal, #assetLibrary) .modal-header {
    padding-right: calc(11px + var(--safe-right));
    padding-left: calc(11px + var(--safe-left));
  }

  body.ui-version-v2 #settingsModal .modal-body {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 0;
  }

  body.ui-version-v2 #settingsModal .settings-tabs {
    display: none;
  }

  body.ui-version-v2 #settingsModal .settings-mobile-selector {
    display: flex;
    min-width: 0;
    max-width: min(190px, 52vw);
    flex: 0 1 190px;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  body.ui-version-v2 #settingsModal .settings-mobile-selector > span {
    flex: 0 0 auto;
  }

  body.ui-version-v2 #settingsModal .settings-mobile-selector > .sandcat-select {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  body.ui-version-v2 #settingsModal .settings-mobile-selector .sandcat-select-trigger {
    min-height: 36px;
    padding: 6px 7px 6px 9px;
    border-color: var(--border-default);
    border-radius: 7px;
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
  }

  body.ui-version-v2 #settingsModal #settingsSectionSelect-menu {
    max-height: min(520px, calc(100dvh - 72px));
  }

  body.ui-version-v2 #settingsModal .settings-panel {
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    padding: 14px calc(12px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(12px + var(--safe-left));
    overflow-y: auto;
    scrollbar-gutter: auto;
  }

  body.ui-version-v2 #settingsModal .modal-footer {
    padding-right: calc(12px + var(--safe-right));
    padding-bottom: calc(10px + var(--safe-bottom));
    padding-left: calc(12px + var(--safe-left));
  }
}

/* The opening character story is one mobile transcript card. Its portrait is
   identity, not a full-height rail, so the premise and details keep the full
   reading width and the whole card leaves with the transcript. */
@media (max-width: 768px) {
  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: repeat(5, auto);
    width: calc(100% - 24px - var(--safe-left) - var(--safe-right));
    min-height: 0;
    margin: 10px auto 8px;
    padding: 16px;
    column-gap: 14px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--ink-primary) 13%, transparent);
    border-radius: 8px;
    background: var(--surface-default);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-character-portrait {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: start;
    width: 72px;
    height: 92px;
    border: var(--portrait-outline);
    border-radius: 5px;
    background-position: 50% 24%;
    box-shadow: 5px 5px 0 var(--portrait-offset);
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-character-portrait:not([role="img"]) {
    display: none;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero:has(> .v2-character-portrait:not([role="img"])) {
    grid-template-columns: minmax(0, 1fr);
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-character-kicker,
  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .chat-header-title,
  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .chat-header-meta {
    grid-column: 2;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero:has(> .v2-character-portrait:not([role="img"])) :is(
    .v2-character-kicker,
    .chat-header-title,
    .chat-header-meta
  ) {
    grid-column: 1;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-character-kicker {
    grid-row: 1;
    align-self: end;
    font-size: 0.57rem;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .chat-header-title {
    grid-row: 2;
    align-self: center;
    margin-top: 3px;
    font-size: 1.5rem;
    line-height: 1.08;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .chat-header-meta {
    grid-row: 3;
    align-self: start;
    margin-top: 5px;
    font-size: 0.7rem;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-character-description {
    grid-column: 1 / -1;
    grid-row: 4;
    margin: 15px 0 0;
    color: var(--ink-primary);
    font-size: 0.91rem;
    line-height: 1.45;
  }

  body.ui-version-v2 .messages-container > .chat-header.v2-character-hero .v2-hero-badges {
    grid-column: 1 / -1;
    grid-row: 5;
    margin-top: 11px;
  }

}

/* Boosts has one dashboard and one contextual settings level. */

body.ui-version-v2 #v2BoostsHeadingHost :is(.v2-boost-catalog-add, .v2-boost-expand-all) {
  display: inline-grid;
  width: 30px;
  height: 30px;
  min-width: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
}

body.ui-version-v2 #v2BoostsHeadingHost .v2-boost-catalog-add svg {
  width: 18px;
  height: 18px;
}

body.ui-version-v2 #v2BoostsHeadingHost :is(.v2-boost-catalog-add, .v2-boost-expand-all):is(:hover, :focus-visible):not(:disabled) {
  background: color-mix(in srgb, var(--ink-primary) 8%, transparent);
  color: var(--ink-primary);
  outline: 0;
}

body.ui-version-v2 .v2-boost-expand-all svg {
  width: 18px;
  height: 18px;
  transition: transform 160ms ease;
}

body.ui-version-v2 .v2-boost-expand-all[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

body.ui-version-v2 .v2-boost-expand-all:disabled {
  opacity: 0.4;
  cursor: default;
}

body.ui-version-v2 .v2-boost-settings-done {
  display: inline-flex;
  height: 28px;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 30%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--lime-strong) 8%, transparent);
  color: var(--lime-default);
  font: 600 0.72rem/1 var(--font-interface);
  cursor: pointer;
}

body.ui-version-v2 :is(.v2-boost-settings-done, .v2-boost-expand-all, .v2-boost-catalog-add)[hidden] {
  display: none !important;
}

body.ui-version-v2 .main-layout > .v2-memory-sidebar:not(.collapsed) {
  display: flex;
  flex-direction: column;
  overflow: visible;
}

body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle,
body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle:is(:hover, :focus-visible) {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 12;
  display: grid;
  width: 24px;
  height: 58px;
  min-height: 0;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--lime-strong);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: color-mix(in srgb, var(--surface-default) 96%, transparent);
  box-shadow: -5px 6px 14px rgba(0, 0, 0, 0.34);
  color: var(--ink-secondary);
  transform: translate(-100%, -50%);
}

body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle:is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--lime-strong) 56%, transparent);
  background: var(--surface-muted);
  color: var(--lime-default);
  outline: 0;
}

body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle svg {
  width: 17px;
  height: 17px;
  transition: transform 160ms ease;
}

body.ui-version-v2 :is(.v2-memory-rail-label, .v2-memory-rail-count) {
  display: none;
}

body.ui-version-v2 .v2-boost-dashboard-heading {
  position: relative;
  display: block;
  min-width: 0;
}

body.ui-version-v2 .v2-boost-card-settings {
  display: grid;
  width: 30px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-secondary);
}

body.ui-version-v2 .v2-boost-dashboard-heading > .v2-boost-card-settings {
  position: absolute;
  top: 50%;
  right: 2px;
  z-index: 2;
  transform: translateY(-50%);
}

body.ui-version-v2 .v2-boost-card-settings svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

body.ui-version-v2 .v2-boost-card-settings:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--ink-primary) 8%, transparent);
  color: var(--lime-default);
  outline: 0;
}

body.ui-version-v2 .v2-boost-dashboard-card[data-enabled="false"] {
  border-color: color-mix(in srgb, var(--ink-primary) 7%, transparent);
  background: color-mix(in srgb, var(--surface-default) 50%, transparent);
}

body.ui-version-v2 .v2-boost-dashboard-card[data-enabled="false"] [data-boost-dashboard-expand] {
  opacity: 0.72;
}

/* Dashboard rows share one surface at every width; only the detail is nested. */
body.ui-version-v2 .v2-boost-pane {
  padding-right: 0;
}

body.ui-version-v2 :is(.v2-boost-dashboard-list, .v2-boost-setup-list) {
  padding-right: 6px;
}

body.ui-version-v2 .v2-boost-dashboard-list {
  gap: 8px;
}

body.ui-version-v2 .v2-boost-dashboard-card,
body.ui-version-v2 .v2-boost-dashboard-card[data-enabled="false"] {
  border: 1px solid color-mix(in srgb, var(--ink-secondary) 18%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-default) 80%, transparent);
  cursor: pointer;
}

body.ui-version-v2 .v2-boost-dashboard-card:is(:hover, :focus-within) {
  border-color: color-mix(in srgb, var(--lime-strong) 34%, transparent);
}

body.ui-version-v2 .v2-boost-dashboard-card[data-open="true"] {
  border-color: color-mix(in srgb, var(--lime-strong) 44%, transparent);
  background: color-mix(in srgb, var(--surface-default) 90%, transparent);
}

body.ui-version-v2 .v2-boost-dashboard-heading {
  padding: 0;
}

body.ui-version-v2 [data-boost-dashboard-expand] {
  width: 100%;
  min-height: 68px;
  padding: 8px 42px 8px 9px;
  border: 0;
  background: var(--surface-muted);
  box-shadow: none;
  transition: background 140ms ease, box-shadow 140ms ease;
}

body.ui-version-v2 [data-boost-dashboard-expand]:is(:hover, :focus-visible),
body.ui-version-v2 .v2-boost-dashboard-card[data-open="true"] [data-boost-dashboard-expand] {
  background: var(--accent-muted);
  box-shadow: none;
}

body.ui-version-v2 .v2-boost-dashboard-card[data-enabled="false"] [data-boost-dashboard-expand] {
  background: var(--surface-muted);
  box-shadow: none;
}

body.ui-version-v2 .v2-boost-dashboard-detail {
  padding: 10px 8px 12px;
  border-top: 1px solid color-mix(in srgb, var(--ink-primary) 10%, transparent);
  background: color-mix(in srgb, var(--surface-canvas) 58%, transparent);
}

@media (min-width: 769px) {
  body.ui-version-v2 .main-layout > .v2-memory-sidebar:not(.collapsed) {
    padding-right: 0;
    padding-left: 9px;
  }

  body.ui-version-v2 .v2-memory-sidebar:not(.collapsed) > .v2-memory-heading {
    margin-right: 0;
    margin-left: -9px;
  }
}

body.ui-version-v2 .v2-boost-settings-copy {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 4px;
  padding: 10px 9px;
}

body.ui-version-v2 .v2-boost-settings-copy strong {
  color: var(--ink-primary);
  font-family: var(--font-v2-display);
  font-size: 0.76rem;
  font-weight: 650;
}

body.ui-version-v2 .v2-boost-settings-copy p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-boost-setup-summary {
  padding-right: 10px;
}

body.ui-version-v2 .v2-boost-setup-details {
  padding-top: 2px;
}

@media (min-width: 769px) {
  body.ui-version-v2 .v2-memory-sidebar {
    position: relative;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle {
    display: none;
  }

}

@media (max-width: 768px) {
  body.ui-version-v2 .status-bar {
    padding: 0;
  }

  body.ui-version-v2 .status-bar-inner {
    gap: 8px;
  }

  body.ui-version-v2 .status-left {
    flex: 0 0 auto;
  }

  body.ui-version-v2 .status-right {
    flex: 1 1 auto;
    min-width: 0;
    gap: 2px;
  }

  body.ui-version-v2 .status-context-control {
    flex: 1 1 88px;
    min-width: 64px;
    max-width: 132px;
    margin: 0;
  }

  body.ui-version-v2 .status-model-control {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  body.ui-version-v2 .status-model-trigger {
    width: 100%;
    justify-content: flex-end;
  }

  body.ui-version-v2 .cloud-save-details {
    bottom: calc(var(--statusbar-height) + 7px + var(--safe-bottom) + var(--vv-bottom));
    max-height: calc(var(--vh, 1vh) * 100 - var(--statusbar-height) - 20px);
    overflow-y: auto;
  }

  body.ui-version-v2 .status-context-overlay {
    position: fixed;
    right: calc(8px + var(--safe-right));
    bottom: calc(var(--statusbar-height) + 7px + var(--safe-bottom));
    width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
    max-height: calc(var(--vh, 1vh) * 100 - var(--statusbar-height) - 20px);
    overflow-y: auto;
    transform: translateY(5px);
  }

  body.ui-version-v2 .status-context-overlay.is-open {
    transform: none;
  }

  body.ui-version-v2 .messages-container::-webkit-scrollbar {
    width: 3px;
  }

  body.ui-version-v2 .messages-container {
    scrollbar-width: thin;
    scrollbar-color: auto;
  }

  body.ui-version-v2 .messages-container::-webkit-scrollbar-thumb {
    border: 0;
    background: color-mix(in srgb, var(--lime-strong) 58%, transparent);
    background-clip: border-box;
  }
}

@media (max-width: 768px) {
  body.ui-version-v2 {
    --v2-memory-peel-rail-width: 19.8px;
  }

  body.ui-version-v2 .top-bar-inner > .v2-sticky-header-integrated {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.ui-version-v2 .main-layout > .v2-memory-sidebar {
    width: 100%;
    min-width: 0;
    padding-right: 0;
    padding-left: calc(7px + var(--v2-memory-peel-rail-width));
    border-left: 0;
  }

  body.ui-version-v2 .main-layout > .v2-memory-sidebar:not(.collapsed) {
    overflow: hidden;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle,
  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle:is(:hover, :focus-visible) {
    top: 0;
    left: 0;
    display: grid;
    width: var(--v2-memory-peel-rail-width);
    height: 100%;
    min-height: 100%;
    place-items: center;
    padding: 0;
    border: 0;
    border-right: 1px solid color-mix(in srgb, var(--ink-primary) 5.5%, transparent);
    border-radius: 0;
    background: color-mix(in srgb, var(--surface-muted) 92%, var(--ink-primary));
    box-shadow: none;
    color: var(--ink-secondary);
    transform: none;
  }

  /* Keep the transparent 33px tap extension while painting only the 19.8px
     rail. The extension fits inside the existing content gutter. */
  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 33px;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle:is(:hover, :focus-visible) {
    border: 0;
    background: color-mix(in srgb, var(--surface-muted) 86%, var(--ink-primary));
    color: var(--ink-primary);
    outline: 0;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle svg {
    width: 16px;
    height: 16px;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-rail-toggle svg path {
    stroke-width: 3.6;
  }

  body.ui-version-v2 .v2-memory-sidebar > .v2-memory-heading {
    margin: 0 0 4px -7px;
  }

  body.ui-version-v2 [data-boost-dashboard-expand] {
    min-height: 72px;
  }

  body.ui-version-v2 .v2-memory-backdrop {
    display: none;
  }

}
@media (min-width: 769px) {
  body.ui-version-v2 .v2-mobile-memory-toggle {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2 .v2-sticky-header,
  body.ui-version-v2 .main-layout > .v2-memory-sidebar,
  body.ui-version-v2 .main-layout > .v2-memory-sidebar.collapsed,
  body.ui-version-v2 .main-layout.v2-rail-exiting > .v2-memory-sidebar,
  body.ui-version-v2.v2-memory-open .main-layout > .v2-memory-sidebar,
  body.ui-version-v2 .v2-memory-backdrop,
  body.ui-version-v2.v2-memory-open .v2-memory-backdrop,
  body.ui-version-v2 .v2-memory-rail-toggle svg {
    transition: none;
  }
}

body.ui-version-v2 #v2StoryAssistantTitle {
  line-height: 1.1;
  transform: translateY(1px);
}

body.ui-version-v2 .v2-story-assistant-dock button,
body.ui-version-v2 .v2-story-assistant-card button,
body.ui-version-v2 .v2-boost-ask-assistant {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--lime-strong) 25%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 7%, transparent);
  color: var(--lime-default);
  font: 600 0.7rem/1.25 var(--font-v2-display);
}

body.ui-version-v2 .v2-story-assistant-card {
  min-width: 0;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 12%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-canvas) 42%, transparent);
  overflow-wrap: anywhere;
}

body.ui-version-v2 .v2-story-assistant-card > :first-child {
  margin-top: 0;
}

body.ui-version-v2 .v2-story-assistant-card > :last-child {
  margin-bottom: 0;
}

body.ui-version-v2 .v2-story-assistant-card p,
body.ui-version-v2 .v2-story-assistant-card ul {
  margin: 7px 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

body.ui-version-v2 .v2-story-assistant-card small {
  color: var(--ink-secondary);
  font-size: 0.66rem;
  line-height: 1.4;
}

body.ui-version-v2 .v2-story-assistant-actions {
  margin: 9px 0 0;
}

body.ui-version-v2 .v2-story-assistant-card-actions {
  display: flex;
  margin-top: 9px;
}

body.ui-version-v2 .v2-story-assistant-card-actions[hidden] {
  display: none;
}

body.ui-version-v2 .v2-story-assistant-card-actions button {
  min-height: 30px;
  padding: 6px 10px;
}

body.ui-version-v2 .v2-story-assistant-amendment[data-status="applied"] {
  border-color: color-mix(in srgb, var(--success) 27%, transparent);
}

body.ui-version-v2 .v2-story-assistant-amendment[data-status="stale"] {
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}

body.ui-version-v2 .v2-story-assistant-error {
  color: var(--error);
}

body.ui-version-v2 .v2-boost-ask-assistant {
  width: 100%;
  min-height: 32px;
  margin-top: 9px;
  padding: 7px 9px;
}

body.ui-version-v2 :is(
  .v2-story-assistant-dock button,
  .v2-story-assistant-card button,
  .v2-boost-ask-assistant
):is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--lime-strong) 48%, transparent);
  background: color-mix(in srgb, var(--lime-strong) 13%, transparent);
  color: var(--lime-default);
  outline: 0;
}

body.ui-version-v2 :is(
  .v2-story-assistant-dock button,
  .v2-story-assistant-card button,
  .v2-boost-ask-assistant
):disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

body.ui-version-v2 #modelPickerOverlay.is-assistant-child {
  z-index: 1400;
}

/* Settings → Models swaps the Settings window for the model window in place:
 * Settings stays open underneath, hidden. Neither window animates in either
 * direction, so no frame shows the page behind or both windows at once. */
body.ui-version-v2 #settingsModal.is-drilled {
  visibility: hidden;
  transition: none;
}

body.ui-version-v2 #settingsModal.is-surfacing,
body.ui-version-v2 #modelPickerOverlay.is-settings-child,
body.ui-version-v2 #modelPickerOverlay.is-settings-child .model-picker-modal {
  transition: none;
  animation: none;
}

/* The workspace is built and loaded out of sight before it replaces Settings;
 * opacity (not visibility) also hides descendants that set their own visibility. */
body.ui-version-v2 #modelPickerOverlay.is-preparing {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 768px) {
  body.ui-version-v2 .model-picker-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    transition-property: opacity, visibility;
  }

  body.ui-version-v2 .model-picker-modal {
    position: relative;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    min-height: 0;
    flex: 1 1 auto;
    border: 0;
    border-radius: 0;
    transform: none;
  }

  body.ui-version-v2 .model-picker-modal {
    --model-picker-header-height: var(--topbar-height);
  }

  body.ui-version-v2 .model-picker-modal > .model-picker-modal-header {
    --chat-font-scale: min(var(--chat-interface-font-scale, 1), calc(15 / 14));
    position: relative;
    z-index: 2;
    min-height: var(--model-picker-header-height);
    height: var(--model-picker-header-height);
    flex: 0 0 var(--model-picker-header-height);
    padding: 0 calc(4px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  }

  body.ui-version-v2 .model-picker-modal .model-picker-modal-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  body.ui-version-v2 .model-picker-modal .model-picker-header-leading {
    flex: 1 1 auto;
  }

  body.ui-version-v2 .model-picker-modal .model-picker-modal-title {
    overflow: hidden;
    font-size: 0.875rem;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.ui-version-v2 .model-picker-editor > .model-picker-selection-row {
    flex: 0 0 auto;
    padding: 10px calc(12px + var(--safe-right)) 10px calc(12px + var(--safe-left));
  }

  body.ui-version-v2 .model-picker-editor > .model-picker-selection-row .model-picker-selection {
    margin: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  body.ui-version-v2 .v2-story-assistant-message,
  body.ui-version-v2 .v2-story-assistant-card,
  body.ui-version-v2 .v2-story-assistant-action-list button {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

/* One blank-Studio introduction for the signed-in canvas and the public
   arrival. CREATE names the mode; the sentence names only real create kinds. */
.studio-arrival{max-width:560px;margin:0 auto;pointer-events:auto}
.studio-arrival-kicker{display:inline-flex;align-items:center;justify-content:center;min-height:22px;padding:0 8px;border:1px solid color-mix(in srgb,var(--lime-default) 42%,transparent);border-radius:999px;background:color-mix(in srgb,var(--lime-default) 12%,transparent);color:var(--lime-default);font:750 .62rem/1 var(--font-interface);letter-spacing:.14em;text-transform:uppercase}
.studio-arrival-title{margin:12px 0 10px;color:var(--ink-primary);font:600 1.4rem/1.3 var(--font-v2-display,var(--font-interface))}
.studio-arrival-copy{max-width:46ch;margin:0 auto;color:var(--ink-muted);font-size:.82rem;line-height:1.55;text-align:center}
.studio-arrival-actions{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:14px;margin-top:22px}
#guestStudioArrival .studio-arrival-kicker{font:750 .62rem/1 var(--font-interface);letter-spacing:.14em}
#guestStudioArrival .studio-arrival-title{margin:12px 0 10px;font:600 1.45rem/1.3 var(--font-v2-display,var(--font-interface))}
#guestStudioArrival .studio-arrival-copy{margin-inline:auto;font-size:.82rem}
.guest-create-menu{position:fixed;inset:auto;min-width:260px}
.guest-create-menu:popover-open{display:flex;flex-direction:column}

/* The chatless guest page is Studio's front door. One authored example stays
 * secondary and opens directly; public discovery belongs to the Chat entrance. */
body.ui-version-v2 .chat-entry { display: none; }
body.ui-version-v2 .chat-entry:not([hidden]) {
  position: absolute;
  top: 44%;
  left: 50%;
  z-index: 2;
  display: block;
  width: min(720px, calc(100% - 48px));
  margin: 0;
  transform: translate(-50%, -50%);
  color: var(--ink-primary);
  text-align: center;
  pointer-events: none;
}
body.ui-version-v2.guest-studio-arrival #guestStudioArrival {
  position: fixed;
}
body.ui-version-v2 .chat-entry h2 { margin: 0 0 10px; font: 600 1.2rem/1.4 var(--font-v2-display); }
body.ui-version-v2 .chat-entry p { margin: 0; color: var(--ink-muted); font-size: .8rem; line-height: 1.55; }
body.ui-version-v2 .chat-entry .chat-entry-start { margin-top: 8px; }
body.ui-version-v2 .chat-entry .chat-entry-studio-note {
  margin-top: 18px;
  font-size: calc(.8rem - 1pt);
}
body.ui-version-v2 .chat-entry-studio-link {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  padding: 2px 8px;
  border: 0;
  border-radius: 5px;
  background: var(--lime-strong);
  color: var(--lime-strong-on);
  font-family: inherit;
  font-size: inherit;
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
}
body.ui-version-v2 .chat-entry-studio-link:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--lime-strong) 86%, white);
  color: var(--lime-strong-on);
}
body.ui-version-v2 .chat-entry-studio-link:focus-visible {
  outline: 2px solid var(--lime-default);
  outline-offset: 2px;
}
body.ui-version-v2.guest-workspace .chat-entry-account,
body.ui-version-v2:not(.guest-workspace) .chat-entry-guest { display: none; }
body.ui-version-v2 .chat-entry-guest {
  max-width: 560px;
  margin: 0 auto;
  pointer-events: auto;
}
body.ui-version-v2 .chat-entry-guest > p {
  max-width: 540px;
  margin-right: auto;
  margin-left: auto;
}
body.ui-version-v2 .guest-entry-primary {
  margin-top: 22px;
}
body.ui-version-v2 .guest-entry-studio {
  min-height: 42px;
  padding: 0 19px;
  border: 1px solid var(--lime-strong);
  border-radius: 7px;
  background: var(--lime-strong);
  color: var(--lime-strong-on);
  font: 650 .8rem/1 var(--font-interface);
  cursor: pointer;
}
body.ui-version-v2 .guest-entry-studio:is(:hover, :focus-visible) {
  background: color-mix(in srgb, var(--lime-strong) 86%, white);
}
body.ui-version-v2 .guest-entry-studio:focus-visible {
  outline: 2px solid var(--lime-default);
  outline-offset: 3px;
}
body.ui-version-v2 .guest-entry-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  color: var(--ink-muted);
  font: 500 .75rem/1.4 var(--font-interface);
}
body.ui-version-v2 .guest-entry-link {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 42%, transparent);
  text-underline-offset: 3px;
  cursor: pointer;
}
body.ui-version-v2 .guest-entry-link:is(:hover, :focus-visible) {
  color: var(--lime-default);
  text-decoration-color: currentColor;
}
body.ui-version-v2 .guest-entry-link:focus-visible {
  outline: 2px solid var(--lime-default);
  outline-offset: 2px;
}
body.ui-version-v2 .guest-header-account {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-primary);
  font: 600 .72rem/1 var(--font-interface);
  cursor: pointer;
}
body.ui-version-v2 .guest-header-account:is(:hover, :focus-visible) {
  border-color: var(--lime-default);
  color: var(--lime-default);
}
body.ui-version-v2:not(.guest-workspace) .guest-header-account { display: none !important; }

/* Settings is one shell control at the far right of the active mode's footer.
 * The no-chat guest launcher keeps the same control as a floating corner action. */
body.ui-version-v2 .shell-settings-button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  margin-left: 2px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  text-decoration: none;
  cursor: pointer;
}
body.ui-version-v2 .shell-settings-button[hidden] { display: none; }
body.ui-version-v2 .shell-settings-button svg { width: 16px; height: 16px; }
body.ui-version-v2 .shell-settings-button:is(:hover, :focus-visible) {
  color: var(--lime-default);
  background: color-mix(in srgb, var(--lime-default) 10%, transparent);
  outline: none;
}
body.ui-version-v2.guest-workspace.v2-no-chat #statusBar {
  overflow: visible;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
body.ui-version-v2.guest-workspace.v2-no-chat #statusBar .status-bar-inner > :not(.shell-settings-button) { display: none !important; }
body.ui-version-v2.guest-workspace.v2-no-chat .shell-settings-button {
  position: fixed;
  right: calc(16px + var(--safe-right, 0px));
  bottom: calc(16px + var(--safe-bottom, 0px));
  z-index: 5;
  width: 40px;
  height: 40px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  border-radius: 50%;
  background: var(--surface-default);
  color: var(--ink-primary);
}
body.ui-version-v2.guest-workspace.v2-no-chat .shell-settings-button svg { width: 20px; height: 20px; }
body.ui-version-v2.guest-workspace.v2-no-chat .shell-settings-button:is(:hover, :focus-visible) {
  border-color: var(--lime-default);
  background: var(--surface-default);
}

/* Guest Settings is one troubleshooting action, not a disabled projection of
 * account preferences. The signed-in modal keeps its full tabbed composition. */
body.ui-version-v2 #settingsModal.guest-settings-only .settings-modal {
  width: min(520px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100dvh - 32px);
}
body.ui-version-v2 #settingsModal.guest-settings-only .modal-body {
  display: block;
  min-height: 0;
  padding: 0;
}
body.ui-version-v2 #settingsModal.guest-settings-only :is(.settings-tabs, .settings-mobile-selector, .modal-footer),
body.ui-version-v2 #settingsModal.guest-settings-only #settingsGeneral > .setting-group:not(.site-cache-setting) {
  display: none;
}
body.ui-version-v2 #settingsModal.guest-settings-only .settings-panel {
  grid-column: 1;
  grid-row: 1;
  height: auto;
  min-height: 0;
  padding: 18px;
}
body.ui-version-v2 #settingsModal.guest-settings-only #settingsGeneral > .site-cache-setting {
  margin: 0;
}
body.ui-version-v2.guest-workspace.v2-no-chat {
  --statusbar-height: 0px;
}
body.ui-version-v2.guest-workspace.v2-no-chat #sidebar,
body.ui-version-v2.guest-workspace.v2-no-chat #sidebarOverlay,
body.ui-version-v2.guest-workspace.v2-no-chat #menuToggleBtn,
body.ui-version-v2.guest-workspace.v2-no-chat .v2-sticky-character,
body.ui-version-v2.guest-workspace.v2-no-chat .input-area {
  display: none !important;
}
body.ui-version-v2.guest-workspace:not(.v2-no-chat) #statusBar .status-context-control,
body.ui-version-v2.guest-workspace:not(.v2-no-chat) #statusBar .status-right,
body.ui-version-v2.guest-workspace #composerAddControl,
body.ui-version-v2.guest-workspace .composer-boost-badge,
body.ui-version-v2.guest-workspace .v2-memory-sidebar,
body.ui-version-v2.guest-workspace .v2-memory-backdrop,
body.ui-version-v2.guest-workspace #shellPanelToggle,
body.ui-version-v2.v2-no-chat .composer-boost-badge { display: none !important; }
body.ui-version-v2 .chat-list.is-empty { display:grid; place-items:center; padding-block:6px; }
body.ui-version-v2 .chat-list-empty { max-width:190px; padding:10px 8px; font-size:.72rem; line-height:1.45; text-align:center; }
body.ui-version-v2 .chat-entry[hidden],
body.ui-version-v2 .v2-chat-search[hidden],
body.ui-version-v2 .v2-chat-view-control[hidden],
body.ui-version-v2 #statusContextControl[hidden],
body.ui-version-v2 .v2-sticky-header[hidden] { display: none !important; }
@media (min-width: 769px) {
  body.ui-version-v2.guest-workspace:not(.v2-no-chat) .guest-header-account { display: none; }
}
@media (max-width: 768px) {
  body.ui-version-v2 #settingsModal.guest-settings-only .settings-modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  body.ui-version-v2 .chat-entry:not([hidden]) { top: 48%; width: calc(100% - 32px); }
  body.ui-version-v2 .guest-entry-primary { margin-top: 20px; }
  body.ui-version-v2 .guest-entry-links { gap: 10px; margin-top: 24px; }
  body.ui-version-v2 .guest-header-account { min-height: 34px; }
}

/* One dock, two views. Swapping views never changes the transcript's track. */
body.ui-version-v2 .main-layout > .v2-memory-sidebar:not(.collapsed) {
  width: var(--v2-memory-track);
  min-width: var(--v2-memory-track);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* One-row panel header: segmented section switch, section actions, Close. */
.v2-side-panel-heading { box-sizing:border-box; display:flex; align-items:center; gap:4px; flex:none; height:45px; padding:0 0 0 8px; border-bottom:1px solid var(--line-default); background:var(--surface-muted); font-family:var(--font-interface); }
.panel-segments { display:inline-flex; flex:0 1 auto; min-width:0; gap:2px; margin-right:auto; padding:2px; border-radius:8px; background:color-mix(in srgb,var(--ink-primary) 7%,transparent); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--ink-primary) 5%,transparent); }
.panel-segments [role=tab] { position:relative; display:inline-flex; align-items:center; gap:6px; min-width:0; height:28px; padding:0 10px; border:0; border-radius:6px; background:transparent; color:var(--ink-secondary); font:600 .75rem/1 var(--font-interface); white-space:nowrap; cursor:pointer; transition:background-color 120ms ease,color 120ms ease,box-shadow 120ms ease; }
.panel-segments [role=tab] > span:first-of-type { min-width:0; overflow:hidden; text-overflow:ellipsis; }
.panel-segments [role=tab] svg { flex:none; width:15px; height:15px; }
.panel-segments [role=tab]:hover:not([aria-selected=true]) { color:var(--ink-primary); }
.panel-segments [aria-selected=true] { background:var(--surface-default); color:var(--ink-primary); box-shadow:0 1px 2px rgb(0 0 0 / .16),0 0 0 1px color-mix(in srgb,var(--ink-primary) 9%,transparent); }
.panel-segments [aria-selected=true] svg { color:var(--lime-default); }
.panel-segments [role=tab]:focus-visible { outline:2px solid var(--lime-default); outline-offset:1px; }
.panel-tab-count { flex:none; box-sizing:border-box; min-width:16px; height:16px; padding:0 4px; border-radius:8px; background:color-mix(in srgb,var(--lime-default) 18%,transparent); color:var(--lime-default); font:700 .6rem/16px var(--font-interface); text-align:center; }
.panel-tab-count:empty { display:none; }
/* Working/New stays readable to assistive technology; sighted users see one dot. */
.panel-tab-status { flex:none; width:7px; height:7px; overflow:hidden; border-radius:50%; background:var(--lime-default); color:transparent; font-size:0; }
.panel-tab-status[hidden] { display:none; }
#v2AssistantHeadingHost,#v2BoostsHeadingHost { display:contents; }
#v2AssistantHeadingHost[hidden],#v2BoostsHeadingHost[hidden],#v2AssistantFooterHost[hidden] { display:none!important; }
#v2BoostsSlot,#v2WorldSlot { display:flex; flex:1; flex-direction:column; min-height:0; overflow:auto; padding:8px 15px 14px; }
#v2AssistantSlot { flex:1; min-width:0; min-height:0; display:flex; overflow:hidden; }
#v2AssistantSlot[hidden],#v2BoostsSlot[hidden],#v2WorldSlot[hidden] { display:none!important; }
/* World: a read-only audit of the saved checkpoint, dense and copyable. */
#v2WorldSlot { gap:12px; font-family:var(--font-interface); font-size:.75rem; color:var(--ink-secondary); }
.v2-world-meta { margin:0; color:var(--ink-muted); font-size:.7rem; }
.v2-world-section { display:grid; gap:6px; }
.v2-world-heading { margin:0; color:var(--ink-primary); font:600 .72rem/1.3 var(--font-interface); text-transform:uppercase; letter-spacing:.04em; }
.v2-world-entity { display:grid; gap:4px; padding:8px 10px; border:1px solid var(--line-default); border-radius:8px; background:var(--surface-default); }
.v2-world-entity-title { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px; }
.v2-world-entity-title strong { color:var(--ink-primary); font-size:.78rem; }
.v2-world-entity-title code,.v2-world-field dd code { color:var(--ink-muted); font-size:.68rem; }
.v2-world-chip { padding:0 6px; border-radius:6px; background:color-mix(in srgb,var(--lime-default) 16%,transparent); color:var(--lime-default); font-size:.64rem; font-weight:600; line-height:16px; }
.v2-world-fields { display:grid; gap:3px; margin:0; }
.v2-world-field { display:grid; grid-template-columns:72px minmax(0,1fr); gap:8px; }
.v2-world-field dt { color:var(--ink-muted); }
.v2-world-field dd { margin:0; color:var(--ink-primary); overflow-wrap:anywhere; }
.v2-world-none { margin:0; color:var(--ink-muted); }
.v2-world-changes { margin:0; padding-left:16px; display:grid; gap:2px; color:var(--ink-primary); }
.v2-world-raw summary { cursor:pointer; color:var(--ink-muted); }
.v2-world-raw pre { margin:6px 0 0; padding:8px; max-height:320px; overflow:auto; border-radius:6px; background:var(--surface-muted); color:var(--ink-primary); font:.68rem/1.4 var(--font-mono,ui-monospace,monospace); white-space:pre-wrap; overflow-wrap:anywhere; user-select:text; }
#v2AssistantSlot #studioAssistant { width:100%; height:100%; flex:1; border:0; position:relative; inset:auto; padding:0; transform:none; visibility:visible; pointer-events:auto; transition:none; }
#v2AssistantSlot #studioAssistant > .studio-scrim { display:none; }
@media(max-width:768px) {
  body.ui-version-v2 .main-layout > .v2-memory-sidebar:not(.collapsed) { width:100%; min-width:0; padding-left:var(--v2-mobile-close-width,19.8px); }
}
/* Mobile: the open panel covers the app bar, so its app-bar-height row starts
   with the current section's icon/caret, followed by the title block and the
   section's actions. Its standard menu lists the available sections.
   The full-height peel rail closes the panel; Close is desktop-only. */
.v2-side-panel-identity, .v2-section-switcher { display:none; }
#v2SectionMenu { position:fixed; inset:auto; margin:0; }
@media (max-width: 768px) {
  .v2-side-panel-heading { height:var(--topbar-height); gap:2px; padding:0 calc(4px + var(--safe-right)) 0 10px; }
  .v2-side-panel-identity { display:flex; flex:1 1 auto; min-width:0; margin-right:4px; --title-block-kicker-size:.47rem; --title-block-title-size:.88rem; }
  .v2-side-panel-heading > :is(.panel-segments,[data-side-panel-close]) { display:none!important; }
  body.ui-version-v2 :is(#v2AssistantHeadingHost,#v2BoostsHeadingHost) :is(#studioThreadTrigger,.studio-thread-new,.v2-boost-catalog-add,.v2-boost-expand-all) { width:36px; min-width:36px; height:36px; }
  body.ui-version-v2 :is(#v2AssistantHeadingHost,#v2BoostsHeadingHost) :is(#studioThreadTrigger,.studio-thread-new,.v2-boost-catalog-add,.v2-boost-expand-all) svg { width:24px; height:24px; }
  .v2-section-switcher { position:relative; display:inline-flex; flex:none; order:-1; align-items:center; gap:3px; height:30px; margin-right:2px; padding:0 7px; border:1px solid color-mix(in srgb,var(--ink-primary) 16%,transparent); border-radius:999px; background:var(--surface-strong); color:var(--ink-primary); cursor:pointer; }
  .v2-section-switcher > svg { width:20px; height:20px; color:var(--lime-default); }
  .v2-section-switcher > .disclosure-caret { color:var(--lime-default); }
  .v2-section-switcher:is(:hover,[aria-expanded="true"]) { border-color:color-mix(in srgb,var(--lime-default) 34%,transparent); background:color-mix(in srgb,var(--lime-default) 10%,var(--surface-strong)); }
  .v2-section-switcher:focus-visible { outline:2px solid var(--lime-default); outline-offset:1px; }
  /* The Assistant's working/unread dot stays visible on the switcher while its tab is folded into the menu. */
  .v2-side-panel-heading:has([data-assistant-tab-status]:not([hidden])) .v2-section-switcher::after { content:''; position:absolute; top:-2px; right:-2px; width:7px; height:7px; border-radius:50%; background:var(--lime-default); }
}

/* Each vertical lane owns its own bottom row. The Chat status bar ends with the
   canvas; Assistant's controls stay inside the right panel. */
body.ui-version-v2 .status-bar-inner { position:relative; height:100%; }
#v2AssistantFooterHost {
  position:static;
  display:flex;
  width:100%;
  min-width:0;
  min-height:var(--statusbar-height);
  height:var(--statusbar-height);
  flex:0 0 var(--statusbar-height);
  border-top:1px solid var(--line-default);
  background:var(--surface-default);
}
@media(min-width:769px) {
  /* While the Assistant shows, its own footer carries Credits. */
  body.ui-version-v2 #statusBar[data-side-panel=assistant] #statusCreditsTrigger { display:none; }
}
body.ui-version-v2 .chat-sidebar-close-rail { display:none; }
@media(max-width:768px) {
  body.ui-version-v2 {
    --chat-sidebar-close-width: 19.8px;
  }
  body.ui-version-v2 .sidebar {
    bottom: 0;
    z-index: 150;
    width: 100%;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    padding-right: var(--chat-sidebar-close-width);
    border-right: 0;
    overscroll-behavior: none;
    touch-action: pan-y;
  }
  body.ui-version-v2 .chat-sidebar-close-rail,
  body.ui-version-v2 .chat-sidebar-close-rail:is(:hover,:focus-visible) {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 36;
    display: block;
    width: 33px;
    height: 100%;
    min-height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--ink-secondary);
    cursor: pointer;
    outline: none;
  }
  body.ui-version-v2 .chat-sidebar-close-rail::before {
    position: absolute;
    inset: 0 0 0 auto;
    width: var(--chat-sidebar-close-width);
    border-left: 1px solid color-mix(in srgb, var(--ink-primary) 5.5%, transparent);
    background: color-mix(in srgb, var(--surface-muted) 92%, var(--ink-primary));
    content: '';
  }
  body.ui-version-v2 .chat-sidebar-close-rail:is(:hover,:focus-visible)::before {
    background: color-mix(in srgb, var(--surface-muted) 86%, var(--ink-primary));
  }
  body.ui-version-v2 .chat-sidebar-close-rail svg {
    position: absolute;
    top: calc(50% - 8px);
    right: calc((var(--chat-sidebar-close-width) - 16px) / 2);
    width: 16px;
    height: 16px;
    color: currentColor;
    pointer-events: none;
    transform: rotate(180deg);
  }
  body.ui-version-v2 .chat-sidebar-close-rail:is(:hover,:focus-visible) {
    color: var(--ink-primary);
  }
  body.ui-version-v2 #statusBar:is([data-side-panel=boosts],[data-side-panel=world],[data-side-panel=assistant]) :is(#statusContextControl,.status-right) { display:none!important; }
}

@media (max-width: 360px) {
  body.ui-version-v2 .composer-boost-active {
    display: none;
  }
}

/* Read/Chat focus mode keeps one compact shell header and turns both persistent
 * desktop columns into temporary drawers. Phone geometry is already drawer-first. */
body.ui-version-v2 .shell-focus-toggle[aria-pressed="true"] {
  background: transparent;
  color: var(--ink-primary);
}

/* Focus removes the fixed chrome bands instead of merely widening their
 * contents. The live canvas owns the viewport; only existing actions remain as
 * floating corner controls, and Read's existing footer controls float over the
 * page without reserving a row. */
body.ui-version-v2.shell-focus-mode .main-layout {
  top: 0;
  height: 100dvh;
  max-height: 100dvh;
  max-width: none;
}
body.ui-version-v2.shell-focus-mode .top-bar {
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}
body.ui-version-v2.shell-focus-mode .top-bar-inner {
  max-width: none;
  pointer-events: none;
}
body.ui-version-v2.shell-focus-mode .top-bar :is(.app-title,.mr-header,.v2-sticky-header) {
  display: none !important;
}
body.ui-version-v2.shell-focus-mode #appHeaderActions > :not(#shellFocusToggle):not(#shellPanelToggle) {
  display: none !important;
}
body.ui-version-v2.shell-focus-mode :is(#shellFocusToggle,#shellPanelToggle) {
  border: 1px solid color-mix(in srgb, var(--ink-primary) 14%, transparent);
  background: color-mix(in srgb, var(--surface-default) 94%, transparent);
  box-shadow: 0 4px 14px rgb(0 0 0 / .24);
  color: var(--ink-primary);
  pointer-events: auto;
}
body.ui-version-v2.shell-focus-mode #menuToggleBtn {
  width: 36px;
  height: 36px;
  aspect-ratio: 1;
  flex: 0 0 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}
body.ui-version-v2.shell-focus-mode #menuToggleBtn svg {
  width: 28px;
  height: 28px;
  flex: none;
}
body.ui-version-v2.shell-focus-mode #menuToggleBtn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
body.ui-version-v2.shell-focus-mode:not(.manuscript-reader-open) .status-bar {
  display: none;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open .manuscript-reader-page {
  padding-block-start: max(48px, clamp(18px, calc(5vh - 8px), 48px));
}

body.ui-version-v2.shell-focus-mode.manuscript-reader-open .status-bar {
  position: fixed;
  inset: calc(4px + var(--safe-top)) auto auto 50%;
  width: max-content;
  max-width: calc(100vw - 16px);
  height: auto;
  min-height: var(--statusbar-height);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);
  pointer-events: none;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open .status-bar-inner {
  width: max-content;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 0;
  gap: 4px;
  background: transparent;
  pointer-events: none;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open
  .status-bar-inner > :is(.status-left,.mr-rail,#shellSettingsButton) {
  pointer-events: auto;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open .status-left {
  max-width: none;
  overflow: visible;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open .mr-rail {
  flex: 0 1 auto;
  gap: 4px;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open
  :is(#shellModeToggle,.mr-chapters-button,.mr-icon-button,#shellSettingsButton) {
  box-sizing: border-box;
  height: 32px;
  min-width: 32px;
  border: 1px solid color-mix(in srgb, var(--ink-primary) 18%, transparent);
  background: color-mix(in srgb, var(--surface-default) 94%, transparent);
  box-shadow: 0 2px 8px rgb(0 0 0 / .18);
  color: var(--ink-primary);
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open #shellModeToggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-radius: 999px;
  font: 650 .64rem/1 var(--font-interface);
  cursor: pointer;
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open #shellSettingsButton {
  width: 32px;
  margin: 0;
}
body.ui-version-v2.shell-focus-mode .mr-preview-dock {
  display: none;
}
body.ui-version-v2.shell-focus-mode .preview-rail {
  left: max(56px, calc(8px + var(--safe-left)));
  right: max(96px, calc(8px + var(--safe-right)));
}
body.ui-version-v2.shell-focus-mode.manuscript-reader-open .mr-menu-scrim {
  inset: calc(var(--statusbar-height) + 16px + var(--safe-top)) 0 0;
}

@media (max-width: 420px) {
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open .status-bar {
    left: calc(50% - 22px);
  }
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open .status-bar-inner,
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open .mr-rail {
    gap: 3px;
  }
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open .mr-chapters-button {
    width: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 6px;
  }
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open .mr-chapters-icon {
    display: block;
  }
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open
    .mr-chapters-button :is(.mr-picker-number,.mr-picker-label,.mr-caret) {
    display: none;
  }
  body.ui-version-v2.shell-focus-mode.manuscript-reader-open #shellModeToggle {
    padding-inline: 6px;
  }
}
@media (min-width: 769px) {
  body.ui-version-v2.shell-focus-mode .main-layout {
    max-width: none;
  }
  body.ui-version-v2.shell-focus-mode .sidebar {
    --chat-sidebar-close-width: 20px;
    position: fixed;
    top: var(--topbar-height);
    bottom: var(--statusbar-height);
    left: 0;
    z-index: 150;
    width: min(320px, calc(100vw - 44px));
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    margin-left: 0 !important;
    padding-right: var(--chat-sidebar-close-width);
    overflow: hidden;
    visibility: hidden;
    transform: translateX(-105%);
    pointer-events: none;
    transition: transform var(--transition-normal), visibility 0s linear 200ms;
  }
  body.ui-version-v2.shell-focus-mode .sidebar.open {
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    transition: transform var(--transition-normal), visibility 0s;
  }
  body.ui-version-v2.shell-focus-mode .sidebar-overlay.active {
    display: block !important;
  }
  body.ui-version-v2.shell-focus-mode .chat-sidebar-close-rail,
  body.ui-version-v2.shell-focus-mode .chat-sidebar-close-rail:is(:hover,:focus-visible) {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 36;
    display: block;
    width: 33px;
    height: 100%;
    min-height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--ink-secondary);
    cursor: pointer;
    outline: none;
  }
  body.ui-version-v2.shell-focus-mode .sidebar:not(.open) .chat-sidebar-close-rail {
    visibility: hidden;
    pointer-events: none;
  }
  body.ui-version-v2.shell-focus-mode .chat-sidebar-close-rail::before {
    position: absolute;
    inset: 0 0 0 auto;
    width: var(--chat-sidebar-close-width);
    border-left: 1px solid color-mix(in srgb, var(--ink-primary) 5.5%, transparent);
    background: color-mix(in srgb, var(--surface-muted) 92%, var(--ink-primary));
    content: '';
  }
  body.ui-version-v2.shell-focus-mode .chat-sidebar-close-rail svg {
    position: absolute;
    top: calc(50% - 8px);
    right: calc((var(--chat-sidebar-close-width) - 16px) / 2);
    width: 16px;
    height: 16px;
    color: currentColor;
    pointer-events: none;
    transform: rotate(180deg);
  }
  body.ui-version-v2.shell-focus-mode .v2-memory-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0;
    z-index: 104;
    display: block;
    border: 0;
    border-radius: 0;
    background: color-mix(in srgb, var(--surface-canvas) 67%, transparent);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 170ms ease-out, visibility 0s linear 170ms;
  }
  body.ui-version-v2.shell-focus-mode.v2-memory-open .v2-memory-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 170ms ease-out, visibility 0s;
  }
  body.ui-version-v2.shell-focus-mode .main-layout > .v2-memory-sidebar,
  body.ui-version-v2.shell-focus-mode .main-layout > .v2-memory-sidebar.collapsed,
  body.ui-version-v2.shell-focus-mode .main-layout.v2-rail-exiting > .v2-memory-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 105;
    display: flex;
    width: min(360px, calc(100vw - 44px));
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    flex: 0 0 min(360px, calc(100vw - 44px));
    height: 100%;
    margin-left: 0;
    padding: 0;
    visibility: hidden;
    transform: translateX(105%);
    pointer-events: none;
    transition: transform 190ms ease-out, visibility 0s linear 190ms;
  }
  body.ui-version-v2.shell-focus-mode.v2-memory-open .main-layout > .v2-memory-sidebar {
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    transition: transform 190ms ease-out, visibility 0s;
  }
  body.ui-version-v2.shell-focus-mode .v2-side-panel-heading > [data-side-panel-close] {
    display: grid;
    flex: 0 0 32px;
  }
  body.ui-version-v2.shell-focus-mode .v2-side-panel-heading > .panel-segments {
    min-width: 0;
    overflow: hidden;
  }
  body.ui-version-v2.shell-focus-mode:has(#sidebar.open) .top-bar
    :is(#appTitleText, #helpTitleText, .shell-opening-title, .v2-sticky-header, #appHeaderActions) {
    display: none !important;
  }
  body.ui-version-v2.shell-focus-mode:has(#sidebar.open) .app-drawer-title {
    display: block;
    color: var(--ink-primary);
    font: 600 .95rem/1.2 var(--font-v2-display);
    white-space: nowrap;
  }
}
body.ui-version-v2.shell-focus-mode .sidebar {
  top: 0;
  bottom: 0;
}
body.ui-version-v2.shell-focus-mode .v2-memory-backdrop {
  inset: 0;
}

@media (prefers-reduced-motion: reduce) {
  body.ui-version-v2.shell-focus-mode :is(.sidebar,.v2-memory-sidebar,.v2-memory-backdrop) {
    transition-duration: 1ms !important;
  }
}
