/**
 * App System Styles
 * Styles for the app.html template system (facet bar, menu bar, app bar, etc.)
 */

/* ========================================
 * Cross-Document View Transitions
 * Enables smooth page transitions in supporting browsers
 * ======================================== */
@view-transition {
  navigation: auto;
}

/* Assign transition names to persistent structural elements */
.facet-bar {
  view-transition-name: facet-bar;
}

.menu-bar {
  view-transition-name: menu-bar;
}

.app-bar {
  view-transition-name: app-bar;
}

.workspace {
  view-transition-name: workspace;
}

/* Customize transition animations */
::view-transition-old(workspace),
::view-transition-new(workspace) {
  animation-duration: 150ms;
  animation-timing-function: ease-in-out;
}

/* Other fixed elements that should persist */
.corner-tags {
  view-transition-name: corner-tags;
}

.notification-center {
  view-transition-name: notification-center;
}

.status-pane {
  view-transition-name: status-pane;
}

/* Keep structural elements stable (no animation) */
::view-transition-old(facet-bar),
::view-transition-new(facet-bar),
::view-transition-old(menu-bar),
::view-transition-new(menu-bar),
::view-transition-old(app-bar),
::view-transition-new(app-bar),
::view-transition-old(corner-tags),
::view-transition-new(corner-tags),
::view-transition-old(notification-center),
::view-transition-new(notification-center),
::view-transition-old(status-pane),
::view-transition-new(status-pane) {
  animation: none;
}

/* Universal box-sizing */
* {
  box-sizing: border-box;
}

/* Reserve scrollbar space to prevent layout shift on navigation */
html {
  scrollbar-gutter: stable;
}

/* Default theme (when no facet is selected) */
:root {
  --facet-color: #b06a1a;
  --facet-bg: transparent;
  --facet-border: var(--hairline);
  /* Semantic status palette — observer is the first consumer. */
  --status-active: var(--success);
  --status-stale: var(--warn);
  --status-error: var(--danger);
  --status-inactive: var(--ink-faint);

  /* Layout dimensions */
  --facet-bar-height: 64px;
  --menu-bar-width-minimal: 60px;
  --menu-bar-width-full: 200px;
  --app-bar-height: 60px;
  --status-pane-width: 280px;

  /* Z-index hierarchy (increasing order) */
  --z-bars: 100;          /* Facet bar, menu bar, app bar */
  --z-modals: 200;        /* Modal overlays */
  --z-notifications: 300; /* Notifications, status pane, error log */
  --z-tags: 400;          /* Corner tags - topmost layer */
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: var(--font-body);
  background: var(--cream-bright);
}

.workspace {
  margin-top: var(--facet-bar-height);
  padding-top: 8px;
  margin-left: var(--menu-bar-width-minimal);
}

body.menu-full .workspace {
  margin-left: var(--menu-bar-width-full);
}

body.has-app-bar .workspace {
  margin-bottom: calc(var(--app-bar-height) + 80px);
}

/* Standard workspace containers */
.workspace-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

.workspace-content-wide {
  padding: 1.5rem 2rem 2rem;
}

.workspace-prose {
  max-width: 72ch;
  margin-inline: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .workspace-content,
  .workspace-content-wide {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .menu-bar {
    width: 0;
    overflow: hidden;
  }

  body.menu-full .menu-bar {
    width: var(--menu-bar-width-full);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.2);
    z-index: calc(var(--z-bars) + 2);
  }

  .workspace {
    margin-left: 0 !important;
  }

  .facet-bar .facet-pills-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-bar {
    left: 8px;
    right: 8px;
    max-width: none;
    width: auto;
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-bars) + 1);
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .menu-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Facet Bar (top) */
.facet-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(var(--facet-bg, transparent), var(--facet-bg, transparent)), var(--paper);
  z-index: var(--z-bars);
  height: var(--facet-bar-height);
  padding: 14px 16px 12px 16px;
  overflow: visible;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Border as pseudo-element for selective positioning */
.facet-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--menu-bar-width-minimal);
  right: 0;
  height: 1px;
  background: var(--facet-border, #e5e0db);
  transition: left 0.3s ease, background-color 0.3s ease;  /* right is instant */
  pointer-events: none;
}

/* When sidebar open, border only where workspace is visible */
body.menu-full .facet-bar::after {
  left: var(--menu-bar-width-full);
}

/* When status pane open, stop border before it */
body:has(.status-pane.visible) .facet-bar::after {
  right: var(--status-pane-width);
}

.facet-bar #hamburger {
  display: flex;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.facet-bar #hamburger:hover {
  background: rgba(0,0,0,0.05);
}

.facet-bar #hamburger:active {
  background: rgba(0, 0, 0, 0.10);
}

.facet-bar .status-icon {
  font-size: 20px;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
  margin-left: auto;
  position: relative;
}

.facet-bar .status-icon:hover {
  background: rgba(0,0,0,0.05);
}

.facet-bar .status-icon:active {
  background: rgba(0, 0, 0, 0.10);
}

.facet-bar .status-icon[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.08);
}

.facet-bar .status-icon.error {
  box-shadow: 0 0 4px 2px red;
  border-radius: 4px;
}

/* Status indicator shapes (SVG inside .status-icon button) */
.status-indicator {
  display: block;
}

.facet-bar .status-icon .status-indicator {
  width: 22px;
  height: 22px;
}

.status-indicator--connecting {
  animation: status-spin 1.2s linear infinite;
}

@keyframes status-spin {
  to { transform: rotate(360deg); }
}

/* Status Pane - slides down from facet bar on right (mirrors menu bar on left) */
.status-pane {
  position: fixed;
  top: var(--facet-bar-height);
  right: 0;
  width: var(--status-pane-width);
  background: white;
  border-left: 1px solid var(--facet-border, #e5e0db);
  border-bottom: 1px solid var(--facet-border, #e5e0db);
  border-radius: 0 0 0 12px;  /* Only bottom-left rounded */
  /* Shadow only on left and bottom - offset down to avoid top bleed */
  box-shadow: -4px 4px 8px -2px rgba(0, 0, 0, 0.1);
  z-index: var(--z-notifications);
  overflow: hidden;  /* Clip content during animation */

  /* Slide animation */
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.25s ease;
}

.status-pane.visible {
  max-height: 400px;
  opacity: 1;
}

/* Facet-colored background tint */
.status-pane::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--facet-bg, transparent);
  border-radius: 0 0 0 12px;
  pointer-events: none;
  z-index: -1;
}

.status-pane-content {
  padding: 16px;
  max-height: 380px;
  overflow-y: auto;
}

.status-pane-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.status-pane-footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  margin: 0 -8px;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s ease;
}

.status-pane-footer-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

.status-pane-footer-link:active {
  background: rgba(0, 0, 0, 0.08);
}

/* Diagnostic console opens on the left so it can coexist with the right-side status pane. */
.diagnostic-console {
  position: fixed;
  top: var(--facet-bar-height);
  left: 0;
  width: min(520px, calc(100vw - 24px));
  background: white;
  border-right: 1px solid var(--facet-border, #e5e0db);
  border-bottom: 1px solid var(--facet-border, #e5e0db);
  border-radius: 0 0 12px 0;
  box-shadow: 4px 4px 8px -2px rgba(0, 0, 0, 0.1);
  z-index: var(--z-notifications);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.25s ease;
}

.diagnostic-console.visible {
  max-height: calc(100vh - var(--facet-bar-height) - 16px);
  opacity: 1;
}

.diagnostic-console-content {
  padding: 16px;
  max-height: calc(100vh - var(--facet-bar-height) - 48px);
  overflow-y: auto;
}

.diagnostic-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.diagnostic-console-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.diagnostic-console-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.diagnostic-console-actions button,
.diagnostic-console-entry button {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
}

.diagnostic-console-actions button:hover,
.diagnostic-console-entry button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.diagnostic-console-close {
  width: 28px;
  height: 28px;
  padding: 0;
  line-height: 1;
}

.diagnostic-console-reporting-off {
  margin: 0 0 12px;
  color: #6b7280;
  font-size: 13px;
}

.diagnostic-console-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.diagnostic-console-tabs button {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
}

.diagnostic-console-tabs button[aria-selected="true"] {
  background: rgba(0, 0, 0, 0.08);
  border-color: #9ca3af;
}

.diagnostic-console-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diagnostic-console-empty {
  margin: 12px 0 0;
  color: #6b7280;
  font-size: 13px;
}

.diagnostic-console-entry {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.diagnostic-console-entry summary {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}

.diagnostic-console-entry summary::-webkit-details-marker {
  display: none;
}

.diagnostic-console-entry-time {
  color: #9ca3af;
  font-size: 11px;
}

.diagnostic-console-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.diagnostic-console-entry-icon--error {
  background: #fee2e2;
  color: #b91c1c;
}

.diagnostic-console-entry-icon--warning {
  background: #fef3c7;
  color: #92400e;
}

.diagnostic-console-entry-icon--info {
  background: #e0f2fe;
  color: #075985;
}

.diagnostic-console-entry-source {
  color: #6b7280;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

.diagnostic-console-entry-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnostic-console-entry-toggle {
  color: #6b7280;
  font-size: 11px;
}

.diagnostic-console-entry[open] .diagnostic-console-entry-toggle {
  display: none;
}

.diagnostic-console-entry-detail {
  border-top: 1px solid #e5e7eb;
  padding: 8px;
  color: #4b5563;
  font-size: 12px;
}

.diagnostic-console-entry-detail div + div {
  margin-top: 4px;
}

.diagnostic-console-entry-detail span {
  color: #374151;
  font-weight: 600;
}

.diagnostic-console-entry-detail pre {
  margin: 4px 0 0;
  padding: 8px;
  overflow-x: auto;
  border-radius: 4px;
  background: #111827;
  color: #f9fafb;
  font-size: 11px;
  white-space: pre-wrap;
}

.status-pane-content h3 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

#status-sentence {
  font-size: 15px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: #333;
}

.status-pane-content p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.status-pane-detail {
  font-size: 13px;
  color: #9ca3af;
}

.status-pane-technical {
  font-size: 12px;
  color: #9ca3af;
}

.status-pane-history-item {
  transition: background 0.15s ease;
}

.status-pane-history-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.status-pane-history-item:active {
  background: rgba(0, 0, 0, 0.08);
}

#notif-bell {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  margin-left: 6px;
  font-size: 12px;
  transition: opacity 0.15s ease;
}

#notif-bell[data-perm="granted"] {
  opacity: 1;
  cursor: default;
}

#notif-bell[data-perm="denied"] {
  opacity: 0.4;
  cursor: default;
}

#notif-bell[data-perm="default"] {
  opacity: 0.5;
  cursor: pointer;
}

#notif-bell[data-perm="default"]:hover {
  opacity: 0.8;
}

.facet-bar .facet-pills-container {
  flex: 1;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  overflow-x: clip;
  overflow-y: visible;
  min-width: 0;  /* Allow container to shrink below content size */
}

/* Menu Bar (left sidebar) */
.menu-bar {
  position: fixed;
  top: var(--facet-bar-height);
  left: 0;
  width: var(--menu-bar-width-minimal);
  max-height: calc(100vh - var(--facet-bar-height));
  background: var(--paper);
  border-right: 1px solid var(--facet-border, #e5e0db); /* Container carries the border, not individual items */
  z-index: calc(var(--z-bars) + 1);  /* Above app bar */
  transition: width 0.3s ease, background 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
  overflow: hidden; /* Clip all content to rounded corner */
  border-bottom-right-radius: 8px;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
}

/* Scrollable container for menu items */
.menu-bar .menu-items {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;  /* Firefox */
}

ul.menu-items {
  list-style: none;
  margin: 0;
  padding: 8px 0 4px;
}

.menu-bar .menu-items::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Edge */
}

/* Scroll overflow shadows on .menu-items */
.menu-bar .menu-items::before,
.menu-bar .menu-items::after {
  content: '';
  display: block;
  position: sticky;
  left: 0;
  right: 0;
  height: 16px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.menu-bar .menu-items::before {
  top: 0;
  margin-bottom: -16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.06), transparent);
}

.menu-bar .menu-items::after {
  bottom: 0;
  margin-top: -16px;
  background: linear-gradient(to top, rgba(0,0,0,0.06), transparent);
}

.menu-bar .menu-items.scroll-shadow-top::before {
  opacity: 1;
}

.menu-bar .menu-items.scroll-shadow-bottom::after {
  opacity: 1;
}

body.menu-full .menu-bar {
  width: var(--menu-bar-width-full);
  background: linear-gradient(var(--facet-bg, transparent), var(--facet-bg, transparent)), white;
  border-right: 1px solid var(--facet-border, #e5e0db);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  border-bottom-right-radius: 0; /* Remove rounded corner when expanded */
}

.menu-bar .menu-item {
  padding: 8px 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.3s ease, max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, border-radius 0.3s ease;
  border-bottom: none;
  border-left: 3px solid transparent;
  border-right: none;
  margin-top: 2px;
  margin-left: 4px;
  margin-right: 4px;
  border-radius: 8px;
  color: inherit;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;  /* Don't compress - let container scroll instead */
}

.menu-bar .menu-item-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}


/* Hide unstarred apps in menu-minimal state */
.menu-bar .menu-item[data-starred="false"] {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  pointer-events: none;
}

/* Always show current app, even if unstarred in menu-minimal state */
.menu-bar .menu-item[data-starred="false"].current {
  max-height: 50px;
  opacity: 1;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-top: 2px;
  pointer-events: auto;
}

/* Show all apps when menu-full */
body.menu-full .menu-bar .menu-item[data-starred="false"] {
  max-height: 50px;
  opacity: 1;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-top: 2px;
  pointer-events: auto;
}

body.menu-full .menu-bar .menu-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.menu-bar .menu-item.drag-over {
  border-top: 2px solid var(--facet-color);
}

/* Keyboard reorder visual feedback */
body.menu-full .menu-bar .menu-item.reordering {
  outline: 2px dashed var(--facet-color, #b06a1a);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--facet-color, #b06a1a) 8%, transparent);
}

@keyframes boundary-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

body.menu-full .menu-bar .menu-item.boundary-hit {
  animation: boundary-shake 0.2s ease;
}

/* Apply facet background to menu items in menu-minimal state */
body:not(.menu-full) .menu-bar .menu-item {
  background: var(--facet-bg, white);
}

/* Hover state for menu items */
.menu-bar .menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.menu-bar .menu-item:active {
  background: rgba(0, 0, 0, 0.14);
}

/* Active app state - stronger background + accent bar */
.menu-bar .menu-item.current {
  background: rgba(0, 0, 0, 0.10);
  border-left-color: var(--facet-color);
}

/* In menu-minimal state, layer hover tint over facet background */
body:not(.menu-full) .menu-bar .menu-item:hover {
  background:
    linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)),
    var(--facet-bg, white);
}

body:not(.menu-full) .menu-bar .menu-item:active {
  background:
    linear-gradient(rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.14)),
    var(--facet-bg, white);
}

/* In menu-minimal state, active app with stronger tint + accent bar */
body:not(.menu-full) .menu-bar .menu-item.current {
  background:
    linear-gradient(rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.10)),
    var(--facet-bg, white);
  border-left-color: var(--facet-color);
}

.menu-bar .menu-item .icon {
  font-size: 22px;
  width: calc(var(--menu-bar-width-minimal) - 8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

body.menu-full .menu-bar .menu-item .icon { width: 36px; }
body.menu-full .menu-bar .menu-item .star-toggle,
body.menu-full .menu-bar .menu-item .drag-handle { min-width: 28px; }

.menu-bar .menu-item .icon svg,
.facet-pill .emoji svg {
  display: block;
  color: inherit;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.menu-bar .menu-item .icon svg *,
.facet-pill .emoji svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.menu-bar .menu-item .icon svg {
  width: 22px;
  height: 22px;
}

.menu-bar .menu-item .label {
  font-size: 14px;
  font-weight: 500;
  padding-right: 12px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-bar .menu-item .star-toggle {
  display: none;
  background: none;
  border: none;
  font: inherit;
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: inherit;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s ease, color 0.15s ease;
  flex-shrink: 0;
  user-select: none;
}

body.menu-full .menu-bar .menu-item .star-toggle {
  display: inline-flex;
}

/* Show star on hover or when starred */
body.menu-full .menu-bar .menu-item:hover .star-toggle,
.menu-bar .menu-item[data-starred="true"] .star-toggle {
  opacity: 1;
}

.menu-bar .menu-item .star-toggle:focus-visible {
  opacity: 1;
}

.menu-bar .menu-item .star-toggle:hover {
  opacity: 1;
  color: #f59e0b;
}

.menu-bar .menu-item .star-toggle:active {
  transform: scale(0.9);
}

.menu-bar .menu-item[data-starred="true"] .star-toggle {
  color: #f59e0b;
}

.menu-bar .menu-item[data-starred="true"] .star-toggle:hover {
  color: #d97706;
}

/* Drag handle */
.menu-bar .menu-item .drag-handle {
  display: none;
  background: none;
  border: none;
  font: inherit;
  font-size: 16px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
  user-select: none;
  color: #bbb;
}

body.menu-full .menu-bar .menu-item .drag-handle {
  display: inline-flex;
  opacity: 0.4;
}

body.menu-full .menu-bar .menu-item:hover .drag-handle {
  opacity: 1;
}

.menu-bar .menu-item .drag-handle:hover {
  opacity: 1;
  color: #666;
}

body.menu-full .menu-bar .menu-item .drag-handle:active {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  cursor: grabbing;
}

/* Visual separator after last starred app */
.menu-bar .menu-item.last-starred {
  border-bottom: 1px solid var(--facet-border, #e5e0db);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

/* Menu bar icon badges */
.menu-bar .menu-item .icon {
  position: relative;
}

@keyframes badge-pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.menu-badge {
  animation: badge-pop 0.2s ease;
  position: absolute;
  top: -2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 600;
  background: #ef4444;
  color: white;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 0 0 2px white;
  line-height: 1;
}

/* Menu expander (down arrow below last visible app icon) */
.menu-bar .menu-expander {
  min-width: 44px;
  width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 22px;
  cursor: pointer;
  color: inherit;
  border: none;
  border-right: none;
  background: var(--facet-bg, white);
  transition: background 0.2s;
  user-select: none;
  position: relative;
  border-radius: 8px;
  flex-shrink: 0;  /* Never shrink - always visible at bottom */
  margin-top: auto;
  margin-bottom: 12px;
  align-self: center;
}


.menu-bar .menu-expander:hover {
  background:
    linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)),
    var(--facet-bg, white);
}

.menu-bar .menu-expander:active {
  background:
    linear-gradient(rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.10)),
    var(--facet-bg, white);
}

/* Hide only when sidebar is menu-full (keep visible during menu-all) */
body.menu-full .menu-bar .menu-expander {
  display: none;
}

/* Show all apps in menu-all state (icons only, narrow width) */
body.menu-all .menu-bar .menu-item[data-starred="false"] {
  max-height: 50px;
  opacity: 1;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-top: 2px;
  pointer-events: auto;
}

/* Keep sidebar narrow in menu-all state (icons only) */
body.menu-all .menu-bar {
  width: var(--menu-bar-width-minimal);
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
}

/* Mobile: the menu rail collapses off-canvas. The base .menu-bar widths
   above re-expand it by source order, so re-assert the collapse here, below
   them, for every non-overlay state. menu-full stays the 200px overlay
   handled in the mobile block near the top of this file. */
@media (max-width: 768px) {
  body:not(.menu-full) .menu-bar {
    width: 0;
    border-right: 0;
    overflow: hidden;
    box-shadow: none;
    pointer-events: none;
    visibility: hidden;
  }

  body:not(.menu-full) .menu-bar .menu-items,
  body:not(.menu-full) .menu-bar .menu-expander {
    display: none;
  }
}

.facet-pill {
  appearance: none;
  font-family: inherit;
  color: inherit;
  line-height: inherit;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--pill-bg-rest, #f5f5f5);
  border: 1px solid var(--facet-border, #e5e0db);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  user-select: none;
  position: relative;
  min-width: 0;        /* Allow pill to shrink below content size */
  flex-shrink: 1;      /* Allow shrinking when space is tight */
}

.facet-pill .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;        /* Can shrink to zero width */
  flex-shrink: 1;
  user-select: none;
  pointer-events: none;
}

/* Dim unselected pills when a facet is selected */
.facet-pill:not(.selected) {
  opacity: 0.85;
}

.facet-pills-container:not(:has(.selected)) .facet-pill {
  opacity: 1;
}

/* "all" label - muted caption before first pill in all-mode */
.facet-all-label {
  font-size: 12px;
  color: #999;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  padding: 0 6px 0 0;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* Hide "all" label when a facet is selected (CSS backup for JS toggle) */
.facet-pills-container:has(.selected) .facet-all-label {
  display: none;
}

/* Empty state: no facets configured */
.facet-empty-state {
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  user-select: none;
  padding: 0 4px;
}

.facet-empty-create {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
}

.facet-empty-create:hover {
  color: #555;
}

.facet-pill:hover {
  opacity: 1;
  border-color: var(--pill-color, #999);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background: var(--pill-bg, #f5f5f5);
}

.facet-pill.selected:hover {
  background: color-mix(in srgb, var(--pill-color, var(--orange)) 22%, var(--paper));
  opacity: 1;
  border-color: var(--pill-color, var(--orange));
  transform: translateY(0);
  box-shadow: none;
}

.facet-pill.selected {
  opacity: 1;
  background: color-mix(in srgb, var(--pill-color, var(--orange)) 14%, var(--paper));
  color: var(--ink);
  border-color: var(--pill-color, var(--orange));
  font-weight: 600;
}

.facet-pill .emoji-container {
  position: relative;
  font-size: 24px;
  line-height: 1;
  margin-top: 1px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  user-select: none;
  pointer-events: none;
  flex-shrink: 0;      /* Never shrink the emoji */
}

.facet-pill .emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  line-height: 0;
  user-select: none;
  pointer-events: none;
}

.facet-pill .emoji svg {
  width: 24px;
  height: 24px;
}

.facet-pill .facet-badge {
  position: absolute;
  bottom: -3px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  font-size: 11px;
  font-weight: 600;
  background: #ef4444;
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 0 0 2px white;
  animation: badge-pop 0.2s ease;
}

.status-icon .quiet-notif-badge {
  position: absolute;
  bottom: -2px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 3px;
  font-size: 11px;
  font-weight: 600;
  background: #ef4444;
  color: white;
  box-shadow: 0 0 0 2px white;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  animation: badge-pop 0.2s ease;
}

/* Drag-and-drop states */
.facet-pill:active:not(.dragging) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.facet-pill.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: scale(1.05) rotate(2deg);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  z-index: calc(var(--z-bars) + 1); /* Above bars, below modals */
  transition: none; /* Disable transitions while dragging */
}

.facet-pill.drag-over {
  /* Subtle indicator only - actual reordering happens via DOM manipulation */
  transform: scale(0.95);
}

/* Apps without facet support - all pills identical, no selection */
.facet-bar.facets-disabled .facet-pill {
  pointer-events: none;
  cursor: default;
  opacity: 0.55;
  filter: grayscale(0.4);
}

/* chat bar + talent-view modal */
.app-bar {
  position: fixed;
  bottom: 16px;
  left: var(--menu-bar-width-minimal);
  right: 0;
  width: auto;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  z-index: var(--z-bars);
  min-height: var(--app-bar-height);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-radius: 12px;
  border: 1px solid var(--facet-border, #e5e0db);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05), 0 2px 12px rgba(0, 0, 0, 0.08);
}

.app-bar--support {
  --facet-color: #01579b;
  --facet-bg:    #0288d114;
  --facet-border:#bfe2f2;
  box-shadow: inset 3px 0 0 #0288d1, 0 -4px 12px rgba(0,0,0,.05), 0 2px 12px rgba(0,0,0,.08);
}
.chat-bar-capacity {
  flex: 1 0 100%; display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; line-height: 1.3; color: #01579b; padding-bottom: 2px;
}
.chat-bar-capacity[hidden] { display: none; }
.chat-bar-capacity-dot { width:8px; height:8px; border-radius:50%; background:#0288d1; flex:0 0 auto; animation: sol-ping-pulse 1.6s ease-in-out infinite; }
.chat-bar-capacity-route { font-weight:700; }
.chat-bar-capacity-route .cap-arrow { opacity:.6; margin:0 5px; font-weight:400; }
.chat-bar-capacity-sub { color:#5a6b78; font-weight:400; }

.chat-bar-offer {
  flex: 1 0 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.chat-bar-offer[hidden] { display: none; }
.chat-bar-offer .offer-text { font-size: 13px; color: #3a342c; line-height: 1.4; }
.offer-actions { display: flex; gap: 8px; }
.offer-btn { font: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; cursor: pointer; border: 1px solid; }
.offer-btn--yes { background: #01579b; border-color: #01579b; color: #fff; }
.offer-btn--no  { background: transparent; border-color: #d8d0c2; color: #6b6258; }
.offer-btn:focus-visible { outline: 2px solid #01579b; outline-offset: 2px; }

.chat-bar-draft { flex: 1 0 100%; }
.chat-bar-draft[hidden] { display: none; }
.chat-bar-draft-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid #bfe2f2;
  border-left: 4px solid #0288d1;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(1, 87, 155, 0.10);
}
.chat-bar-draft-header {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 12px;
  background: #f3fafd;
  border-bottom: 1px solid #e2eef5;
}
.chat-bar-draft-dot { width:9px; height:9px; border-radius:50%; background:#0288d1; flex:0 0 auto; }
.chat-bar-draft-title { font-size: 13px; line-height: 1.35; font-weight: 700; color: #12384f; }
.chat-bar-draft-route {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  max-width: 100%; padding: 3px 9px; border-radius: 999px;
  background: #e3f3fb; color: #01579b; font-size: 12px; font-weight: 700;
}
.chat-bar-draft-route-arrow { opacity:.65; font-weight:400; }
.chat-bar-draft-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  max-height: 340px; overflow: auto;
  font-size: 12.5px; line-height: 1.4; color: #3a342c;
}
.chat-bar-draft-kindrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-bar-draft-kind { color: #01579b; font-weight: 700; }
.chat-bar-draft-ticket,
.chat-bar-draft-pill {
  display: inline-flex; align-items: center; min-height: 24px;
  padding: 2px 8px; border-radius: 999px;
  background: #f3efe7; color: #5a5249; font-size: 12px; font-weight: 650;
}
.chat-bar-draft-field,
.chat-bar-draft-diagnostic-row,
.chat-bar-draft-diagnostic-subrow { display: flex; gap: 8px; align-items: flex-start; }
.chat-bar-draft-label { flex: 0 0 112px; color: #6b6258; font-weight: 650; }
.chat-bar-draft-fieldval { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.chat-bar-draft-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-bar-draft-attach-note { color: #5a5249; background: #faf8f3; border: 1px solid #e6e0d6; border-radius: 8px; padding: 8px 10px; }
.chat-bar-draft-diagnostics {
  display: flex; flex-direction: column; gap: 7px;
  border: 1px solid #e6e0d6; background: #faf8f3; border-radius: 8px;
  padding: 9px 10px;
}
.chat-bar-draft-diagnostics-title { color: #3a342c; font-weight: 700; }
.chat-bar-draft-diagnostics-note { color: #6b6258; font-size: 12px; }
.chat-bar-draft-diagnostics-rows,
.chat-bar-draft-diagnostic-subrows,
.chat-bar-draft-diagnostic-array-items { display: flex; flex-direction: column; gap: 5px; }
.chat-bar-draft-diagnostic-subrows,
.chat-bar-draft-diagnostic-array-items { padding-left: 12px; border-left: 2px solid #e6e0d6; }
.chat-bar-draft-diagnostic-row--array .chat-bar-draft-fieldval { flex-basis: 100%; }
.chat-bar-draft-diagnostic-toggle {
  font: inherit; color: #01579b; background: transparent; border: 0; padding: 0;
  cursor: pointer; font-weight: 700; text-align: left;
}
.chat-bar-draft-diagnostic-toggle:focus-visible { outline: 2px solid #01579b; outline-offset: 2px; border-radius: 4px; }
.chat-bar-draft-value { white-space: pre-wrap; word-break: break-word; }
.chat-bar-draft-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-top: 1px solid #e6e0d6; background: #fbfaf6;
}
.chat-bar-draft-floor { margin-left: auto; color: #6b6258; font-size: 12px; }
.chat-bar-draft-btn {
  font: inherit; font-size: 12.5px; font-weight: 650; min-height: 40px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; border: 1px solid;
}
.chat-bar-draft-btn--submit { background: #01579b; border-color: #01579b; color: #fff; }
.chat-bar-draft-btn--cancel { background: #fff; border-color: #d8d0c2; color: #5a5249; }
.chat-bar-draft-btn:disabled { opacity: 0.5; cursor: default; }
.chat-bar-draft-btn:focus-visible { outline: 2px solid #01579b; outline-offset: 2px; }
.chat-bar-result { flex: 1 0 100%; }
.chat-bar-result[hidden] { display: none; }
.chat-bar-result-strip {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 11px; border: 1px solid; border-radius: 8px;
  font-size: 12.5px; line-height: 1.35;
}
.chat-bar-result-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px;
  color: #fff; font-weight: 800; flex: 0 0 auto;
}
.chat-bar-result-text { flex: 1 1 auto; min-width: 180px; white-space: pre-wrap; word-break: break-word; }
.chat-bar-result-action {
  color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px;
}
.chat-bar-result-action--button {
  font: inherit; border: 1px solid currentColor; border-radius: 8px;
  background: transparent; padding: 5px 9px; cursor: pointer; text-decoration: none;
}
.chat-bar-result-action:focus-visible,
.chat-bar-result-action--button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.chat-bar-result-strip--submitted { background:#e7f3e8; border-color:#cfe6d1; color:#246627; }
.chat-bar-result-strip--submitted .chat-bar-result-icon { background:#2e7c32; }
.chat-bar-result-strip--failed { background:#fbe7e4; border-color:#f2cfc9; color:#a3271a; }
.chat-bar-result-strip--failed .chat-bar-result-icon { background:#c0392b; }
.chat-bar-result-strip--ambiguous { background:#fbecd9; border-color:#f0dcbf; color:#7c4a10; }
.chat-bar-result-strip--ambiguous .chat-bar-result-icon { background:#985b14; }
.chat-bar-result-strip--cancelled { background:#f3efe7; border-color:#e6dfd2; color:#6b6258; }
.chat-bar-result-strip--cancelled .chat-bar-result-icon { background:#8a8175; }

.app-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  pointer-events: none;
  z-index: -2;
  border-radius: 12px;
}

.app-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--facet-bg, #b06a1a1a);
  transition: background-color 0.3s ease;
  pointer-events: none;
  z-index: -1;
  border-radius: 12px;
}

.chat-bar-status {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-bar-status--sol-ping {
  cursor: pointer;
}

.chat-bar-status--error {
  cursor: pointer;
}

.chat-bar-status #chatBarStatusText {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #888;
  font-size: 13px;
  line-height: 1.4;
}

.chat-bar-status--thinking #chatBarStatusText {
  color: var(--facet-color, #b06a1a);
  font-size: 14px;
  font-weight: 600;
}

.chat-bar-status--thinking #chatBarStatusText::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: currentColor;
  vertical-align: middle;
  animation: sol-ping-pulse 1.2s ease-in-out infinite;
}

.chat-bar-queue {
  flex: 1 0 100%;
  min-width: 0;
  color: #888;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
}

.chat-bar-queue[hidden] {
  display: none;
}

.chat-bar-status-action {
  flex: 0 0 auto;
  margin-left: 8px;
  color: #666;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.chat-bar-status-action:hover {
  text-decoration: underline;
}

.chat-bar-sol-ping-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--facet-color, #b06a1a);
  flex: 0 0 auto;
}

.chat-bar-sol-ping-dot[hidden] {
  display: none;
}

.chat-bar-sol-ping-dot.pulsing {
  animation: sol-ping-pulse 3s ease-in-out infinite;
}

.chat-bar-sol-ping-dot.offline {
  opacity: 0.4;
  filter: grayscale(1);
}

.chat-bar-sol-ping-dismiss {
  border: 0;
  background: transparent;
  color: #777;
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
}

.chat-bar-sol-ping-dismiss[hidden] {
  display: none;
}

.chat-bar-sol-ping-dismiss:hover {
  color: #222;
}

.chat-bar-talents {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(8 * 24px);
  overflow: hidden;
}

.chat-bar-form {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-bar-input {
  flex: 1 1 auto;
  resize: none;
  overflow: hidden;
  max-height: 120px;
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
  font: inherit;
  line-height: 1.4;
}

.chat-bar-input:focus {
  outline: 2px solid var(--facet-color, #b06a1a);
  outline-offset: 1px;
}

.chat-bar-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-bar-send {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--orange);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.chat-bar-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-bar-talent {
  width: 20px;
  height: 20px;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 50%;
  background: transparent;
  color: #888;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-bar-talent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.chat-bar-talent[data-status="running"] {
  color: var(--facet-color, #b06a1a);
}

.chat-bar-talent[data-status="running"] .chat-bar-talent-dot {
  animation: chat-bar-talent-pulse 1.2s ease-in-out infinite;
}

.chat-bar-talent--overflow {
  width: auto;
  min-width: 28px;
  height: 20px;
  border-radius: 10px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.chat-bar-talent[data-status="errored"] {
  color: #b42318;
}

@keyframes chat-bar-talent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes sol-ping-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.talent-view-modal[hidden] {
  display: none;
}

.talent-view-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modals);
  display: flex;
  align-items: center;
  justify-content: center;
}

.talent-view-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.talent-view-panel {
  position: relative;
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.talent-view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--facet-border, #e5e0db);
}

.talent-view-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.talent-view-status {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.talent-view-status[data-status="running"] {
  background: rgba(176, 106, 26, 0.16);
  color: var(--facet-color, #b06a1a);
}

.talent-view-status[data-status="completed"] {
  background: rgba(15, 23, 42, 0.08);
  color: #888;
}

.talent-view-status[data-status="errored"] {
  background: rgba(180, 35, 24, 0.16);
  color: #b42318;
}

.talent-view-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

.talent-view-timeline {
  flex: 1 1 auto;
  padding: 12px 16px;
  overflow: auto;
}

.talent-view-empty {
  margin: 0;
  color: #6b7280;
}

.talent-view-event {
  margin-bottom: 12px;
  font-size: 13px;
}

.talent-view-event-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.talent-view-event-label {
  font-weight: 600;
}

.talent-view-event-time {
  color: #6b7280;
  font-size: 12px;
  flex-shrink: 0;
}

.talent-view-event--thinking,
.talent-view-thinking {
  color: #888;
  font-style: italic;
}

.talent-view-info {
  line-height: 1.5;
}

.talent-view-pre {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.03);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.talent-view-event--tool summary,
.talent-view-event details > summary {
  cursor: pointer;
  font-weight: 600;
}

.talent-view-event--error {
  color: #b42318;
}

@media (max-width: 768px) {
  .app-bar {
    padding: 10px;
    gap: 10px;
  }

  .chat-bar-form {
    min-width: 0;
    width: 100%;
  }

  .talent-view-modal {
    padding: 12px;
  }
}

/* Notification Center */
.notification-center {
  position: fixed;
  top: calc(var(--facet-bar-height) + 8px);
  right: 20px;
  width: 280px;
  z-index: var(--z-notifications);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: right 0.25s ease;
}

body:has(.status-pane.visible) .notification-center {
  right: calc(var(--status-pane-width) + 12px);
}

@media (max-width: 768px) {
  body:has(.status-pane.visible) .notification-center {
    right: 8px;
  }
}

/* Notification Card */
.notification-card {
  background: white;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px;
  position: relative;
  overflow: hidden;
  pointer-events: all;
  animation: slideIn 0.3s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
  display: block;
}

/* Reset anchor tag styles when used as notification card */
a.notification-card {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a.notification-card:hover {
  transform: translateX(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

a.notification-card:active {
  transform: translateX(-4px) scale(0.98);
}

.notification-card--dismissing {
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes countdownShrink {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.notification-countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #3b82f6;
  transform-origin: left;
  animation: countdownShrink linear forwards;
  border-radius: 0 0 8px 8px;
}

.notification-card:hover .notification-countdown,
.notification-card:focus-within .notification-countdown {
  animation-play-state: paused;
}

/* Notification Header */
.notification-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.notification-app-icon {
  font-size: 16px;
  line-height: 1;
}

.notification-app-name {
  font-size: 11px;
  color: #9ca3af;
  text-transform: capitalize;
  letter-spacing: 0.03em;
  flex: 1;
  font-weight: 500;
}

.notification-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
  margin: -6px -6px -6px 0;
}

.notification-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.notification-close:active {
  background: #e5e7eb;
}

/* Notification Body */
.notification-body {
  position: relative;
}

.notification-title {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
  margin-bottom: 4px;
  line-height: 1.3;
}

.notification-message {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  line-height: 1.2;
}

/* Notification Footer */
.notification-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notification-time {
  font-size: 11px;
  color: #9ca3af;
}

.notification-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.notification-action {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #f9fafb;
  color: #374151;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.notification-action:hover {
  background: #f3f4f6;
}

.notification-action:active {
  background: #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
  .notification-center {
    top: calc(var(--facet-bar-height) + 8px);
    right: 8px;
    left: 8px;
    width: auto;
  }

  .notification-card {
    width: 100%;
  }
}

/* Modal styling */
.modal {
  display: none;
  position: fixed;
  z-index: var(--z-modals);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  background: white;
  margin: 5% auto;
  padding: 1em;
  border-radius: 8px;
  max-width: 500px;
  max-height: 80vh;
  overflow: auto;
  position: relative;
}

.report-error-modal .modal-content {
  max-width: 560px;
}

.report-error-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-error-form label {
  display: block;
  margin-bottom: 2px;
  color: var(--text, #222);
  font-size: 0.9rem;
}

.report-error-form input[type="text"],
.report-error-form textarea,
.report-error-form select,
.report-error-fallback-report {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 6px;
  font: inherit;
}

.report-error-form textarea {
  min-height: 96px;
  resize: vertical;
}

.report-error-checkbox {
  display: flex;
  gap: 6px;
  align-items: center;
}

.report-error-diagnostic {
  max-height: 240px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.report-error-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.report-error-fallback h2 {
  color: var(--color-warning, #f59e0b);
}

.report-error-fallback-report {
  min-height: 220px;
  resize: vertical;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', monospace;
  font-size: 12px;
}

.report-error-failure-meta {
  color: var(--muted, #666);
  font-size: 0.85rem;
}

.close {
  position: absolute;
  top: 10px;
  right: 15px;
  cursor: pointer;
  font-size: 24px;
  transition: color 0.15s ease;
}

.close:hover {
  color: #333;
}

.close:active {
  transform: scale(0.9);
}

/* Corner Tags - fixed markers for screen region detection */
.corner-tags {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-tags);
}

.corner-tag {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--facet-color);
  mask-size: contain;
  -webkit-mask-size: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges; /* Firefox fallback */
}

.corner-tag-tl { top: 0; left: 0; mask-image: url('tags/tag-6.png'); -webkit-mask-image: url('tags/tag-6.png'); }
.corner-tag-tr { top: 0; right: 0; mask-image: url('tags/tag-7.png'); -webkit-mask-image: url('tags/tag-7.png'); }
.corner-tag-bl { bottom: 32px; left: 0; mask-image: url('tags/tag-4.png'); -webkit-mask-image: url('tags/tag-4.png'); }
.corner-tag-br { bottom: 32px; right: 0; mask-image: url('tags/tag-2.png'); -webkit-mask-image: url('tags/tag-2.png'); }

/* ========================================
 * Facet Add Button
 * Plus button to create new facets
 * ======================================== */
.facet-add-pill {
  appearance: none;
  font-family: inherit;
  color: inherit;
  line-height: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 2px dashed #ccc;
  cursor: pointer;
  font-size: 20px;
  color: #999;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.facet-add-pill:hover {
  border-color: var(--facet-color, #b06a1a);
  color: var(--facet-color, #b06a1a);
  background: var(--facet-bg, rgba(176, 106, 26, 0.1));
  transform: scale(1.1);
}

.facet-add-pill:active {
  transform: scale(0.95);
}

/* ========================================
 * Facet Create Modal
 * Simple modal for creating new facets
 * ======================================== */
.facet-create-modal {
  display: none;
  position: fixed;
  z-index: var(--z-modals);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.facet-create-modal.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.facet-create-content {
  background: white;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.facet-create-content h3 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.facet-create-field {
  margin-bottom: 16px;
}

.facet-create-field label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
}

.facet-create-field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.facet-create-field input:focus {
  outline: none;
  border-color: var(--facet-color, #b06a1a);
}

.facet-create-slug {
  font-size: 13px;
  color: #888;
  margin-top: 6px;
  font-family: monospace;
}

.facet-create-slug.has-slug::before {
  content: "→ ";
}

.facet-create-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.facet-create-buttons button {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.facet-create-cancel {
  background: #f5f5f5;
  border: 1px solid var(--facet-border, #e5e0db);
  color: #666;
}

.facet-create-cancel:hover {
  background: #e5e5e5;
}

.facet-create-submit {
  background: var(--orange);
  border: none;
  color: var(--ink);
}

.facet-create-submit:hover {
  opacity: 0.9;
}

.facet-create-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.facet-create-error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.facet-create-error.visible {
  display: block;
}

/* Button reset for a11y-converted controls */
button#hamburger,
button.status-icon,
button.close {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ========================================
 * Reduced Motion
 * Respects prefers-reduced-motion user preference
 * ======================================== */
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .chat-bar-talent[data-status="running"] .chat-bar-talent-dot {
    animation: none;
  }

  .status-indicator--connecting {
    animation: none;
  }

  .facet-pill:hover {
    transform: none;
  }

  .facet-pill:active:not(.dragging) {
    transform: none;
  }

  .facet-pill.dragging {
    transform: none;
  }

  .facet-pill.drag-over {
    transform: none;
  }

  .facet-add-pill:hover {
    transform: none;
  }

  a.notification-card:hover {
    transform: none;
  }

  .menu-bar .menu-item .star-toggle:active {
    transform: none;
  }

  .facet-add-pill:active {
    transform: none;
  }

  .close:active {
    transform: none;
  }

  a.notification-card:active {
    transform: none;
  }

  .entity-card:active {
    transform: none;
  }
}

/* Focus-visible states for keyboard navigation */
.menu-bar .menu-item-link:focus-visible,
.facet-pill:focus-visible,
.facet-add-pill:focus-visible,
#hamburger:focus-visible,
.facet-bar .status-icon:focus-visible,
.chat-bar-send:focus-visible,
.facet-create-submit:focus-visible,
.facet-create-cancel:focus-visible,
.menu-bar .menu-expander:focus-visible,
.notification-card:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--facet-color, #b06a1a);
  outline-offset: 2px;
}

.chat-bar-send:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* chat app */
.chat-app {
  height: calc(100dvh - var(--facet-bar-height) - 16px);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-app-search {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: 4px;
  background: white;
}

.chat-search-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 12px;
  font: inherit;
  background: #fffdf9;
}

.chat-search-results {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--facet-border, #e5e0db);
  border-radius: 12px;
  background: white;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  max-height: 240px;
  overflow: auto;
}

.chat-search-result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-search-result-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
}

.chat-search-result-day,
.chat-search-status,
.chat-empty,
.chat-time-sep {
  color: #6b7280;
  font-size: 12px;
}

.chat-search-result-text {
  font-size: 13px;
  line-height: 1.4;
}

.chat-transcript {
  list-style: none;
  margin: 0;
  padding: 4px 0 16px;
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-event {
  display: flex;
}

.chat-event--owner {
  justify-content: flex-end;
}

.chat-event--sol {
  align-items: flex-start;
  flex-direction: column;
  justify-content: flex-start;
}

.chat-event--talent,
.chat-event--error {
  justify-content: center;
}

.chat-bubble {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.chat-bubble--owner {
  background: color-mix(in srgb, var(--facet-color, var(--orange)) 14%, var(--paper));
  color: var(--ink);
  border: 1px solid var(--facet-color, var(--orange));
  border-bottom-right-radius: 6px;
}

.chat-bubble--sol {
  background: #f6efe7;
  color: #1f2937;
  border-bottom-left-radius: 6px;
}

.chat-bubble--placeholder { opacity: 0.65; font-style: italic; }

.chat-thinking-content { opacity: 0.7; font-style: italic; white-space: pre-wrap; }

.chat-error-detail-content { opacity: 0.7; font-style: italic; white-space: pre-wrap; }

.chat-origin-tag {
  max-width: 70%;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.chat-origin-tag__label {
  font-weight: 500;
}

.chat-origin-tag__toggle {
  appearance: none;
  background: transparent;
  border: 0;
  color: #6b7280;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-origin-tag__toggle:hover {
  color: #374151;
}

.chat-dispatch-origin {
  max-width: 70%;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.chat-dispatch-origin__prefix {
  font-weight: 500;
}

.chat-dispatch-origin__ask {
  white-space: pre-wrap;
}

.chat-dispatch-origin--locatable {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-dispatch-origin--locatable:hover {
  color: #374151;
}

.chat-origin-provenance {
  color: #6b7280;
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11px;
}

.chat-origin-provenance strong {
  color: #4b5563;
  font-weight: 600;
}

.chat-bubble-author {
  font-size: 11px;
  opacity: 0.75;
}

.chat-bubble-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.chat-bubble-text--markdown {
  white-space: normal;
}

.chat-bubble-text--markdown > :first-child {
  margin-top: 0;
}

.chat-bubble-text--markdown > :last-child {
  margin-bottom: 0;
}

.chat-bubble-text--markdown pre { max-width: 100%; overflow-x: auto; }

.chat-time-sep,
.chat-empty {
  text-align: center;
}

.chat-talent-card {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--facet-border, #e5e0db);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.chat-reflection-card {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(180, 83, 9, 0.18);
  background: rgba(245, 158, 11, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.chat-talent-card--spawned {
  border-color: rgba(176, 106, 26, 0.22);
  background: rgba(176, 106, 26, 0.08);
}

.chat-talent-card--queued {
  border-style: dashed;
  border-color: rgba(107, 114, 128, 0.28);
  background: rgba(107, 114, 128, 0.06);
  opacity: 0.78;
  cursor: default;
}

.chat-talent-card--finished {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.03);
}

.chat-talent-card--errored,
.chat-error-block {
  border-color: rgba(180, 35, 24, 0.2);
  background: rgba(180, 35, 24, 0.08);
  color: #b42318;
}

.chat-talent-card-label {
  font-size: 13px;
  font-weight: 600;
}

.chat-reflection-card-label {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
}

.chat-talent-card-task,
.chat-talent-card-summary,
.chat-talent-card-reason,
.chat-talent-card-detail,
.chat-reflection-card-week {
  font-size: 12px;
  line-height: 1.4;
}

.chat-reflection-card-link {
  width: fit-content;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  text-decoration: none;
}

.chat-reflection-card-link:hover {
  text-decoration: underline;
}

.chat-error-block {
  max-width: 70%;
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.2);
  border-radius: 14px;
}

.surface-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 24px;
  text-align: center;
  color: #9ca3af;
}

.surface-state--loading {
  color: #6b7280;
}

.surface-state-icon {
  color: #d1d5db;
  font-size: 48px;
  line-height: 1;
}

.surface-state-icon svg {
  width: 48px;
  height: 48px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.surface-state-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  color: #4b5563;
}

.surface-state-desc {
  margin: 0;
  max-width: 36ch;
  font-size: 14px;
  line-height: 1.5;
  color: #9ca3af;
}

.surface-state-text {
  display: block;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: #6b7280;
}

.surface-state-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.surface-state-action > button {
  min-height: 40px;
  padding: 0.6em 1.2em;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.surface-state-action > button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.surface-state-action > button:active {
  background: #e5e7eb;
  border-color: #6b7280;
  transform: scale(0.98);
}

.surface-state-action > button:focus-visible {
  outline: 2px solid var(--facet-color, #b06a1a);
  outline-offset: 2px;
}

.surface-state-action > a:not([class]) {
  color: var(--facet-color, #2563eb);
  text-decoration: none;
  font-weight: 500;
}

.surface-state-action > a:not([class]):hover {
  text-decoration: underline;
}

.surface-state-action > a:not([class]):focus-visible {
  outline: 2px solid var(--facet-color, #b06a1a);
  outline-offset: 2px;
  border-radius: 4px;
}

.surface-state-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.surface-state-action-row > button,
.surface-state-action-row > a {
  min-height: 40px;
  padding: 0.6em 1.2em;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.surface-state-action-row > button:hover,
.surface-state-action-row > a:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.surface-state-action-row > button:active,
.surface-state-action-row > a:active {
  background: #e5e7eb;
  border-color: #6b7280;
  transform: scale(0.98);
}

.surface-state-action-row > button:focus-visible,
.surface-state-action-row > a:focus-visible {
  outline: 2px solid var(--facet-color, #b06a1a);
  outline-offset: 2px;
}

.surface-state--error .surface-state-icon {
  color: #f59e0b;
}

.surface-state--error .surface-state-heading {
  color: #92400e;
}

.surface-state-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--facet-color, #b06a1a);
  border-radius: 50%;
  animation: surface-state-spin 0.8s linear infinite;
}

@keyframes surface-state-spin {
  to { transform: rotate(360deg); }
}

.surface-state-server-message {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  font-family: monospace;
  word-break: break-word;
}

.surface-state-detail {
  max-width: 56ch;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted, #6b7280);
  text-align: left;
  word-break: break-word;
}

.surface-state-detail summary {
  width: fit-content;
  margin: 0 auto 6px;
  color: var(--facet-color, #92400e);
  cursor: pointer;
}

.surface-state-copy-reference {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--facet-color, #92400e);
  font: inherit;
  cursor: pointer;
}

.surface-state-copy-reference:hover {
  text-decoration: underline;
}

.surface-state-refresh-error {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--color-warning, #f59e0b);
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.08);
}

.control-save-error {
  display: inline-block;
  margin-left: 8px;
  color: var(--color-error, #dc2626);
  font-size: 13px;
}

.menu-item-bg-failing::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-warning, #f59e0b);
  border: 2px solid var(--facet-bg-primary, #fff);
}

@media (max-width: 768px) {
  .chat-app {
    padding: 0 12px 16px;
  }

  .chat-bubble,
  .chat-origin-tag,
  .chat-dispatch-origin,
  .chat-talent-card,
  .chat-reflection-card,
  .chat-error-block {
    max-width: 88%;
  }

}

@media (prefers-reduced-motion: reduce) {
  .surface-state-spinner {
    animation: none;
  }
}

/* Visually hidden — accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link — visible on focus */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--orange);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  border-radius: 0 0 4px 0;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

/* ==========================================================================
   Presentation mode — gated by body.presentation-mode (toggle: ?present=1
   or Shift+P; persists in sessionStorage). Boosts type, contrast, weights
   so views read from the back row of a presentation room on a 1080p
   projector. Per-app overrides live in each app's workspace.html.
   ========================================================================== */

/* Floating "PRESENT" badge — also a click-to-exit affordance. */
body.presentation-mode::after {
  content: 'PRESENT — Shift+P to exit';
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 9998;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fef3c7;
  background: rgba(180, 83, 9, 0.92);
  border-radius: 4px;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  opacity: 0.85;
}

/* Shared chrome boosts — keep these conservative. The big polish lives
   in the app workspaces (graph, entities, transcripts). */
body.presentation-mode .facet-bar {
  font-size: 1.05rem;
}
body.presentation-mode .facet-pills-container .facet-pill {
  font-size: 1rem;
  padding: 6px 14px;
}

/* Minor: surface-state empty/error blocks read at distance. */
body.presentation-mode .surface-state-heading {
  font-size: 1.5rem;
}
body.presentation-mode .surface-state-desc {
  font-size: 1.1rem;
}
