/* Inter ships with the editor (SIL OFL 1.1, see fonts/inter/LICENSE.txt), so the
   default font of new text looks the same on every computer (BUG-017). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('/apps/web/fonts/inter/InterVariable.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: block;
  src: url('/apps/web/fonts/inter/InterVariable-Italic.woff2') format('woff2');
}

/* Canvas Studio editor UI. Compact, stable layout: panels are docked to the
   window edges (FR-UI-001) and the canvas gets every remaining pixel. */

:root {
  --bg: #ffffff;
  --bg-subtle: #f5f5f5;
  --bg-hover: #f0f0f0;
  --border: #e6e6e6;
  --text: #1e1e1e;
  --text-muted: #6b6b6b;
  --text-faint: #9a9a9a;
  --accent: #0d99ff;
  --accent-soft: #e5f4ff;
  --danger: #e03e1a;
  --component: #9747ff;
  --component-soft: #f1e8ff;
  --warning-bg: #fff4e0;
  --warning-text: #8a5300;
  --field-h: 28px;
  --font: 12px/1.35 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2c2c2c;
    --bg-subtle: #383838;
    --bg-hover: #3a3a3a;
    --border: #444444;
    --text: #f2f2f2;
    --text-muted: #b3b3b3;
    --text-faint: #8a8a8a;
    --accent: #0d99ff;
    --accent-soft: #1e3a52;
    --component: #b48cff;
    --component-soft: #3a2d52;
    --warning-bg: #4a3816;
    --warning-text: #ffd48a;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

kbd {
  font: 11px system-ui, sans-serif;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.icon {
  display: block;
  flex: none;
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  width: 100vw;
  overflow: hidden;
  --left-w: 240px;
  --right-w: 260px;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  grid-template-rows: 44px minmax(0, 1fr);
  grid-template-areas:
    'top top top'
    'left canvas right';
  height: 100vh;
}

.app.hide-left {
  grid-template-columns: 0 minmax(0, 1fr) var(--right-w);
}
.app.hide-right {
  grid-template-columns: var(--left-w) minmax(0, 1fr) 0;
}
.app.hide-left.hide-right {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}
.app.hide-ui {
  grid-template-columns: 0 minmax(0, 1fr) 0;
  grid-template-rows: 0 minmax(0, 1fr);
}
.app.hide-ui .topbar,
.app.hide-ui .panel,
.app.hide-left .layers-panel,
.app.hide-right .properties-panel {
  visibility: hidden;
  overflow: hidden;
}

.topbar {
  grid-area: top;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-width: 0;
}

.topbar-left,
.topbar-right,
.tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: center;
}
.topbar-left,
.topbar-right {
  flex: none;
}

.file-name {
  flex: 0 1 220px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  padding: 4px 6px;
  font-weight: 600;
  text-align: center;
  width: 220px;
  min-width: 80px;
}
.file-name:hover {
  border-color: var(--border);
}
.file-name:focus {
  outline: none;
  border-color: var(--accent);
}

.save-status {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.save-status[data-state='error'] {
  color: var(--danger);
}

.tool-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.tool-button {
  width: 32px;
  height: 32px;
}
.icon-button {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}
.tool-button:hover,
.icon-button:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tool-button.active {
  background: var(--accent);
  color: #fff;
}
.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
  background: transparent;
}
.tool-button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.segment:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.zoom-label {
  border: none;
  background: transparent;
  min-width: 48px;
  padding: 4px;
  border-radius: var(--radius);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.zoom-label:hover {
  background: var(--bg-hover);
}

.canvas-area {
  grid-area: canvas;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.canvas-view {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.canvas-view canvas {
  display: block;
  outline: none;
  touch-action: none;
}

.text-editor {
  /* Invisible input sink at the caret: the canvas draws the text, caret and selection. */
  position: absolute;
  width: 2px;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  resize: none;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  white-space: pre;
  z-index: 2;
}

/* ---------- Panels ---------- */

.panel {
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}
.layers-panel {
  grid-area: left;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.properties-panel {
  grid-area: right;
  border-left: 1px solid var(--border);
}

.panel-section {
  border-bottom: 1px solid var(--border);
  padding: 4px 0 10px;
}
.panel-section.grow {
  flex: 1;
  border-bottom: none;
  overflow: auto;
}
/* Title on the left, every action button grouped on the right (with two or
   more buttons, space-between used to push the middle one to the centre). */
.section-header {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 8px 0 12px;
}
.section-header h3 {
  margin: 0 auto 0 0;
  font-size: 11px;
  font-weight: 600;
}
.section-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px;
}
.subsection-title {
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 4px;
}
.hint {
  color: var(--text-muted);
  margin: 0;
  padding: 0 12px;
  line-height: 1.5;
}
.section-body .hint {
  padding: 0;
}

.selection-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 6px;
}
.selection-type {
  font-weight: 600;
}
.align-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 8px 8px;
  border-bottom: 1px solid var(--border);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.grid-2 > :only-child {
  grid-column: 1 / -1;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.row-label {
  color: var(--text-muted);
}

/* ---------- Fields ---------- */

.field {
  display: flex;
  align-items: center;
  height: var(--field-h);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  min-width: 0;
}
.field:hover {
  border-color: var(--border);
}
.field:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}
.field.disabled {
  opacity: 0.45;
}
.field-label {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 0 4px;
  color: var(--text-faint);
  cursor: ew-resize;
  user-select: none;
  font-size: 11px;
}
.select-wrap .field-label,
.text-field .field-label {
  cursor: default;
}
.field-input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0 6px 0 2px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.text-field .field-input {
  padding-left: 8px;
}
.field-input.mixed {
  color: var(--text-faint);
}
.field-input.invalid {
  color: var(--danger);
}
.field-suffix {
  color: var(--text-faint);
  padding-right: 6px;
  font-size: 11px;
}
.field-select {
  flex: 1;
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  height: var(--field-h);
  border: 1px solid transparent;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 0 4px;
  outline: none;
}
.select-wrap .field-select {
  border: none;
  background: transparent;
  height: 100%;
}
.field-select:focus {
  border-color: var(--accent);
}

.color-field {
  gap: 4px;
  padding-left: 4px;
  flex: 1;
}
.color-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  flex: none;
}
.color-swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-swatch::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}
.color-field .hex {
  flex: 2;
  text-transform: uppercase;
}
.color-field .opacity {
  flex: 1;
  text-align: right;
  padding-right: 0;
}

.paint-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.paint-row > .field,
.paint-row > .select-wrap {
  flex: 1;
}
.paint-row.muted > .field {
  opacity: 0.5;
}
.gradient-label {
  flex: 1;
  height: var(--field-h);
  border-radius: var(--radius);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.segment {
  border: none;
  background: transparent;
  border-radius: 4px;
  height: 24px;
  min-width: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}
.segment.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  min-height: 24px;
}
.checkbox input {
  accent-color: var(--accent);
  margin: 0;
}

.text-button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  height: var(--field-h);
  padding: 0 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.text-button:hover {
  background: var(--bg-hover);
}
.text-button.wide {
  width: 100%;
}

/* ---------- Layers ---------- */

.pages {
  display: flex;
  flex-direction: column;
  padding: 0 4px;
}
.page-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
}
.page-item:hover {
  background: var(--bg-hover);
}
.page-item.active {
  color: var(--text);
  font-weight: 600;
}

.layer-tree {
  padding: 0 4px 24px;
}
.layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding-right: 4px;
  border-radius: var(--radius);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.layer-row:hover,
.layer-row.hovered {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.layer-row.selected {
  background: var(--accent-soft);
}
.layer-row.child-of-selected {
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}
.layer-row.hidden-layer .label,
.layer-row.hidden-layer .type-icon {
  opacity: 0.45;
}
.layer-row .label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.type-frame .label {
  font-weight: 600;
}
.type-icon {
  color: var(--text-faint);
  display: flex;
}
.tree-toggle {
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  cursor: pointer;
}
.row-action {
  border: none;
  background: none;
  padding: 2px;
  color: var(--text-faint);
  cursor: pointer;
  display: none;
}
.layer-row:hover .row-action,
.row-action.on {
  display: flex;
}
.row-action:hover {
  color: var(--text);
}
.rename-input {
  flex: 1;
  min-width: 0;
  height: 22px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 4px;
  outline: none;
  background: var(--bg);
}
.layer-row.drop-before::before,
.layer-row.drop-after::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 4px;
  height: 2px;
  background: var(--accent);
}
.layer-row.drop-before::before {
  top: -1px;
}
.layer-row.drop-after::after {
  bottom: -1px;
}
.layer-row.drop-inside {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- Palette ---------- */

.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  z-index: 50;
}
.palette-backdrop[hidden] {
  display: none;
}
.palette {
  width: min(560px, calc(100vw - 32px));
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.palette-input {
  flex: 1;
  height: 48px;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--text);
}
.palette-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
}
.palette-item.active {
  background: var(--accent-soft);
}
.palette-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.palette-group {
  color: var(--text-faint);
  font-size: 11px;
}
.palette-empty {
  padding: 16px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 60;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #1e1e1e;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  max-width: min(560px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.error {
  background: var(--danger);
}
.toast-close {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 160ms ease-out;
  }
  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
  }
}

.panel-section,
.section-body > *,
.selection-header > * {
  min-width: 0;
  max-width: 100%;
}
.paint-row > * {
  min-width: 0;
}
.text-button {
  max-width: 100%;
}

/* ---------- Context menu ---------- */

.menu-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
}
.menu-layer[hidden] {
  display: none;
}
.menu {
  position: fixed;
  min-width: 220px;
  max-width: 320px;
  max-height: calc(100vh - 8px);
  overflow-y: auto;
  background: #1e1e1e;
  color: #f2f2f2;
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
  outline: none;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 26px;
  padding: 0 8px;
  border-radius: 5px;
  cursor: default;
  outline: none;
  white-space: pre;
}
.menu-item:focus,
.menu-item:hover {
  background: var(--accent);
  color: #fff;
}
.menu-item.disabled {
  opacity: 0.4;
  background: none;
}
.menu-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-shortcut {
  color: #a0a0a0;
  font-size: 11px;
}
.menu-item:focus .menu-shortcut,
.menu-item:hover .menu-shortcut {
  color: #e6f3ff;
}
.menu-separator {
  height: 1px;
  background: #3a3a3a;
  margin: 5px 4px;
}

@media (max-width: 1200px) {
  .save-status {
    display: none;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 0 minmax(0, 1fr) 240px;
  }
  .app .layers-panel {
    visibility: hidden;
  }
  .save-status {
    display: none;
  }
}

/* ---------- Components ---------- */

.panel-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.panel-tab {
  border: none;
  background: none;
  height: 30px;
  padding: 0 8px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 600;
}
.panel-tab:hover {
  color: var(--text);
}
.panel-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.panel-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tab-body {
  min-height: 0;
}

.type-component .label,
.type-component-set .label,
.type-instance .label,
.type-component .type-icon,
.type-component-set .type-icon,
.type-instance .type-icon,
.in-instance .type-icon {
  color: var(--component);
}
.type-component .label,
.type-component-set .label {
  font-weight: 600;
}
.layer-row.in-instance.selected,
.layer-row.type-instance.selected,
.layer-row.type-component.selected,
.layer-row.type-component-set.selected {
  background: var(--component-soft);
}
.layer-row.in-instance:hover,
.layer-row.type-instance:hover,
.layer-row.type-component:hover,
.layer-row.type-component-set:hover {
  box-shadow: inset 0 0 0 1px var(--component);
}

.selection-header.component-header .selection-type {
  color: var(--component);
}
.component-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--field-h);
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--component);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.component-link:hover {
  background: var(--component-soft);
}
.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-radius: var(--radius);
  padding: 6px 8px;
  line-height: 1.4;
  margin: 0;
}
.button-row {
  display: flex;
  gap: 6px;
}
.button-row > * {
  flex: 1;
  min-width: 0;
}
.button-row.wrap {
  flex-wrap: wrap;
}
.button-row.wrap > * {
  flex: 1 1 120px;
}
.prop-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px;
}
.prop-type {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}
.binding {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--component);
}
.binding {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hint.values {
  color: var(--text);
}
.overrides-list {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}
.override-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--component);
  flex: none;
  transform: translateY(-1px);
}

.assets-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px 24px;
}
.assets-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--field-h);
  margin: 0 4px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
}
.assets-search-wrap:focus-within {
  border-color: var(--accent);
}
.assets-search {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  height: 100%;
}
.assets-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.assets-group {
  color: var(--text-faint);
  font-size: 11px;
  padding: 8px 8px 2px;
}
.asset-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius);
  cursor: grab;
  user-select: none;
}
.asset-item:hover {
  background: var(--bg-hover);
}
.asset-item:focus-visible {
  outline: 2px solid var(--component);
  outline-offset: -2px;
}
.asset-thumb {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-subtle);
}
.asset-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.asset-name,
.asset-meta {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.asset-name {
  font-weight: 600;
}
.asset-meta {
  color: var(--text-faint);
  font-size: 11px;
}
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.text-button > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Paints ---------- */

.paint-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.paint-item:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}
.paint-item.muted > :not(.paint-row) {
  opacity: 0.5;
}
.paint-row > .select-wrap {
  flex: 1;
}
.gradient-editor,
.image-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gradient-preview {
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.stop-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
}
.stop-row .field-label:empty {
  display: none;
}
.image-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}
.image-thumb {
  width: 72px;
  height: 64px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#e6e6e6 0 25%, #fff 0 50%) 0 0 / 10px 10px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}
.image-thumb:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.image-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* ---------- Labelled lines, auto layout ---------- */

.prop-line {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}
.prop-label {
  color: var(--text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prop-line > .segmented {
  justify-self: start;
}
.segmented.with-text .segment {
  padding: 0 8px;
  gap: 4px;
}
.hint.small {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}
.align-block {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.align-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 76px;
  height: 62px;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.align-cell {
  border: none;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
}
.align-cell:hover {
  background: var(--bg-hover);
}
.align-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-faint);
}
.align-cell.active .align-dot {
  width: 14px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}
.align-cell:hover .align-dot {
  background: var(--text-muted);
}
.align-cell.active:hover .align-dot {
  background: var(--accent);
}
.sizing-row .field-label {
  min-width: 56px;
  justify-content: flex-start;
  padding-left: 8px;
}
.segmented.with-text {
  display: flex;
  width: 100%;
}
.segmented.with-text .segment {
  flex: 1;
}
.with-action {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.with-action > :first-child {
  flex: 1;
  min-width: 0;
}
.icon-button.on {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Panel resizing (FEAT-012) ---------- */

.canvas-area {
  position: relative;
}
.panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
}
.panel-resizer.left {
  left: -3px;
}
.panel-resizer.right {
  right: -3px;
}
.panel-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
  background: transparent;
  transition: background 0.12s;
}
.panel-resizer:hover::after,
.panel-resizer.dragging::after {
  background: var(--accent);
  width: 2px;
  left: 2.5px;
}
.app.hide-left .panel-resizer.left,
.app.hide-right .panel-resizer.right,
.app.hide-ui .panel-resizer {
  display: none;
}

/* ---------- Tool dock (FEAT-004) ---------- */

.tool-dock {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  max-width: calc(100% - 24px);
  overflow-x: auto;
}
.tool-dock .tool-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.dock-separator {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex: none;
}
.app.hide-ui .tool-dock {
  display: none;
}

/* ---------- Font picker (FEAT-005) ---------- */

.font-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.font-button {
  width: 100%;
  justify-content: space-between;
  padding: 0 6px 0 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.font-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-popover {
  position: fixed;
  z-index: 80;
  max-height: min(420px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.font-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.font-search {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  min-width: 0;
}
.font-list {
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}
.font-group {
  font-size: 11px;
  color: var(--text-faint);
  padding: 8px 8px 4px;
}
.font-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  cursor: pointer;
}
.font-item.active {
  background: var(--bg-hover);
}
.font-item.selected {
  color: var(--accent);
}
.font-item.missing {
  opacity: 0.55;
}
.font-preview {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-missing {
  font-size: 11px;
  color: var(--text-faint);
}
.font-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}
.font-footer:empty {
  display: none;
}

/* ---------- Gradient bar (BUG-015) ---------- */

.gradient-bar {
  position: relative;
  height: 34px;
  margin: 0 8px;
}
.gradient-strip {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: copy;
}
.gradient-stop {
  position: absolute;
  top: 14px;
  width: 16px;
  height: 20px;
  margin-left: -8px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: ew-resize;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  touch-action: none;
}
.gradient-stop::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  margin-left: -4px;
  border: 4px solid transparent;
  border-bottom-color: var(--border);
  border-top: none;
}
.gradient-stop-color {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 2px;
}
.gradient-stop.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.gradient-stop.selected::before {
  border-bottom-color: var(--accent);
}
.stop-row.selected .color-field {
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---------- Rich text controls ---------- */

.segmented.text-styles {
  display: flex;
  width: 100%;
}
.segmented.text-styles .segment {
  flex: 1;
  font-size: 13px;
}
.text-style.bold {
  font-weight: 700;
}
.text-style.italic {
  font-style: italic;
  font-family: Georgia, serif;
}
.text-style.underline {
  text-decoration: underline;
}
.text-style.strike {
  text-decoration: line-through;
}
.text-scope {
  background: var(--accent-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
}
.grid-2.align-center {
  align-items: center;
}
.segmented.with-text .segment span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.segmented.with-text .segment {
  min-width: 0;
}

/* ---------- Tool flyout (FEAT-024) ---------- */

.tool-group {
  display: inline-flex;
  align-items: center;
}
.tool-chevron {
  width: 16px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tool-chevron:hover,
.tool-chevron.open {
  background: var(--bg-hover);
  color: var(--text);
}
.tool-flyout {
  position: fixed;
  z-index: 80;
  min-width: 220px;
  padding: 6px;
  background: #1e1e1e;
  color: #f2f2f2;
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}
.tool-flyout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border: none;
  background: none;
  color: inherit;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.tool-flyout-item:hover,
.tool-flyout-item:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}
.tool-flyout-item.active .tool-flyout-label::after {
  content: ' ✓';
}
.tool-flyout-label {
  flex: 1;
}
.tool-flyout-key {
  color: #a0a0a0;
  font-size: 11px;
}
.tool-flyout-item:hover .tool-flyout-key {
  color: #e6f3ff;
}

.export-row {
  display: grid;
  grid-template-columns: 62px 72px minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
}
.export-suffix {
  padding-left: 8px;
}

/* Quick export: format dropdown + one button (BUG-027). */
.export-row.quick {
  grid-template-columns: minmax(0, 1fr) auto;
}
.layer-row .type-icon.mask {
  color: var(--accent);
}

/* ---------- Styles (stage 4, FR-STY) ---------- */
.style-popover {
  position: fixed;
  z-index: 80;
  max-height: min(460px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.style-picker {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}
.style-picker > .hint {
  padding: 0 10px 8px;
  margin: 0;
}
.style-list {
  overflow-y: auto;
  padding: 4px;
  flex: 1;
  min-height: 40px;
}
.style-list > .hint {
  padding: 8px;
  margin: 0;
}
.style-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.style-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.style-item.local {
  grid-template-columns: 20px minmax(0, 1fr) auto auto;
  padding-right: 2px;
}
.style-item.local .style-meta {
  display: none;
}
.style-item.local .icon-button {
  opacity: 0;
}
.style-item.local:hover .icon-button,
.style-item.local:focus-within .icon-button {
  opacity: 1;
}
.style-item:hover,
.style-item.active {
  background: var(--bg-hover);
}
.style-item.selected .style-name {
  color: var(--accent);
}
.style-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.style-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.style-name.muted {
  color: var(--text-muted);
  flex: 1;
}
.style-meta,
.style-count {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.style-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  background-clip: padding-box;
  flex: none;
}
.style-glyph {
  width: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text);
  flex: none;
}
.style-effect {
  width: 14px;
  height: 14px;
  margin: 1px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  flex: none;
}
.style-effect.blur {
  background: linear-gradient(135deg, var(--bg-hover), var(--bg));
  filter: blur(0.6px);
}
.style-folder {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-faint);
  padding: 6px 2px 2px;
}
.style-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: var(--field-h);
}
.style-row:empty {
  display: none;
}
.style-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--field-h);
  padding: 0 6px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.style-open:hover {
  background: var(--bg-hover);
}
.style-open .style-name {
  flex: 1;
}
.style-menu {
  display: flex;
  flex-direction: column;
  padding: 4px;
  overflow-y: auto;
}
.style-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.style-menu-item:hover:not(:disabled) {
  background: var(--bg-hover);
}
.style-menu-item:disabled {
  color: var(--text-faint);
  cursor: default;
}
.style-menu-title {
  font-size: 11px;
  color: var(--text-faint);
  padding: 8px 8px 2px;
}
.style-editor-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 4px;
}
.style-editor-header h3 {
  flex: 1;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}
.style-editor-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: repeating-conic-gradient(var(--bg-hover) 0 25%, var(--bg) 0 50%) 0 0 / 12px 12px;
  overflow: hidden;
}
.style-editor-preview .style-swatch {
  width: 100%;
  height: 56px;
  border-radius: 8px;
}
.style-editor-preview .style-effect {
  width: 64px;
  height: 36px;
  border-radius: 6px;
}
.style-editor-preview.kind-text {
  background: var(--bg-subtle);
  justify-content: flex-start;
  padding: 10px;
}
.style-text-sample {
  color: var(--text);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.text-button.danger {
  color: var(--danger);
}

/* ---------- Variables (stage 4, FR-VAR) ---------- */
.text-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.text-button.primary:hover {
  background: #0b85e0;
}
.text-button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Bindable fields in the properties panel */
.bindable {
  position: relative;
  min-width: 0;
}
.bindable > .field,
.bindable > .color-field {
  width: 100%;
}
.var-bind {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.var-bind[hidden] {
  display: none !important;
}
.bindable:hover .var-bind,
.bindable:focus-within .var-bind {
  display: inline-flex;
}
.var-bind:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.bindable.has-match .var-bind {
  display: inline-flex;
  color: var(--accent);
}
.bindable.has-match .var-bind::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.var-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--field-h);
  min-width: 0;
}
.var-pill[hidden] {
  display: none;
}
.var-pill-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--field-h);
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.var-pill-open .icon {
  color: var(--accent);
  flex: none;
}
.var-pill-open:hover {
  border-color: var(--accent);
}
.var-pill-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.var-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  flex: none;
}
.var-value {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
.var-picker-footer {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.mode-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Variables table dialog */
.vars-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  padding: 24px;
}
.vars-overlay[hidden] {
  display: none;
}
.vars-dialog {
  display: flex;
  flex-direction: column;
  width: min(1280px, 100%);
  height: min(820px, 100%);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  font: var(--font);
}
.vars-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.vars-header h2 {
  margin: 0 8px 0 4px;
  font-size: 13px;
  font-weight: 600;
}
.vars-header .field {
  width: 150px;
  flex: none;
}
.vars-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--field-h);
  padding: 0 8px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text-faint);
  min-width: 120px;
}
.vars-search {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  min-width: 0;
}
.vars-main {
  flex: 1;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 280px;
  min-height: 0;
}
.vars-side {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 6px;
}
.vars-side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 6px 4px;
}
.vars-collection,
.vars-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 4px 0 8px;
  border-radius: 6px;
  cursor: pointer;
}
.vars-collection:hover,
.vars-group:hover {
  background: var(--bg-hover);
}
.vars-collection.active,
.vars-group.active {
  background: var(--accent-soft);
}
.vars-collection-name,
.vars-group > span:nth-of-type(1) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vars-collection .icon-button {
  opacity: 0;
}
.vars-collection:hover .icon-button,
.vars-collection.active .icon-button {
  opacity: 1;
}
.vars-group.has-hits {
  color: var(--accent);
  font-weight: 600;
}
.vars-count {
  font-size: 11px;
  color: var(--text-faint);
}
.vars-center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.vars-scroller {
  flex: 1;
  overflow: auto;
  outline: none;
  position: relative;
}
.vars-row {
  display: grid;
  height: 32px;
  border-bottom: 1px solid var(--border);
  min-width: max-content;
}
.vars-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
}
.vars-body-rows {
  position: relative;
}
.vars-rows {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
.vars-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}
.vars-cell:last-child {
  border-right: none;
}
.vars-head-cell .icon-button {
  margin-left: auto;
  opacity: 0;
}
.vars-head-cell:hover .icon-button,
.vars-add-mode .icon-button {
  opacity: 1;
}
.vars-add-mode {
  padding: 0 2px;
  justify-content: center;
}
.vars-mode-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.vars-default {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-faint);
}
.vars-group-row {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
}
.vars-group-row .vars-cell {
  grid-column: 1 / -1;
  border-right: none;
}
.vars-row.selected .vars-name {
  background: var(--accent-soft);
}
.vars-cell.active {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.vars-cell.in-range {
  background: var(--accent-soft);
}
.vars-cell.editing {
  padding: 0 2px;
}
.vars-type {
  display: inline-flex;
  color: var(--text-faint);
}
.vars-name-text,
.vars-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.vars-badge {
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.vars-muted {
  color: var(--text-faint);
  font-size: 11px;
}
.vars-swatch-wrap {
  position: relative;
  display: inline-flex;
}
.vars-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}
.vars-alias {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 22px;
  padding: 0 8px 0 6px;
  border-radius: 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
}
.vars-alias-opacity {
  font-size: 11px;
  color: var(--text-muted);
}
.vars-input {
  width: 100%;
  height: 26px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.vars-input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(224, 62, 26, 0.15);
}
.vars-empty {
  padding: 40px 24px;
  max-width: 520px;
  color: var(--text-muted);
  line-height: 1.5;
}
.vars-empty .text-button {
  margin-top: 8px;
}
.vars-bulk {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-wrap: wrap;
}
.vars-bulk[hidden] {
  display: none;
}
.vars-bulk-count {
  font-weight: 600;
  margin-right: 6px;
}
.vars-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}
.vars-scopes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.style-popover .vars-scopes {
  padding: 10px;
}
.checkbox.indent {
  padding-left: 18px;
}
.vars-details {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 12px 16px;
}
.vars-details > .hint {
  margin-top: 12px;
}
.vars-detail-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.vars-detail-section h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
}
.vars-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.vars-textarea {
  height: auto;
  min-height: 48px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid transparent;
  resize: vertical;
  font: inherit;
  color: var(--text);
}
.vars-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}
.vars-code {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vars-code .field-label {
  width: 56px;
  flex: none;
}
.vars-usages,
.vars-chain {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vars-usage {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.vars-usage:hover {
  background: var(--bg-hover);
}
.vars-usage-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vars-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.vars-details .button-row {
  margin-top: 12px;
  display: flex;
  gap: 6px;
}
.bindable > [hidden] {
  display: none !important;
}
.vars-textarea {
  width: 100%;
  box-sizing: border-box;
}
.vars-import {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: inherit;
  min-height: 0;
}
.vars-import h3 {
  margin: 0;
  font-size: 12px;
}
.vars-import-list {
  overflow-y: auto;
  min-height: 0;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vars-import-item {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vars-import-item.added {
  color: #14ae5c;
}
.vars-import-item.warning {
  color: var(--warning-text);
  white-space: normal;
}
.vars-import .button-row {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ---------- Precision (stage 5) ---------- */
.guide-input {
  position: absolute;
  z-index: 5;
  width: 80px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: var(--font);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  outline: none;
}
.row.end {
  justify-content: space-between;
}
.icon-button.on {
  color: var(--accent);
  background: var(--accent-soft);
}
.stroke-more {
  margin-top: 4px;
}
.stroke-more > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
  list-style: none;
}
.stroke-more > summary::before {
  content: '▸ ';
}
.stroke-more[open] > summary::before {
  content: '▾ ';
}
.stroke-more > .grid-2 {
  margin-top: 4px;
}
.style-grid {
  background-color: var(--bg);
}

/* ---------- Layers search (stage 6) ---------- */
.layers-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 6px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}
.layers-search {
  flex: 1;
  min-width: 0;
  height: 24px;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
}
.layers-filter {
  height: 24px;
  max-width: 96px;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}
.layers-found {
  font-size: 11px;
  color: var(--text-faint);
  padding: 6px 10px 4px;
}
.layer-row.found {
  padding-left: 10px;
}
.layer-row.found .label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  padding: 3px 0;
}
.layer-path {
  font-size: 10px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Files (stage 6) ---------- */
.files-dialog {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(640px, 100%);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  font: var(--font);
}
.files-list {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
  min-height: 120px;
}
.files-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 8px;
  border-radius: 8px;
  cursor: pointer;
}
.files-row:hover,
.files-row:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.files-row.current {
  background: var(--accent-soft);
}
.files-row > .icon {
  color: var(--text-faint);
  flex: none;
}
.files-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.files-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.files-meta {
  font-size: 11px;
  color: var(--text-faint);
}
.files-row .icon-button,
.files-delete {
  opacity: 0;
}
.files-row:hover .icon-button,
.files-row:hover .files-delete,
.files-row:focus-within .icon-button,
.files-delete.danger {
  opacity: 1;
}
.files-note {
  padding: 8px 14px 12px;
  margin: 0;
  border-top: 1px solid var(--border);
}
.files-button {
  margin-left: -6px;
}

/* ---------- Sections (FR-CNV-070, 071) ---------- */
.section-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.section-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  cursor: pointer;
}
.section-swatch:hover,
.section-swatch:focus-visible {
  outline: 2px solid var(--accent, #0d99ff);
  outline-offset: 1px;
}

/* ---------- Prototype: panel tabs and the Prototype tab (FR-PRT-001–003) ---------- */
.panel-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 8px 0 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.panel-tab {
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  padding: 6px 8px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.panel-tab:hover {
  color: var(--text);
}
.panel-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.panel-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.panel-play {
  margin-left: auto;
}
.proto-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.proto-head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.proto-head .proto-select {
  flex: 1;
  min-width: 0;
}
.proto-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--accent-soft);
}
.proto-select.proto-missing {
  color: var(--danger);
}
.proto-input {
  width: 100%;
  box-sizing: border-box;
  height: var(--field-h);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text);
  font: inherit;
  padding: 0 8px;
}
.proto-input:focus {
  outline: none;
  border-color: var(--accent);
}
.proto-desc {
  height: auto;
  padding: 6px 8px;
  resize: vertical;
}
.proto-number {
  width: 96px;
}
.proto-key {
  width: 120px;
  cursor: pointer;
  text-align: center;
}
.proto-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.proto-check {
  font-size: 11px;
}
.proto-add-action {
  align-self: flex-start;
  color: var(--text-muted);
}
.proto-present {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.proto-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.proto-color {
  width: 40px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
}
.flow-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.flow-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.flow-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-screen {
  padding: 0;
  height: auto;
  border: 0;
  background: none;
  color: var(--text-muted);
  text-align: left;
}
.flow-screen:hover {
  color: var(--accent);
  background: none;
}

/* ---------- Prototype viewer (FR-PRT-050, 051) ---------- */
.player {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  color: #f0f0f0;
}
.player.standalone {
  position: absolute;
}
.player-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 8px;
  background: #2c2c2c;
  border-bottom: 1px solid #3a3a3a;
  flex: none;
  min-width: 0;
}
.player-bar .icon-button {
  color: #f0f0f0;
}
.player-bar .icon-button:hover {
  background: #3a3a3a;
}
.player-bar .icon-button:disabled {
  opacity: 0.35;
}
.player-bar .field-select {
  background: #383838;
  color: #f0f0f0;
  width: auto;
  max-width: 180px;
}
.player-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 30vw;
}
.player-spacer {
  flex: 1;
}
.player-check {
  color: #c8c8c8;
  white-space: nowrap;
}
.player-stage {
  position: relative;
  flex: 1;
  min-height: 0;
}
.player-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
@media (max-width: 640px) {
  .player-check,
  .player-scale {
    display: none;
  }
}

/* ---------- Prototype transitions (FR-PRT-020, 021) ---------- */
.proto-transition {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}
.proto-transition .proto-line .proto-select {
  flex: 1;
  width: auto;
  min-width: 0;
  max-width: 140px;
}
.proto-transition .proto-line .field-label {
  flex: none;
}
.proto-dirs {
  display: flex;
  gap: 2px;
}
.proto-dir {
  width: 28px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.proto-dir.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.proto-dir:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.proto-spring {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.proto-spring-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.proto-spring-field .field-label {
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.curve-editor {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.curve-canvas {
  width: 220px;
  height: 132px;
  max-width: 100%;
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
.curve-canvas.editable {
  cursor: crosshair;
  touch-action: none;
}
.curve-values {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Prototype: overlays, scrolling (FR-PRT-011, 030) ---------- */
.proto-offsets {
  display: flex;
  gap: 4px;
}
.proto-offset {
  display: flex;
  align-items: center;
  gap: 3px;
}
.proto-offset .proto-input {
  width: 48px;
  padding: 0 4px;
}
.proto-line:has(.proto-offsets) {
  flex-wrap: wrap;
  row-gap: 4px;
}
.proto-dim {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.proto-percent {
  width: 52px;
}

/* ---------- Prototype logic: expressions, conditions, debugger (FR-PRT-040–043) ---------- */
.proto-expr-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.proto-expr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.proto-insert {
  width: 44px;
  flex: none;
  padding: 0 2px;
}
.proto-expr-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.proto-expr-status.ok {
  color: #14ae5c;
}
.proto-expr-status.error {
  color: var(--danger);
}
.proto-expr-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
.proto-expr-code mark {
  background: none;
  color: var(--danger);
  text-decoration: underline wavy var(--danger);
}
.proto-branch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.proto-branch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.proto-branch-label {
  font-weight: 600;
  color: var(--component);
}

.player-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.player-body .player-stage {
  flex: 1;
  min-width: 0;
}
.player-debug {
  width: 280px;
  flex: none;
  overflow-y: auto;
  background: #252525;
  border-left: 1px solid #3a3a3a;
  padding: 8px 12px 16px;
  font-size: 12px;
}
.player-debug h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9a9a9a;
  margin: 12px 0 6px;
}
.player-var {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #333;
}
.player-var-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-var-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #8fd3ff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid #555;
}
.player-log-entry {
  padding: 4px 0;
  border-bottom: 1px solid #333;
}
.player-log-cause {
  color: #c8c8c8;
}
.player-log-cause time {
  color: #777;
  font-variant-numeric: tabular-nums;
}
.player-log-line {
  padding-left: 10px;
  color: #a8e6b8;
}
.player-log-line.error {
  color: #ff8f7a;
}
.player-empty {
  color: #777;
}
.player-bar .icon-button.active {
  background: #0d99ff;
  color: #fff;
}
@media (max-width: 640px) {
  .player-debug {
    position: absolute;
    right: 0;
    top: 44px;
    bottom: 0;
    z-index: 2;
  }
}
.proto-transition .proto-number {
  width: 72px;
}
.proto-branch .curve-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 220 / 132;
}

/* ---------- Sign-in (stage "Server") ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg-subtle);
  overflow-y: auto;
}
.auth-card {
  width: min(380px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: 8px;
}
.auth-tab {
  flex: 1;
  border: 0;
  border-radius: 6px;
  padding: 6px;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.auth-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-submit {
  height: 38px;
  justify-content: center;
  font-size: 14px;
}
.auth-error {
  margin: 0;
  min-height: 1em;
  color: var(--danger);
  font-size: 12px;
}
.auth-error:empty {
  display: none;
}
.auth-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}
.auth-hint:empty {
  display: none;
}
.auth-local {
  align-self: center;
  color: var(--text-muted);
  font-size: 12px;
}
.account-button {
  width: 28px;
  height: 28px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.account-button.signed-in {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.account-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.files-upload {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 12px;
}
.auth-field[hidden] {
  display: none;
}
.auth-local {
  height: auto;
  min-height: 28px;
  white-space: normal;
  text-align: center;
  border-color: transparent;
  background: none;
}
.auth-local:hover {
  color: var(--text);
  background: var(--bg-subtle);
}
.auth-tabs[hidden],
.auth-link[hidden] {
  display: none;
}
.auth-links {
  display: flex;
  justify-content: center;
}
.auth-link {
  padding: 2px 4px;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.auth-link:hover {
  text-decoration: underline;
}
.auth-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Home screen (file browser): sidebar with sections and projects, file cards
   with previews — the start page, as in Figma. */
.home {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px 10px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.home-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 6px;
  font-size: 14px;
  font-weight: 600;
}
.home-mark {
  display: grid;
  grid-template-columns: 9px 9px;
  gap: 3px;
}
.home-mark i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}
.home-account {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-account:hover {
  background: var(--bg-hover);
}
.home-account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.home-account-text strong,
.home-account-text small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.home-account-text strong {
  font-weight: 600;
}
.home-account-text small {
  color: var(--text-muted);
  font-size: 11px;
}
.home-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.home-avatar.signed-in {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.home-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  margin: 2px 0 4px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.home-search:focus-within {
  border-color: var(--accent);
}
.home-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
}
.home-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.home-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-nav-item svg {
  flex: none;
  color: var(--text-muted);
}
.home-nav-item:hover {
  background: var(--bg-hover);
}
.home-nav-item.active {
  background: var(--accent-soft);
  font-weight: 600;
}
.home-nav-item.active svg {
  color: var(--accent);
}
.home-nav-item.drop {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.home-nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.home-nav-count {
  color: var(--text-faint);
  font-size: 11px;
}
.home-nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 4px 2px 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.home-nav-hint {
  margin: 2px 8px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
}
.home-sidebar-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.home-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}
.home-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 32px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
}
.home-banner[hidden] {
  display: none;
}
.home-main {
  padding: 24px 32px 40px;
}
.home-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}
.home-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.home-header-spacer {
  flex: 1;
}
.home-new {
  text-decoration: none;
  gap: 6px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
  outline: none;
}
.home-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-faint);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.home-card:hover .home-thumb,
.home-card:focus-visible .home-thumb {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.home-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 0 28px 0 2px;
}
.home-card-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
}
.home-card-meta {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 12px;
}
.home-card-more {
  position: absolute;
  right: 0;
  bottom: 4px;
  opacity: 0;
}
.home-card:hover .home-card-more,
.home-card:focus-within .home-card-more {
  opacity: 1;
}
@media (hover: none) {
  .home-card-more {
    opacity: 1;
  }
}
.home-rename {
  width: 100%;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}
.home-title + .home-rename,
.home-header .home-rename {
  max-width: 360px;
  height: 30px;
  font-size: 18px;
}
.home-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 460px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.home-empty p {
  margin: 0;
}
.home-empty a,
.home-missing a {
  text-decoration: none;
  gap: 6px;
}
.home-missing {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
}
.home-button {
  width: auto;
  gap: 4px;
  padding: 0 8px 0 4px;
  font-size: 12px;
}
@media (max-width: 720px) {
  .home {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .home-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .home-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .home-nav-item {
    width: auto;
  }
  .home-nav-heading,
  .home-nav-hint,
  .home-sidebar-footer {
    display: none;
  }
  .home-main {
    padding: 16px;
  }
  .home-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }
}

/* Own dialogs instead of the browser's prompt / confirm / alert (ui/dialog.ts). */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.32);
  animation: dialog-fade 0.12s ease-out;
}
.dialog {
  width: min(400px, 100%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  font: var(--font);
  font-size: 13px;
  animation: dialog-pop 0.14s ease-out;
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 4px 18px;
}
.dialog-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 18px 4px;
}
.dialog-message {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}
.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.dialog-input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.dialog-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.dialog-hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
}
.dialog-error {
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}
.dialog-error:empty {
  display: none;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px 16px;
}
.text-button.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.text-button.danger-solid:hover {
  filter: brightness(1.08);
}
@keyframes dialog-fade {
  from { opacity: 0; }
}
@keyframes dialog-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
}
@media (prefers-reduced-motion: reduce) {
  .dialog-overlay,
  .dialog {
    animation: none;
  }
}

/* Sharing: the "Share" dialog, the button and the view-only badge. */
.share-button {
  height: 28px;
  margin: 0 4px 0 8px;
  padding: 0 12px;
}
.share-button[hidden],
.view-only-badge[hidden],
.save-status[hidden] {
  display: none;
}
.view-only-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 11px;
}
/* View-only: no drawing tools; panning, zoom and selection still work. */
.app.read-only .tool-dock {
  display: none;
}
.share-dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}
.share-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 18px 0;
  overflow-y: auto;
}
.share-error {
  padding: 0 18px;
}
.share-error .dialog-error:not(:empty) {
  padding-bottom: 6px;
}
.share-invite {
  display: flex;
  gap: 6px;
}
.share-email {
  flex: 1;
  min-width: 0;
}
.share-select {
  height: 32px;
  max-width: 200px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.share-select:focus {
  outline: none;
  border-color: var(--accent);
}
.share-select[hidden] {
  display: none;
}
.share-heading {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.share-people {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.share-person {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.share-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.share-person-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.share-person-text strong,
.share-person-text small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.share-person-text strong {
  font-weight: 600;
}
.share-person-text small {
  color: var(--text-muted);
  font-size: 11px;
}
.share-muted {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.share-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.share-link-row .share-select:first-of-type {
  flex: 1;
  max-width: none;
}
.share-link-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-subtle);
}
.share-link-settings[hidden] {
  display: none;
}
.share-setting {
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-setting > span:first-child {
  width: 56px;
  flex: none;
  color: var(--text-muted);
  font-size: 12px;
}
.share-setting .dialog-input {
  flex: 1;
  min-width: 0;
  height: 30px;
}
.share-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.share-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 16px;
}
.share-footer .text-button {
  gap: 6px;
}
.share-spacer {
  flex: 1;
}
.share-url {
  width: 100%;
  margin-bottom: 12px;
}
.home-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.home-missing-actions {
  display: flex;
  gap: 8px;
}
@media (max-width: 560px) {
  .share-invite {
    flex-wrap: wrap;
  }
  .share-email {
    flex-basis: 100%;
  }
}

/* Who else is in the file now (live editing): avatars in their colours. */
.peers {
  display: flex;
  align-items: center;
  margin-left: 6px;
}
.peers:empty {
  display: none;
}
.peer {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: -6px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
}
.peer:first-child {
  margin-left: 0;
}
.peer.more {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* Folded block of rare settings ("Дополнительно") with plain explanations. */
.foldout {
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.foldout > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.foldout > summary::-webkit-details-marker {
  display: none;
}
.foldout > summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s;
}
.foldout[open] > summary::before {
  transform: rotate(90deg);
}
.foldout > summary:hover {
  color: var(--text);
}
.foldout-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
}
.field-explain {
  margin: -2px 0 4px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.4;
}

/* Collaborators' pointers and selections over the canvas. */
.peer-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.peer-selection {
  position: absolute;
  border: 2px solid;
  border-radius: 2px;
}
.peer-cursor {
  position: absolute;
  left: 0;
  top: 0;
  transition: transform 0.08s linear;
  will-change: transform;
}
.peer-cursor svg {
  display: block;
  margin: -2px 0 0 -2px;
}
.peer-name {
  position: absolute;
  left: 14px;
  top: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .peer-cursor {
    transition: none;
  }
}

/* "Import HTML" window: settings on the left, live preview on the right. */
.hi-dialog {
  width: min(1040px, 100%);
  height: min(720px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
}
.hi-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 4px 18px 0;
}
.hi-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.hi-pane[hidden] {
  display: none;
}
.hi-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
}
.hi-drop strong {
  color: var(--text);
  font-size: 13px;
}
.hi-drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.hi-drop-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.hi-file {
  margin: 6px 0 0;
  font-size: 12px;
  word-break: break-all;
}
.hi-file[hidden] {
  display: none;
}
.hi-code {
  width: 100%;
  height: 160px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: 11px/1.4 'SF Mono', Menlo, Consolas, monospace;
  resize: vertical;
}
.hi-code:focus {
  outline: none;
  border-color: var(--accent);
}
.hi-width {
  flex: 1;
  max-width: none;
}
.hi-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}
.hi-check input {
  margin-top: 2px;
}
.hi-check span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hi-check small {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.35;
}
.hi-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 6px;
}
.hi-preview {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--bg-subtle);
  overflow: hidden;
}
.hi-preview-inner {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  background: #fff;
}
.hi-preview-inner iframe {
  position: absolute;
  left: 0;
  top: 0;
  border: 0;
  transform-origin: 0 0;
  background: #fff;
}
.hi-empty,
.hi-note {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
}
.hi-footer {
  align-items: center;
}
.hi-status {
  flex: 1;
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}
.hi-status.error {
  color: var(--danger);
}
@media (max-width: 760px) {
  .hi-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .hi-preview {
    min-height: 260px;
  }
}
.stroke-more.foldout[open] {
  padding-bottom: 8px;
}
.stroke-more.foldout > .grid-2 + .grid-2 {
  margin-top: 6px;
}

/* Our colour picker (ui/color-picker.ts). */
button.vars-color-input {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.color-picker {
  position: fixed;
  z-index: 3500;
  width: 240px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  font: var(--font);
}
.cp-sv {
  position: relative;
  height: 160px;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
.cp-sv-white,
.cp-sv-black {
  position: absolute;
  inset: 0;
  border-radius: 6px;
}
.cp-sv-white {
  background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}
.cp-sv-black {
  background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
}
.cp-knob {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.cp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cp-sliders {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-slider {
  position: relative;
  height: 12px;
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.cp-slider[hidden] {
  display: none;
}
.cp-slider:focus-visible,
.cp-sv:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}
.cp-hue {
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.cp-alpha {
  background-color: #fff;
  background-image: linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%), linear-gradient(45deg, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
}
.cp-alpha-fill {
  position: absolute;
  inset: 0;
  border-radius: 6px;
}
.cp-slider-knob {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.cp-dropper {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
}
.cp-dropper[hidden] {
  display: none;
}
.cp-inputs .cp-label {
  color: var(--text-muted);
  font-size: 11px;
}
.cp-hex {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
}
.cp-pct {
  width: 44px;
  text-align: right;
}
.cp-pct[hidden] {
  display: none;
}
.cp-swatches-title {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 11px;
}
.cp-swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}
.cp-swatch {
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
.cp-swatch:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Components tab: what it is, and explicit actions on every component. */
.assets-intro {
  margin: 8px 12px 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}
.asset-item {
  position: relative;
}
.asset-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
}
.asset-item:hover .asset-actions,
.asset-item:focus-within .asset-actions {
  opacity: 1;
}
@media (hover: none) {
  .asset-actions {
    opacity: 1;
  }
}
.asset-action {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

/* The layer list is a list of objects, not text: Shift/⌘ clicks must never select text in it (Safari). */
.layers-panel,
.layers-panel * {
  user-select: none;
  -webkit-user-select: none;
}
.layers-panel input,
.layers-panel textarea {
  user-select: text;
  -webkit-user-select: text;
}
/* The editor's chrome is controls, not text to copy: no stray text selection anywhere (fields excepted). */
.app {
  user-select: none;
  -webkit-user-select: none;
}
.app input,
.app textarea,
.app [contenteditable='true'] {
  user-select: text;
  -webkit-user-select: text;
}
