/* Cowork Design UI. Components (ds-button-*, ds-bi-*, ds-tabs-*, ds-field-*, ds-checkbox-*, ds-select-*,
 * ds-search-*, ds-segmented-*, ds-messagebanner-*, ds-card-*, ds-tile-*, ds-dropdown-*, ds-ti-*, ds-nb-*,
 * ds-ia-*, ds-id-*) come from /ui-ds/styles.css: the built-in Cowork UI kit (public/ui-kit) or, when
 * configured as uiDesignSystem, a design system with the same class API.
 * This file maps semantic tokens and styles what the kit has no component for: the dashboard layout,
 * the canvas, frames, comment pins, cursors and presence avatars.
 *
 * Rules: page on a neutral background, white surfaces; elevation by a 1px border, never a shadow —
 * shadows only on floating surfaces (menus, toasts, modals); hover is an overlay, not a lift;
 * focus-visible is a 2px currentColor outline; motion is short opacity.
 * Light and dark: data-theme="light|dark" on <html> (see theme.js). */

/* Cowork UI kit colours (light / dark). A configured design system's --semantic-* tokens win. */
:root {
  --fb-paper: #f4f4f5;
  --fb-surface: #ffffff;
  --fb-tint: rgba(0, 0, 0, 0.09);
  --fb-ink: #18181b;
  --fb-muted: #5f5f68;
  --fb-line-strong: #8e8e96;
  --fb-accent: #18181b;
  --fb-on-accent: #ffffff;
  --fb-selected: #18181b;
  --fb-on-selected: #ffffff;
  --fb-on-surface: #000000;
  --fb-notify: #5b4ce0;
  --fb-success: #1a8754;
  --fb-warning: #b45309;
  --fb-error: #d93025;
}
:root[data-theme='dark'] {
  --fb-paper: #0b0b0c;
  --fb-surface: #18181b;
  --fb-tint: rgba(255, 255, 255, 0.1);
  --fb-ink: #fafafa;
  --fb-muted: rgba(255, 255, 255, 0.66);
  --fb-line-strong: rgba(255, 255, 255, 0.42);
  --fb-accent: #fafafa;
  --fb-on-accent: #18181b;
  --fb-selected: #fafafa;
  --fb-on-selected: #000000;
  --fb-on-surface: #ffffff;
  --fb-notify: #a29bfe;
  --fb-success: #71b55f;
  --fb-warning: #fbbf24;
  --fb-error: #f9836c;
}
:root {
  --paper: var(--semantic-color-neutral-background, var(--fb-paper));
  --surface: var(--semantic-color-neutral-surface, var(--fb-surface));
  --surface-muted: var(--semantic-color-neutral-surfaceMuted, var(--fb-tint));
  --ink: var(--semantic-color-neutral-onSurfacePrimary, var(--fb-ink));
  --muted: var(--semantic-color-neutral-onSurfaceSecondary, var(--fb-muted));
  --line: var(--semantic-color-neutral-borderMuted, var(--fb-tint));
  --line-strong: var(--semantic-color-neutral-border, var(--fb-line-strong));
  --accent: var(--semantic-color-accent-primary, var(--fb-accent));
  --on-accent: var(--semantic-color-accent-onPrimary, var(--fb-on-accent));
  --warning: var(--semantic-color-status-warning, var(--fb-warning));
  --deco-accent: color-mix(in srgb, var(--notify) 18%, transparent);
  --deco-ink: var(--ink);
  --selected: var(--semantic-color-accent-secondary, var(--fb-selected)); /* on-states are black (white in dark) */
  --on-selected: var(--semantic-color-accent-onSecondary, var(--fb-on-selected));
  --notify: var(--semantic-color-accent-tertiary, var(--fb-notify));
  --inverted: var(--semantic-color-neutral-surfaceInverted, #222222);
  --on-inverted: var(--semantic-color-neutral-onSurfaceInverted, #ffffff);
  --success: var(--semantic-color-status-success, var(--fb-success));
  --error: var(--semantic-color-status-error, var(--fb-error));
  --on-surface: var(--semantic-color-neutral-onSurface, var(--fb-on-surface));
  --hover: color-mix(in srgb, var(--on-surface) 4%, transparent);
  --pressed: color-mix(in srgb, var(--on-surface) 8%, transparent);
  --r-action: var(--semantic-borderRadius-action-web, 8px);
  --r-container: var(--semantic-borderRadius-container-web, 8px);
  --r-modal: var(--semantic-borderRadius-modal-web, 16px);
  --r-form: var(--semantic-borderRadius-form-web, 8px);
  --r-s: var(--semantic-borderRadius-s, 4px);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --shadow-float: 0 4px 12px rgba(0, 0, 0, 0.16); /* tooltip */
  --shadow-modal: 0 8px 16px rgba(0, 0, 0, 0.24); /* modal / dropdown */
  --bar-h: 56px;
  --nav-w: 248px;
  --side-w: 400px;
  --canvas-dot: color-mix(in srgb, var(--on-surface) 14%, transparent);
}

* {
  box-sizing: border-box;
}
html,
body,
#app {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea,
select {
  font-family: inherit;
}
a {
  color: inherit;
}
code {
  font-family: var(--mono);
  font-size: 12px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.kbd {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: var(--r-s);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--muted);
}
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
/* Kit form controls draw focus on their container. */
.ds-field-input:focus-visible,
.ds-search-input:focus-visible,
.native-select select:focus-visible {
  outline: none;
}

/* ---------- kit glue (states the React versions drive, driven here by CSS) ---------- */
.ds-field-container:focus-within {
  box-shadow: inset 0 0 0 2px var(--line-strong);
}
.ds-field-root {
  width: 100%;
}
.native-select {
  position: relative;
}
.native-select select {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}
.native-select:focus-within {
  box-shadow: inset 0 0 0 2px var(--line-strong);
}
.ds-bi-root.is-active {
  background: var(--selected);
  color: var(--on-selected);
}
.ds-ia-root.sm {
  width: 16px;
  height: 16px;
}
.ds-ia-root.xs {
  width: 14px;
  height: 14px;
}
.ds-tabs-root {
  overflow-x: auto;
  scrollbar-width: none;
}
.ds-messagebanner-root {
  width: 100%;
  max-width: none;
}
.ds-select-root {
  width: 100%;
}
.ds-id-root {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex: none;
}
.ds-id-root svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- avatars (no kit avatar component) ---------- */
.avatar {
  --c: var(--muted);
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface);
  flex: none;
}
.avatar.agent {
  border-radius: var(--r-action);
  background: var(--surface);
  color: var(--c);
  box-shadow: inset 0 0 0 2px var(--c), 0 0 0 2px var(--surface);
  position: relative;
}
.avatar .ds-ia-root {
  width: 18px;
  height: 18px;
}
.avatar.agent.working::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: calc(var(--r-action) + 4px);
  border: 2px solid var(--c);
  opacity: 0;
  animation: ping 1.6s ease-out infinite;
}
@keyframes ping {
  0% {
    opacity: 0.6;
    transform: scale(0.9);
  }
  100% {
    opacity: 0;
    transform: scale(1.25);
  }
}
.avatar.sm {
  width: 24px;
  height: 24px;
  font-size: 10px;
}
.avatar.sm .ds-ia-root {
  width: 14px;
  height: 14px;
}
.avatar.xs {
  width: 20px;
  height: 20px;
  font-size: 9px;
  box-shadow: none;
}
.avatar-stack {
  display: flex;
  align-items: center;
}
.avatar-stack .avatar + .avatar {
  margin-left: -6px;
}

/* ---------- app chrome ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--r-action);
  flex: none;
}
.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
}
.brand-name {
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.topbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .spacer {
  flex: 1;
}
.bar-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
  flex: none;
}
.account-btn {
  border: 0;
  padding: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  display: inline-grid;
}
.account-btn .avatar {
  box-shadow: none;
}
.account-btn:hover .avatar,
.account-btn[aria-expanded='true'] .avatar {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--line);
}
.topbar-search.ds-search-secondary {
  flex: 0 1 400px;
  min-width: 0;
  margin-left: 32px;
}

/* ---------- menus (kit Dropdown surface) ---------- */
.menu-pop {
  position: fixed;
  z-index: 45;
  max-height: 70vh;
  overflow: auto;
  min-width: 240px;
  max-width: 320px;
  animation: fade 0.15s ease-out;
}
.menu-pop .ds-dropdown-item {
  color: var(--ink);
}
.menu-pop .ds-dropdown-label-web {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.menu-pop .ds-dropdown-icon-slot .ds-ia-root {
  width: 20px;
  height: 20px;
}
.menu-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.menu-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  min-width: 0;
}
.menu-account .who {
  min-width: 0;
}
.menu-account .who > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-theme {
  padding: 4px 8px 8px;
}
.menu-theme .ds-segmented-root {
  width: 100%;
}
.menu-theme .ds-segmented-segment {
  flex: 1;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- sign-in ---------- */
.signin {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  background: var(--surface);
}
.signin-panel {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding: 32px 56px;
}
.signin-body {
  margin: auto 0;
  display: grid;
  gap: 16px;
  max-width: 400px;
}
.signin-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}
.signin-body #sso-login {
  margin-top: 16px;
}
.signin-art {
  --inv: 1;
  background-color: var(--paper);
  background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  border-left: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 48px;
}
.art-canvas {
  position: relative;
  width: 560px;
  height: 420px;
}
.art-frame {
  position: absolute;
}
.art-label {
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
}
.art-screen {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
  height: 100%;
}
.art-frame.f1 {
  left: 0;
  top: 40px;
  width: 280px;
  height: 240px;
}
.art-frame.f2 {
  left: 312px;
  top: 40px;
  width: 132px;
  height: 260px;
}
.art-frame.f3 {
  left: 96px;
  top: 320px;
  width: 248px;
  height: 120px;
}
.art-frame.f2 .art-row,
.art-frame.f3 .art-block {
  display: none;
}
.art-bar {
  height: 10px;
  width: 40%;
  border-radius: 5px;
  background: var(--ink);
  opacity: 0.85;
}
.art-line {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
}
.art-line.w70 {
  width: 70%;
}
.art-line.w45 {
  width: 45%;
}
.art-block {
  height: 64px;
  border-radius: var(--r-s);
  background: var(--paper);
}
.art-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.art-row span {
  height: 24px;
  width: 72px;
  border-radius: var(--r-s);
  background: var(--line);
}
.art-row span:last-child {
  background: var(--accent);
}
.art-frame.f1 .art-row span:last-child {
  width: 96px;
}
.art-c1 {
  left: 220px;
  top: 170px;
}
.art-c2 {
  left: 400px;
  top: 250px;
}
.art-pin {
  left: 300px;
  top: 360px;
}
.signin-art .cursor,
.signin-art .pin {
  position: absolute;
  transform: none;
}

/* state pages (project in the trash, private, not found) */
.join {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.join .ds-card-root {
  width: min(480px, 100%);
}
.join-body {
  padding: 16px;
  display: grid;
  gap: 16px;
}

/* ---------- dashboard ---------- */
.lobby {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: calc(100% - var(--bar-h));
}
.side-nav {
  position: sticky;
  top: var(--bar-h);
  height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-group {
  display: grid;
  gap: 2px;
}
.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 4px 12px;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-action);
  color: var(--ink);
  text-decoration: none;
}
.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.15s;
  pointer-events: none;
}
.nav-item:hover::before {
  background: var(--hover);
}
.nav-item.active::before {
  background: var(--pressed);
}
.nav-item.active .name {
  font-weight: 700;
}
.nav-item > .ds-ia-root {
  color: var(--muted);
}
.nav-item.active > .ds-ia-root {
  color: var(--ink);
}
.nav-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item .count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.nav-item.drop-target::before {
  background: var(--pressed);
  box-shadow: inset 0 0 0 2px var(--selected);
}
.lobby.dragging .nav-item[data-drop]:not([data-drop='all']):not([data-drop='mine'])::before,
.lobby.dragging .nav-item[data-trash-drop]::before {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.nav-hint {
  padding: 4px 12px;
}
.nav-spacer {
  flex: 1;
  min-height: 24px;
}

.lobby-main {
  width: 100%;
  max-width: 1248px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.lobby-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.lobby-title {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 720px;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.title-row h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title-actions {
  display: inline-flex;
  gap: 4px;
}
.lobby-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  margin-bottom: 16px;
}
.lobby-toolbar:empty {
  display: none;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
  gap: 24px 16px;
}
.project-tile {
  min-width: 0;
}
.project-tile .thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.project-tile .thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity 0.15s;
}
.project-tile .thumb.portrait img {
  object-fit: contain;
  object-position: center;
  padding: 12px 0 0;
}
.project-tile .thumb.loaded img {
  opacity: 1;
}
.thumb-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}
.thumb.loaded .thumb-empty {
  display: none;
}
.tile-body {
  display: grid;
  gap: 8px;
  padding: 12px 8px 16px 16px;
  min-width: 0;
}
.tile-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.tile-title .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-menu {
  position: relative;
  z-index: 2;
  margin: -6px 0;
}
.tile-meta,
.tile-folder {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  min-width: 0;
  padding-right: 8px;
  white-space: nowrap;
}
.tile-meta > span:not(.avatar),
.tile-folder > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex: none;
}
.tile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* skeleton while loading */
.skeleton-tile {
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  background: var(--surface);
  overflow: hidden;
  padding-bottom: 16px;
  display: grid;
  gap: 10px;
}
.sk {
  background: var(--line);
  border-radius: var(--r-s);
  animation: pulse 1.4s ease-in-out infinite;
}
.sk-thumb {
  aspect-ratio: 16 / 10;
  border-radius: 0;
}
.sk-line {
  height: 12px;
  margin: 0 16px;
  width: 60%;
}
.sk-line.short {
  width: 35%;
}
@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* empty states: centred message, decorative icon, one action */
.empty-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 72px 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  background: var(--surface);
}
.empty-state .empty-art {
  width: 96px;
  height: 96px;
  margin-bottom: 16px;
}
.empty-state p {
  max-width: 440px;
}
.empty-state .ds-button-root {
  margin-top: 16px;
}
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-container);
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
}

/* trash */
.trash-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  background: var(--surface);
  overflow: hidden;
}
.trash-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
}
.trash-row + .trash-row {
  border-top: 1px solid var(--line);
}
.trash-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-action);
  background: var(--paper);
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.trash-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

/* dialogs used by the dashboard */
.modal-md {
  width: min(520px, 100%);
}
.modal-sm {
  width: min(440px, 100%);
}
.stack-lg {
  display: grid;
  gap: 20px;
}
.field-gap {
  margin-top: 8px;
}
.inherit-hint {
  margin-top: -12px !important;
}
.inherit-hint:empty {
  display: none;
}
.settings-group {
  display: grid;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
}
.modal-actions.spread {
  justify-content: space-between;
}

/* ---------- canvas page ---------- */
.canvas-page {
  height: 100%;
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  overflow: hidden;
}
.canvas-page .topbar {
  grid-column: 1 / -1;
  padding-left: 8px;
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.crumb a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  max-width: 18vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb a:hover {
  color: var(--ink);
  text-decoration: underline;
}
.crumb-folder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.crumb-sep {
  color: var(--line-strong);
}
.canvas-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 28vw;
}
.ds-chip-btn {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--r-s);
  flex: none;
}
.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 4px;
}
.conn::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.conn.off::before {
  background: var(--error);
}

.viewport {
  position: relative;
  overflow: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(var(--canvas-dot) 1.1px, transparent 1.1px);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.viewport.panning {
  cursor: grabbing;
}
.viewport.comment-mode {
  cursor: crosshair;
}
.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  --z: 1;
  --inv: 1;
}
/* Frames are designs: white artboards with a 1px border, no drop shadow. */
.frame {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 0 calc(1px * var(--inv)) var(--line);
}
.frame.selected {
  box-shadow: 0 0 0 calc(2px * var(--inv)) var(--selected);
}
.frame-body {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.frame-body iframe {
  position: absolute;
  inset: 0;
  border: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: #fff;
}
.frame-body iframe.incoming {
  visibility: hidden;
}
.frame.locked::after {
  content: '';
  position: absolute;
  inset: calc(-4px * var(--inv));
  border: calc(2px * var(--inv)) dashed var(--lock, var(--selected));
  pointer-events: none;
  animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}
.frame.flash .frame-body::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--lock, var(--selected));
  opacity: 0;
  animation: flash 0.7s ease-out;
  pointer-events: none;
}
@keyframes flash {
  0% {
    opacity: 0.16;
  }
  100% {
    opacity: 0;
  }
}
.frame-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  transform-origin: 0 100%;
  transform: scale(var(--inv));
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  max-width: calc(var(--w) * var(--z) * 1px);
  white-space: nowrap;
  color: var(--muted);
  cursor: pointer;
}
.frame-label .name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}
.frame-label .ver {
  font-family: var(--mono);
  font-size: 11px;
}
.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 6px;
  border-radius: var(--r-s);
  background: var(--lock);
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.lock-chip .ds-ia-root {
  width: 14px;
  height: 14px;
}

.pin {
  position: absolute;
  transform: translate(-4px, -100%) scale(var(--inv));
  transform-origin: 4px 100%;
  width: 28px;
  height: 28px;
  border-radius: 14px 14px 14px 4px;
  background: var(--c, var(--selected));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  z-index: 2;
}
.pin.active {
  outline: 3px solid var(--selected);
}
.pin.resolved {
  opacity: 0.45;
}

.cursor {
  position: absolute;
  pointer-events: none;
  transform-origin: 0 0;
  transform: scale(var(--inv));
  z-index: 5;
  transition: left 0.08s linear, top 0.08s linear;
}
.cursor svg {
  width: 18px;
  height: 18px;
  display: block;
}
.cursor span {
  display: inline-block;
  margin: 2px 0 0 12px;
  padding: 2px 8px;
  border-radius: var(--r-s);
  background: var(--c);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
  white-space: nowrap;
}

/* floating UI over the viewport */
.working-strip {
  position: absolute;
  left: 16px;
  top: 16px;
  display: grid;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
  max-width: min(440px, calc(100% - 32px));
}
.working {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-float);
  pointer-events: auto;
}
.working .st {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-float);
  z-index: 10;
}
.toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}
.zoom-label {
  min-width: 56px;
  justify-content: center;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
}
.canvas-empty .ds-card-root {
  pointer-events: auto;
  max-width: 480px;
  text-align: center;
  border: 1px solid var(--line);
}
.canvas-empty .inner {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 16px;
}
.canvas-empty .ds-button-root {
  margin-top: 8px;
}
.canvas-empty .empty-art {
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
}

.comment-pop {
  position: fixed;
  z-index: 40;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-modal);
  padding: 16px;
  display: grid;
  gap: 8px;
}
.comment-pop .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ---------- canvas sidebar ---------- */
.side {
  border-left: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  z-index: 15;
}
.side-tabs {
  border-bottom: 1px solid var(--line);
  padding: 0 8px;
  min-width: 0;
}
.side-tabs .ds-tabs-item {
  padding: 0 12px;
}
.side-body {
  overflow: auto;
  min-height: 0;
  padding: 20px;
}
.side-section + .side-section {
  margin-top: 32px;
}
.side-section > h3 {
  margin: 0 0 12px;
}
.stack {
  display: grid;
  gap: 8px;
}
.row-end {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.thread {
  border-radius: var(--r-container);
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.thread.active {
  border-color: var(--selected);
  box-shadow: inset 0 0 0 1px var(--selected);
}
.thread.resolved {
  opacity: 0.7;
}
.thread-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.thread-head .where {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  cursor: pointer;
}
.thread-head .where:hover {
  color: var(--ink);
  text-decoration: underline;
}
.num {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px 12px 12px 4px;
  background: var(--c, var(--selected));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.msg {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  padding: 8px 0;
}
.msg + .msg {
  border-top: 1px solid var(--line);
}
.msg time {
  color: var(--muted);
  margin-left: 4px;
  font-weight: 400;
}
.msg .body {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.reply {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: flex-start;
}
.reply .ds-field-input {
  resize: none;
}

.feed-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.feed-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  margin-top: 6px;
}
.feed-item time {
  display: block;
  color: var(--muted);
}
.feed-item .clickable {
  cursor: pointer;
}
.feed-item .clickable:hover {
  text-decoration: underline;
}

.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.person .info {
  min-width: 0;
}
.person .info > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-list {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}
.skill-list .ds-checkbox-root {
  align-items: flex-start;
  padding: 8px;
  border-radius: var(--r-action);
}
.skill-list .ds-checkbox-root:hover {
  background: var(--hover);
}
.skill-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
}

.connect-step {
  margin-bottom: 16px;
}
.connect-step .label {
  margin-bottom: 8px;
}
.code {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-action);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- modal & preview ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade 0.15s ease-out;
}
.modal {
  width: min(640px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r-modal);
  box-shadow: var(--shadow-modal);
  padding: 24px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.preview {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--inverted);
  display: grid;
  grid-template-rows: var(--bar-h) 1fr;
}
.preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--on-inverted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.preview-bar .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-bar .ds-select-root {
  width: 320px;
}
.preview-stage {
  overflow: auto;
  padding: 24px;
}
.preview-scale {
  margin: 0 auto;
  transform-origin: 0 0;
}
.preview-scale iframe {
  border: 0;
  background: #fff;
  display: block;
}

#toasts {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: var(--inverted);
  color: var(--on-inverted);
  padding: 12px 16px;
  border-radius: var(--r-container);
  box-shadow: var(--shadow-modal);
  animation: fade 0.15s ease-out;
}
.toast.with-action {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}
.toast-action {
  border: 0;
  background: transparent;
  color: var(--on-inverted);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.toast.error {
  background: var(--error);
  color: #fff;
}

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .signin {
    grid-template-columns: 1fr;
  }
  .signin-art {
    display: none;
  }
  .signin-panel {
    padding: 32px 24px;
  }
}
@media (max-width: 900px) {
  .lobby {
    grid-template-columns: 1fr;
  }
  .side-nav {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
    scrollbar-width: none;
  }
  .nav-group {
    display: flex;
    gap: 4px;
  }
  .nav-head .text-web-caption-m,
  .nav-hint,
  .nav-spacer {
    display: none;
  }
  .nav-head {
    padding: 0;
  }
  .nav-item {
    flex: none;
  }
  .topbar-search.ds-search-secondary {
    margin-left: 8px;
  }
  .topbar .brand-name {
    display: none;
  }
  .lobby-main {
    padding: 24px 16px 64px;
  }
  .canvas-page {
    grid-template-columns: 1fr;
    grid-template-rows: var(--bar-h) 1fr 45%;
  }
  .side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .crumb-home,
  .crumb-home + .crumb-sep,
  .crumb-folder {
    display: none !important;
  }
  .canvas-title {
    max-width: 36vw;
  }
  .hide-sm {
    display: none !important;
  }
}
@media (max-width: 640px) {
  .trash-row {
    flex-wrap: wrap;
  }
  .conn {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
