/* -------- App shell ------------------------------------------------- */
.app {
  display: grid;
  /* Two rows: optional project-instructions bar (auto — collapses to 0
   * when hidden) and the chat/workspace split (1fr — fills the remaining
   * viewport). The standalone chrome header row was removed; its contents
   * moved into the chat pane (project title + design-system picker) and the
   * Design Files tab row (settings / handoff / present / share / avatar).
   * The split gets explicit `grid-row: 2` below so the layout works whether
   * the instructions bar is rendered or returns null. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  height: 100vh;
  background: var(--bg-app);
  overflow: hidden;
}
.app > .split {
  grid-row: 2;
}

.workspace-shell {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 36px minmax(0, 1fr);
  background: var(--bg-app);
  overflow: hidden;
}
.workspace-shell__body {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.workspace-shell__body > .app,
.workspace-shell__body > .entry-shell {
  height: 100%;
  min-height: 0;
}

.iframe-keep-alive-pool {
  display: none;
}

.pooled-iframe-host {
  display: contents;
}

.workspace-tabs-chrome.app-chrome-header {
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  height: 38px;
  padding: 0 8px 0 6px;
  gap: 0;
  background: color-mix(in srgb, var(--bg-panel) 88%, var(--bg-subtle));
  border-bottom: 0;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--bg-panel) 80%, transparent) inset;
  user-select: none;
  -webkit-app-region: drag;
  overflow: hidden;
  position: relative;
  z-index: 120;
}
.workspace-tabs-chrome.app-chrome-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: color-mix(in srgb, var(--border) 64%, transparent);
  transform: scaleY(0.5);
  transform-origin: center bottom;
  pointer-events: none;
  z-index: 0;
}
.workspace-tabs-chrome .workspace-tabs-traffic {
  margin-right: var(--app-chrome-traffic-margin);
}
.workspace-tabs-new-btn {
  width: 28px;
  height: 28px;
  margin-left: 5px;
  margin-right: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  -webkit-app-region: no-drag;
  transition: background 100ms ease, color 100ms ease;
}
.workspace-tabs-strip.is-overflowing .workspace-tabs-new-btn {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg-panel);
  box-shadow: -8px 0 10px -9px color-mix(in srgb, var(--text) 30%, transparent);
}
.workspace-tabs-new-btn:hover {
  background: color-mix(in srgb, var(--bg-panel) 72%, var(--bg-subtle));
  color: var(--text-muted);
}
.workspace-tabs-icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  -webkit-app-region: no-drag;
}
.workspace-tabs-icon-btn:hover:not(:disabled),
.workspace-tabs-icon-btn.is-active {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--bg-panel) 78%, var(--bg-subtle));
  border-color: var(--border);
}
.workspace-tabs-strip {
  align-self: stretch;
  min-width: 0;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 0;
  padding-left: 0;
  position: relative;
  z-index: 1;
  /* Horizontal scroll inside the strip — tabs keep their natural width
     and the strip itself scrolls when it overflows the chrome. This
     replaces the previous "slice to N visible + overflow chip" model
     which let lots of tabs squish-shrink and could push the rest of
     the chrome out of view. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  contain: layout style;
  -webkit-app-region: drag;
  /* Allow the user's trackpad / shift-wheel to scroll horizontally
     without the OS turning it into a back-gesture. */
  overscroll-behavior-x: contain;
}
.workspace-tabs-strip::-webkit-scrollbar {
  height: 0;
  display: none;
}
.workspace-tab {
  position: relative;
  height: 24px;
  /* Fixed width — never shrink. The strip scrolls when the tabs
     don't fit anymore. */
  width: 156px;
  flex: 0 0 156px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  overflow: visible;
  contain: layout style;
  transition-property: background, border-color, color, opacity, transform, box-shadow;
  transition-duration: 100ms, 100ms, 100ms, 120ms, 150ms, 150ms;
  transition-timing-function: ease, ease, ease, ease, cubic-bezier(0.2, 0.8, 0.2, 1), ease;
  -webkit-app-region: no-drag;
  cursor: default;
  z-index: 1;
  will-change: transform;
}
.workspace-tab.is-dragging {
  opacity: 0.88;
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--text) 14%, transparent);
  cursor: default;
  z-index: 3;
}
.workspace-tab.is-drag-over-before,
.workspace-tab.is-drag-over-after {
  background: color-mix(in srgb, var(--bg-panel) 84%, var(--bg-subtle));
  border-color: color-mix(in srgb, var(--border-strong) 42%, transparent);
  color: var(--text);
}
.workspace-tab.is-drag-over-before {
  transform: translateX(6px);
}
.workspace-tab.is-drag-over-after {
  transform: translateX(-6px);
}
.workspace-tab + .workspace-tab::before {
  display: none;
}
.workspace-tab:hover {
  background: color-mix(in srgb, var(--bg-panel) 64%, transparent);
  border-color: color-mix(in srgb, var(--border) 60%, transparent);
  color: var(--text);
}
.workspace-tab.is-active {
  background: color-mix(in srgb, var(--bg-panel) 92%, var(--bg-subtle));
  border-color: color-mix(in srgb, var(--border-strong) 52%, transparent);
  color: var(--text-strong);
  box-shadow: 0 1px 1px color-mix(in srgb, var(--text) 6%, transparent);
}
.workspace-tab:hover::before,
.workspace-tab:hover + .workspace-tab::before,
.workspace-tab:focus-within::before,
.workspace-tab:focus-within + .workspace-tab::before,
.workspace-tab.is-active::before,
.workspace-tab.is-active + .workspace-tab::before {
  opacity: 0;
}
.workspace-tab__main {
  min-width: 0;
  height: 100%;
  padding: 0 6px 0 9px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: left;
  cursor: inherit;
}
.workspace-tab__main:hover:not(:disabled) {
  background: transparent;
  border-color: transparent;
}
.workspace-tab__icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  opacity: 0.74;
  flex: 0 0 auto;
  line-height: 0;
}
.workspace-tab__icon svg,
.workspace-tab__close svg,
.workspace-tabs-icon-btn svg {
  display: block;
  flex: none;
}
.workspace-tab__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 520;
  letter-spacing: 0;
}
.workspace-tab__close {
  width: 18px;
  height: 18px;
  margin-right: 4px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.workspace-tab:hover .workspace-tab__close,
.workspace-tab.is-active .workspace-tab__close {
  opacity: 1;
}
.workspace-tab__close:hover {
  color: var(--text);
  background: var(--bg-subtle);
}
.workspace-tabs-actions {
  position: relative;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: 4px;
  padding-left: 2px;
  z-index: 35;
  -webkit-app-region: no-drag;
}
.workspace-tabs-popover {
  /* Anchored to the viewport, not to .workspace-tabs-actions, because the
     actions group sits next to the tab strip on the left side of the chrome
     header — not the right. `position: absolute; right: 0` against that
     narrow inline-flex container made the 380px popover hang off the left
     edge of the window. Fixed positioning keeps it inside the viewport
     regardless of where the actions group lands as tabs accumulate. */
  position: fixed;
  top: calc(var(--workspace-tabs-chrome-height, 38px) + 7px);
  right: max(10px, env(safe-area-inset-right));
  width: min(380px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - var(--workspace-tabs-chrome-height, 38px) - 24px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 130;
  -webkit-app-region: no-drag;
}
.workspace-tabs-popover,
.workspace-tabs-popover * {
  -webkit-app-region: no-drag;
}
.workspace-tabs-search {
  height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--selected);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text-muted);
  box-shadow: 0 0 0 3px var(--selected-soft);
}
.workspace-tabs-search input {
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 13px;
}
.workspace-tabs-search input:focus {
  border: 0;
  box-shadow: none;
}
.workspace-tabs-popover__section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 5px 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0;
}
.workspace-tabs-list {
  min-height: 0;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  contain: layout style paint;
}
.workspace-tabs-list__item {
  min-height: 34px;
  border-radius: 7px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  contain: layout style;
}
.workspace-tabs-list__item:hover,
.workspace-tabs-list__item.is-active {
  background: color-mix(in srgb, var(--selected) 9%, var(--bg-subtle));
}
.workspace-tabs-list__main {
  min-width: 0;
  height: 34px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
}
.workspace-tabs-list__main:hover:not(:disabled) {
  background: transparent;
  border-color: transparent;
}
.workspace-tabs-list__icon {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
.workspace-tabs-list__icon svg,
.workspace-tabs-list__close svg,
.workspace-tabs-search svg {
  display: block;
  flex: none;
}
.workspace-tabs-list__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.workspace-tabs-list__title,
.workspace-tabs-list__meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-tabs-list__title {
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 600;
}
.workspace-tabs-list__meta {
  color: var(--text-muted);
  font-size: 11px;
}
.workspace-tabs-list__close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.workspace-tabs-list__close:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-muted);
}
.workspace-tabs-empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}
.workspace-tab-preview {
  position: fixed;
  z-index: 140;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  animation: workspace-tab-preview-in 130ms cubic-bezier(0.23, 1, 0.32, 1);
}
.workspace-tab-preview__icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.workspace-tab-preview__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.workspace-tab-preview__title {
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.workspace-tab-preview__meta {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.3;
}
.workspace-tab-preview__detail {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
@keyframes workspace-tab-preview-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 720px) {
  .workspace-tabs-chrome.app-chrome-header {
    padding-right: 6px;
  }
  .workspace-tab {
    min-width: 40px;
    max-width: 44px;
    flex-basis: 44px;
    grid-template-columns: 1fr;
    padding: 0;
  }
  .workspace-tab__main {
    justify-content: center;
    padding: 0;
  }
  .workspace-tab__label,
  .workspace-tab__close {
    display: none;
  }
}

.app-chrome-header {
  --app-chrome-traffic-space: 0px;
  --app-chrome-traffic-margin: 0px; /* Set to 8px on macOS */
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 12px;
  flex-shrink: 0;
}
.app-chrome-traffic-space {
  width: var(--app-chrome-traffic-space);
  flex: 0 0 var(--app-chrome-traffic-space);
  /* Add extra spacing after the traffic light controls on macOS so project
     navigation starts after the native window controls. */
  margin-right: var(--app-chrome-traffic-margin);
}
.app-chrome-back,
.settings-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-chrome-back:hover:not(:disabled),
.settings-icon-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text);
}
.app-chrome-content {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  align-self: stretch;
  flex: 1 1 auto;
}
.app-chrome-drag {
  min-width: 24px;
  flex: 1 1 auto;
  align-self: stretch;
}
.app-chrome-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.app-chrome-file-actions-before {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.app-chrome-file-actions-before:has(> [data-app-chrome-file-actions='true']:empty),
.app-chrome-file-actions:empty {
  display: none;
}
.app-chrome-file-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.app-chrome-file-actions-before:not(:empty) + .app-chrome-file-actions:not(:empty) {
  margin-left: 4px;
}
.app-chrome-file-actions:not(:empty) + .app-chrome-actions,
.app-chrome-file-actions-before:not(:has(> [data-app-chrome-file-actions='true']:empty)):not(:empty) + .app-chrome-file-actions + .app-chrome-actions {
  position: relative;
  margin-left: 4px;
  padding-left: 12px;
}
.app-chrome-file-actions:not(:empty) + .app-chrome-actions::before,
.app-chrome-file-actions-before:not(:has(> [data-app-chrome-file-actions='true']:empty)):not(:empty) + .app-chrome-file-actions + .app-chrome-actions::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  width: 1px;
  height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 82%, transparent);
  transform: translateY(-50%);
}
.chrome-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.chrome-action svg {
  display: block;
}
.chrome-action > svg:first-child {
  transform: translateY(1px);
}
.chrome-action:hover:not(:disabled) {
  background: var(--bg-subtle);
}
.chrome-action-secondary {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
}
.chrome-action-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border);
}
.chrome-file-action-menus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chrome-action-with-label {
  gap: 8px;
}
.present-trigger[aria-expanded='true'] {
  background: var(--bg-panel);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.chrome-action-primary {
  background: var(--text-strong);
  border-color: var(--text-strong);
  color: var(--bg);
}
.chrome-action-primary:hover:not(:disabled) {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chrome-action-export {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 24%, transparent);
}
.chrome-action-export:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}
.chrome-action-export:focus-visible {
  outline-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.chrome-action-export.export-ready-nudge {
  animation: export-ready-nudge 1600ms cubic-bezier(0.23, 1, 0.32, 1) 1;
}
.chrome-share-menu .share-menu-popover,
.chrome-present-wrap .present-menu {
  top: calc(100% + 6px);
  right: 0;
}
.zoom-menu { position: relative; display: inline-block; }
.zoom-menu .zoom-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.viewer-toolbar-zoom .zoom-trigger:focus-visible {
  outline: none;
  box-shadow: none;
}
.zoom-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 110px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.viewer-toolbar-zoom .zoom-menu-popover {
  left: auto;
  right: 0;
  transform: none;
}
.zoom-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}
.zoom-menu-item:hover { background: var(--bg-subtle); }
.zoom-menu-item.active { color: var(--accent-strong); font-weight: 600; }
@media (max-width: 880px) {
  .chrome-action-secondary span { display: none; }
  .chrome-action-secondary { padding: 0 10px; }
}
@media (max-width: 720px) {
  .app-chrome-content { display: none; }
}
.viewer.is-tab-present .viewer-toolbar,
.viewer.is-tab-present .live-artifact-refresh-notice {
  display: none;
}
.viewer.is-tab-present .viewer-body {
  inset: 0;
}
.viewer .present-exit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
}
.viewer .present-exit-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.live-artifact-preview-frame-host {
  width: 100%;
  height: 100%;
  background: var(--bg);
}
.live-artifact-preview-frame-host:fullscreen {
  background: var(--bg);
}
.project-target-platforms,
.project-feature-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: min(100%, 280px);
  height: 22px;
  overflow: hidden;
  white-space: nowrap;
  flex: 0 1 auto;
}
.project-feature-chips {
  max-width: min(100%, 260px);
}
.project-target-platforms-label,
.project-feature-chips-label {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.project-target-platform-chip,
.project-feature-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 92px;
  height: 20px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 999px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg-subtle) 88%, transparent);
  font-size: 11px;
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
.project-feature-chip.is-landing {
  color: color-mix(in srgb, var(--accent) 72%, var(--text-strong));
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-subtle));
}
.project-feature-chip.is-widgets {
  color: color-mix(in srgb, #0891b2 72%, var(--text-strong));
  border-color: color-mix(in srgb, #0891b2 26%, transparent);
  background: color-mix(in srgb, #0891b2 10%, var(--bg-subtle));
}
.project-target-platform-chip.is-count {
  min-width: 28px;
  max-width: 36px;
  flex: 0 0 auto;
  color: var(--text-strong);
  background: color-mix(in srgb, var(--accent, #7c5cff) 12%, var(--bg-subtle));
}

/* Project instructions toggle & modal */
.project-instructions-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  margin-left: 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.project-instructions-toggle:hover {
  opacity: 1;
  background: var(--bg-hover, rgba(128, 128, 128, 0.1));
}
.project-instructions-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding: min(14vh, 96px) 20px 20px;
  background: color-mix(in srgb, #0f172a 24%, transparent);
}
.project-instructions-modal {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow-lg, 0 22px 70px rgba(15, 23, 42, 0.2));
}
.project-instructions-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.project-instructions-modal-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.project-instructions-modal-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0;
}
.project-instructions-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 200ms cubic-bezier(0.23, 1, 0.32, 1),
    color 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.project-instructions-modal-close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text-muted) 9%, transparent);
}
.project-instructions-input {
  width: 100%;
  min-height: 160px;
  max-height: min(52vh, 420px);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}
.project-instructions-input:focus {
  outline: none;
  border-color: var(--accent, #646cff);
}
.project-instructions-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* Saved-state entry point: a persistent header chip that reveals the
   review panel so saved Project instructions stay discoverable (#1822). */
.project-instructions-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg-hover, rgba(128, 128, 128, 0.1));
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  max-width: 220px;
}
.project-instructions-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-instructions-chip:hover,
.project-instructions-chip.is-open {
  color: var(--text);
  border-color: var(--accent, #646cff);
}
.project-instructions-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.project-instructions-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent, #646cff);
  flex-shrink: 0;
}
.project-instructions-preview {
  width: 100%;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

/* Settings: custom instructions textarea */
.custom-instructions-input {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}
.custom-instructions-input:focus {
  outline: none;
  border-color: var(--accent, #646cff);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; flex-direction: row; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topbar .title { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .meta { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

.topbar .brand-mark {
  display: inline-flex;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-tint) 0%, var(--accent-soft) 100%);
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}
.topbar .brand-mark .brand-mark-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 1px;
  user-select: none;
  -webkit-user-drag: none;
}

.topbar-left .back-btn {
  align-self: center;
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.topbar-left .back-btn:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--border); }

/* -------- Avatar menu (replaces in-topbar agent picker) ------------- */
.avatar-menu { position: relative; }
.avatar-agent-trigger {
  width: 58px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  grid-template-columns: 32px 24px;
  align-items: center;
  justify-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 200ms cubic-bezier(0.23, 1, 0.32, 1),
    background 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.avatar-agent-trigger:hover:not(:disabled) {
  border-color: var(--border-strong, var(--border));
}
.avatar-agent-trigger > svg:last-child {
  color: var(--text-muted);
}
.avatar-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-tint) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: box-shadow 120ms ease, transform 120ms ease;
}
.avatar-btn:hover:not(:disabled) {
  box-shadow: 0 0 0 3px rgba(194, 83, 45, 0.18);
  border-color: transparent;
}
.avatar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(194, 83, 45, 0.32);
  border-color: transparent;
}
.avatar-btn:active:not(:disabled) { transform: scale(0.96); }
.avatar-btn-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.avatar-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 280px;
  padding: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
[dir='rtl'] .avatar-popover {
  right: auto;
  left: 0;
}
.avatar-popover-head {
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}
.avatar-popover-head .who { font-weight: 600; font-size: 13px; }
.avatar-popover-head .where { font-size: 11.5px; color: var(--text-muted); }
.avatar-amr-account-link,
.avatar-amr-account-link:visited {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  margin: 0 6px 6px;
  padding: 9px 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border-soft));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-tint) 34%, var(--bg-panel));
}
.avatar-amr-account-link:hover {
  background: color-mix(in srgb, var(--accent-tint) 52%, var(--bg-panel));
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}
.avatar-amr-account-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-strong);
}
.avatar-amr-account-link__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.avatar-amr-account-link__copy span:first-child {
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-amr-account-link__copy span:last-child {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font-size: 12.5px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
}
.avatar-item:hover { background: var(--bg-subtle); }
/* `<a>` items inside the popover need explicit color + decoration
   resets — the user-agent stylesheet otherwise paints them blue
   and underlined, which reads as misalignment next to the button
   rows that share the same `.avatar-item` class. */
a.avatar-item,
a.avatar-item:visited {
  color: var(--text);
}
.avatar-item .avatar-item-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: var(--text-muted);
  flex-shrink: 0;
}
.avatar-item .avatar-item-meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.avatar-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 8px 10px 4px;
}
.avatar-model-section {
  padding: 2px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px dashed var(--border-soft);
  margin-top: 4px;
}
.avatar-select-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  font-size: 12px;
  color: var(--text-muted);
}
.avatar-select-label {
  flex-shrink: 0;
  min-width: 0;
}
.avatar-select {
  display: block;
  width: 100%;
  min-width: min(340px, 100%);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
}
.avatar-select:focus { outline: 2px solid var(--accent-soft, var(--border-strong)); }

/* Environment pill — only used in entry view header now */
.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  max-width: 360px;
  min-width: 0;
  font: inherit;
  color: inherit;
}
.env-pill:hover { background: var(--bg-panel); border-color: var(--border-strong); }
.env-pill-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #d97757 0%, #b85a3b 100%);
  flex-shrink: 0;
}
.env-pill-dot[data-mode="api"] {
  background: linear-gradient(135deg, #1c1b1a 0%, #4b4948 100%);
}
.env-pill-label { font-weight: 500; font-size: 12px; }
.env-pill-meta {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* -------- Split / panes -------------------------------------------- */
.split {
  --project-chat-panel-width: 460px;
  --project-workspace-panel-track: minmax(400px, 1fr);
  display: grid;
  grid-template-columns:
    var(--project-chat-panel-width)
    8px
    var(--project-workspace-panel-track);
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: var(--bg);
}
.split.is-resizing-chat {
  cursor: col-resize;
  user-select: none;
}
.split.is-resizing-chat iframe {
  pointer-events: none;
}
.split.is-resizing-chat .workspace,
.split.is-resizing-chat .viewer,
.split.split-focus .workspace,
.split.split-focus .viewer {
  contain: layout paint;
}
.split.is-resizing-chat .html-viewer:has(.deck-nav) .preview-frame-clip,
.split.split-focus .html-viewer:has(.deck-nav) .preview-frame-clip {
  background: var(--text-strong);
}
.split.split-focus {
  grid-template-columns: minmax(0, 1fr);
}
.split-chat-slot {
  position: relative;
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.split-chat-slot[hidden] {
  display: none;
}
.split-chat-slot > .pane {
  flex: 1 1 auto;
  min-width: 0;
}
.split-edit-divider {
  width: 8px;
  min-width: 8px;
  height: 100%;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
}
.comment-left-host {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-panel);
}
.comment-left-host > .comment-side-dock {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}
.comment-left-host > .comment-side-panel,
.comment-left-host > .comment-side-dock > .comment-side-panel {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: 20;
}
.comment-left-host .comment-side-header {
  min-height: 40px;
}
.comment-left-host .comment-side-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 12px;
}
.comment-side-composer {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-panel);
  overflow: hidden;
}
.split-resize-handle {
  position: relative;
  z-index: 45;
  width: 8px;
  min-width: 8px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}
.split-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -10px;
  right: -10px;
  cursor: col-resize;
}
.split-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.5px);
  width: 1px;
  pointer-events: none;
  background: color-mix(in srgb, var(--border) 92%, transparent);
  opacity: 0.9;
  transition:
    background-color 140ms cubic-bezier(0.23, 1, 0.32, 1),
    box-shadow 140ms cubic-bezier(0.23, 1, 0.32, 1),
    opacity 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.split-resize-handle:hover,
.split-resize-handle:focus-visible,
.split.is-resizing-chat .split-resize-handle {
  background: transparent;
}
.split-resize-handle:hover::after,
.split-resize-handle:focus-visible::after,
.split.is-resizing-chat .split-resize-handle::after {
  background: color-mix(in srgb, var(--accent) 70%, var(--border));
  box-shadow: none;
  opacity: 1;
}
.split-resize-handle:focus-visible {
  outline: none;
}
