:root {
  --bg: #0b0f1a;
  --bg-alt: #101523;
  --bg-card: #141a2c;
  --cream: #f3ead8;
  --cream-dim: #cfc6b6;
  --gold: #e7c98a;
  --muted: #8d94a6;
  --line: rgba(255, 255, 255, 0.08);
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --radius: 12px;

  --kimi-font-sans: var(--font-body);
  --kimi-font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --kimi-color-text-primary: var(--cream);
  --kimi-color-text-secondary: var(--cream-dim);
  --kimi-color-text-tertiary: var(--muted);
  --kimi-color-text-quaternary: #6d7484;
  --kimi-color-border: var(--line);
  --kimi-color-surface: var(--bg-alt);
  --kimi-color-hover: rgba(231, 201, 138, 0.12);
  --kimi-color-danger: #ffb4a2;
  --kimi-color-positive: var(--gold);
  --kimi-chart-1: var(--gold);
  --stage-fill: #080b14;
  --grid: rgba(255, 255, 255, 0.06);
  --axis: rgba(243, 234, 216, 0.35);
  --axis-label: rgba(243, 234, 216, 0.55);
  --accent-ink: #0b0f1a;
}

* {
  box-sizing: border-box;
}

/* Dark-themed scrollbars  -  otherwise horizontal/vertical overflow
   (e.g. .preview, .block-body-input) shows the OS default white bar. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(231, 201, 138, 0.35) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(231, 201, 138, 0.3);
  border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(231, 201, 138, 0.5);
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: calc(100% * var(--a11y-font-scale, 1));
}

html[data-theme="cream"] {
  --bg: #f3ead8;
  --bg-alt: #ede1c8;
  --bg-card: #ffffff;
  --cream: #0b0f1a;
  --cream-dim: #5c5340;
  --gold: #8a5e14;
  --muted: #5c5340;
  --line: rgba(11, 15, 26, 0.12);
  --kimi-color-hover: rgba(11, 15, 26, 0.08);
  --stage-fill: #f7f1e4;
  --grid: rgba(11, 15, 26, 0.08);
  --axis: rgba(11, 15, 26, 0.4);
  --axis-label: rgba(11, 15, 26, 0.55);
  --accent-ink: #f3ead8;
}

html[data-theme="gold"] {
  --bg: #101526;
  --bg-alt: #1b2340;
  --bg-card: #241c12;
  --cream: #f3ead8;
  --cream-dim: #cfc6b6;
  --gold: #e7c98a;
  --muted: #cfc6b6;
  --line: rgba(231, 201, 138, 0.18);
  --stage-fill: #0e121c;
  --grid: rgba(231, 201, 138, 0.08);
  --axis: rgba(231, 201, 138, 0.4);
  --axis-label: rgba(243, 234, 216, 0.6);
}

html[data-theme="contrast"] {
  --bg: #000;
  --bg-alt: #000;
  --bg-card: #111;
  --cream: #fff;
  --cream-dim: #ddd;
  --gold: #fff;
  --muted: #ddd;
  --line: #fff;
  --kimi-color-hover: rgba(255, 255, 255, 0.12);
  --stage-fill: #000;
  --grid: rgba(255, 255, 255, 0.25);
  --axis: #ffff00;
  --axis-label: #fff;
  --accent-ink: #000;
}

.axiom-studio {
  font-family: var(--font-body);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.axiom-studio button,
.axiom-studio input,
.axiom-studio select,
.axiom-studio textarea {
  font-family: inherit;
  color: inherit;
}

.axiom-studio svg text {
  font-family: var(--font-body);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 7.5rem;
  margin-right: 4px;
  /* Without this, the flex layout shrinks .brand down to min-width
     whenever the topbar is tight, but its content (mark + wordmark +
     the role badge appended by axiom-gate.js) doesn't shrink to match  - 
     it just overflows the box and spills over .topbar-title next to it. */
  flex-shrink: 0;
}

.mark {
  color: var(--gold);
  font-size: 1.45rem;
  line-height: 1;
  display: inline-block;
  border-radius: 6px;
  vertical-align: middle;
}

.kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.1;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  min-width: 160px;
  flex: 1;
  background: transparent;
  border: none;
  color: var(--cream);
  padding: 4px 6px;
  border-radius: 6px;
}

.topbar-title:focus {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}

.topbar-transport {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-modes {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.topbar-modes > .popout > .btn {
  min-width: 5.6rem;
  justify-content: center;
}

.axiom-studio.is-giving #popout-plan {
  display: none;
}

.btn {
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--cream-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Same [hidden]-defeating bug as .axiom-cloud-panel/.sheet  -  display set
   unconditionally on the bare class means any button ever hidden via
   el.hidden = true (e.g. #btn-cloud when Supabase isn't configured) never
   actually disappears. */
.btn:not([hidden]) {
  display: inline-flex;
}

.btn:hover {
  background: var(--kimi-color-hover);
  color: var(--cream);
  border-color: rgba(231, 201, 138, 0.35);
}

.btn.is-active,
.btn.is-on {
  background: var(--gold);
  color: var(--accent-ink);
  border-color: var(--gold);
}

.btn-danger {
  border-color: rgba(224, 138, 138, 0.5);
  color: #e08a8a;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(224, 138, 138, 0.12);
  border-color: #e08a8a;
  color: #e08a8a;
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-icon {
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  gap: 4px;
}

.btn-speed {
  min-width: 2.6rem;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#btn-rec.is-on {
  background: rgba(196, 42, 42, 0.16);
  color: #e23b3b;
  border-color: rgba(226, 59, 59, 0.55);
}

#btn-rec.is-on svg {
  fill: #e23b3b;
  animation: rec-blink 1s ease-in-out infinite;
}

@keyframes rec-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.status-dot.on {
  background: var(--gold);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 0;
}

.toolbar.is-floating {
  position: fixed;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  flex-wrap: nowrap;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
}

.toolbar-drag-handle {
  background: none;
  border: none;
  color: var(--cream-dim);
  cursor: grab;
  padding: 2px 4px;
  flex-shrink: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar-drag-handle svg {
  width: 14px;
  height: 14px;
}

.toolbar-drag-handle:hover {
  color: var(--gold);
  background: rgba(231, 201, 138, 0.1);
}

.toolbar-drag-handle:active {
  cursor: grabbing;
}

.toolbar.is-floating .toolbar-drag-handle {
  color: var(--gold);
}

.toolbar-collapse-btn {
  background: none;
  border: none;
  color: var(--cream-dim);
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.toolbar-collapse-btn svg {
  width: 14px;
  height: 14px;
}

.toolbar-collapse-btn:hover {
  color: var(--gold);
  background: rgba(231, 201, 138, 0.1);
}

.toolbar-collapse-btn.is-collapsed {
  transform: rotate(-90deg);
}

.toolbar-collapsible {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar .btn {
  padding: 4px 9px;
}

.toolbar-collapsible.is-collapsed {
  display: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.popout {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.popout-caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  vertical-align: middle;
}

.btn-caret {
  padding-left: 6px;
  padding-right: 8px;
}

.split-btn > .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-btn > .btn-caret {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-color: transparent;
  margin-left: -1px;
}

.popout-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  min-width: 188px;
  z-index: 60;
  display: none;
  overflow: visible;
  padding: 4px 0;
}

.popout-nested {
  display: block;
  width: 100%;
  position: relative;
}

.popout-nested > [data-popout-toggle] {
  box-sizing: border-box;
}

.popout-submenu {
  top: 0;
  left: calc(100% + 4px);
  right: auto;
}

.popout-caret-end {
  margin-left: auto;
  border-left: 5px solid currentColor;
  border-right: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.popout-end .popout-menu {
  left: auto;
  right: 0;
}

.popout.open > .popout-menu {
  display: block;
}

.popout-heading {
  margin: 6px 12px 2px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.popout-heading:first-child {
  margin-top: 2px;
}

.popout-item,
.popout-menu .tab-btn,
.popout-menu .add-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--cream-dim);
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
}

.popout-item:hover,
.popout-menu .tab-btn:hover,
.popout-menu .add-menu-item:hover {
  background: var(--kimi-color-hover);
  color: var(--gold);
}

.popout-menu .tab-btn.is-active,
.popout-item.is-active,
.popout-item.is-on {
  color: var(--cream);
  background: var(--kimi-color-hover);
  font-weight: 500;
}

.axiom-studio.is-giving #popout-plan,
.axiom-studio.is-giving #popout-share {
  display: none;
}

.tab-group-label {
  margin-left: 8px;
  margin-right: 2px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.tab-group-label:first-child {
  margin-left: 0;
}

.tab-btn kbd {
  display: inline-block;
  min-width: 1.1em;
  margin-right: 4px;
  padding: 0 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--kimi-font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}

.tab-btn.is-active kbd {
  color: var(--gold);
  border-color: rgba(231, 201, 138, 0.35);
}

.tab-btn {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--cream);
  background: var(--kimi-color-hover);
}

.tab-btn.is-active {
  color: var(--cream);
  background: var(--kimi-color-hover);
  border-color: var(--line);
  font-weight: 500;
}

.add-menu {
  position: relative;
}

.add-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  min-width: 180px;
  z-index: 50;
  display: none;
  overflow: hidden;
}

.add-menu.open .add-menu-dropdown {
  display: block;
}

.add-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--cream-dim);
  cursor: pointer;
}

.add-menu-item:hover {
  background: var(--kimi-color-hover);
  color: var(--gold);
}

.time-display {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: center;
}

input[type="range"]#scrubber {
  width: 96px;
  height: 4px;
  padding: 0;
  accent-color: var(--gold);
}

.dur-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: auto;
}

.dur-label input {
  width: 4.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 0.25rem 0.4rem;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

.main-body {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.dock-bottom {
  display: none;
  flex-direction: row;
  flex-shrink: 0;
  height: 220px;
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
  overflow: hidden;
}

.dock-bottom:has(.float-panel.is-open) {
  display: flex;
}

.dock-bottom .float-panel {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.dock-bottom .float-panel:last-child {
  border-right: 0;
}

.dock-bottom .float-panel-body {
  flex-direction: row;
  flex-wrap: wrap;
}

.dock-bottom .sidebar-body,
.dock-bottom .inspector-body {
  overflow-y: auto;
}

.panel-dock {
  width: 92px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px;
  background: var(--bg-alt);
  border-right: 1px solid var(--line);
}

/* Hidden by default (desktop/tablet keep the dock permanently visible);
   the phone breakpoint below is the only place this becomes display:flex. */
.panel-dock-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--cream-dim);
  cursor: pointer;
}

.panel-dock-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.panel-dock-btn {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 4px;
  cursor: pointer;
}

.panel-dock-btn:hover,
.panel-dock-btn.is-active {
  color: var(--gold);
  border-color: rgba(231, 201, 138, 0.45);
  background: rgba(231, 201, 138, 0.08);
}

.panel-dock-btn--accent {
  color: var(--bg);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
  margin-bottom: 4px;
}

.panel-dock-btn--accent:hover {
  color: var(--bg);
  background: var(--gold);
  filter: brightness(1.08);
}

#dock-add-menu {
  display: block;
  width: 100%;
}

#dock-add-menu .popout-menu {
  left: calc(100% + 6px);
  top: 0;
}

.float-panel-empty-hint {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--cream-dim);
}

.axiom-studio.is-giving .panel-dock,
.axiom-studio.is-giving .float-panel {
  display: none !important;
}

.side-column {
  display: flex;
  flex-direction: column;
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg-alt);
  transition: width 0.15s ease;
}

.side-column.has-open {
  width: 300px;
}

#side-column-left.has-open {
  border-right: 1px solid var(--line);
}

#side-column-right.has-open {
  border-left: 1px solid var(--line);
}

.axiom-studio.is-giving .side-column,
.axiom-studio.is-giving .dock-bottom,
.axiom-studio.is-giving .float-panel[data-dock="float"] {
  display: none !important;
}

.float-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-alt);
}

.float-panel.is-open {
  display: flex;
  flex: 1;
}

.float-panel[data-dock="float"].is-open {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  max-height: 70vh;
}

.dock-picker .btn-icon {
  min-width: 26px;
  min-height: 26px;
  padding: 4px;
}

.dock-picker-menu {
  min-width: 100px;
}

.dock-picker-menu .popout-item.is-active {
  color: var(--gold);
}

.float-panel.is-open.is-collapsed {
  flex: 0 0 auto;
}

.float-panel + .float-panel {
  border-top: 1px solid var(--line);
}

.float-panel.is-collapsed .float-panel-body {
  display: none;
}

.float-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 6px 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  user-select: none;
}

.float-panel-head span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.float-panel-head .btn-icon {
  min-width: 26px;
  min-height: 26px;
  padding: 4px;
}

.float-panel-head .btn-icon[data-float-collapse].is-active svg {
  transform: rotate(-90deg);
}

.float-panel-head .btn-icon svg {
  transition: transform 0.15s ease;
}

.float-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-body,
.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  min-height: 0;
}

#popout-settings {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 4px 0 0;
  border-top: 1px solid var(--line);
}

#popout-settings .settings-toggle {
  width: 100%;
  justify-content: flex-start;
  padding: 6px;
}

#popout-settings .settings-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#popout-settings .settings-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.popout-up .popout-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.block-card {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 6px;
  cursor: pointer;
  background: var(--bg-card);
}

.block-card:hover {
  border-color: rgba(231, 201, 138, 0.25);
}

.block-card.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(231, 201, 138, 0.2);
  margin-bottom: 10px;
  padding-bottom: 14px;
}

.block-card.is-now {
  box-shadow: inset 3px 0 0 var(--gold);
}

.block-card.is-collapsed {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 10px;
  border-color: rgba(231, 201, 138, 0.08);
}

.block-card.is-collapsed:hover {
  background: rgba(231, 201, 138, 0.06);
  border-color: rgba(231, 201, 138, 0.25);
}

.block-card.is-collapsed .block-kind {
  margin: 0;
  flex-shrink: 0;
}

.block-collapsed-title {
  margin: 0;
  font-size: 12.5px;
  color: var(--cream-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.block-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 0 0 4px;
}

.block-title-input,
.block-body-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--cream);
  padding: 2px 0;
  resize: none;
}

.block-title-input {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
}

.block-body-input {
  font-size: 12px;
  color: var(--cream-dim);
  min-height: 40px;
}

.block-card.is-reading .block-body-input {
  display: none;
}

.preview {
  margin-top: 6px;
  font-size: 12px;
  color: var(--cream);
  overflow-x: auto;
  cursor: text;
}

.preview:empty {
  display: none;
}

.block-card.is-reading .preview {
  margin-top: 2px;
}

.vis-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--cream-dim);
}

.vis-list-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
}

.vis-list-label:hover,
.vis-list-label:focus {
  background: var(--bg);
  outline: none;
}

.extra-curves {
  gap: 4px;
}

.extra-curve-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.extra-curve-row input {
  flex: 1;
  min-width: 0;
}

.vis-ctl {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.65;
}

.vis-ctl:hover {
  opacity: 1;
  background: var(--line);
}

.vis-ctl:disabled {
  opacity: 0.2;
  cursor: default;
}

.vis-list-item.is-hidden {
  opacity: 0.5;
}

.vis-list-item.is-locked .swatch {
  box-shadow: 0 0 0 1px var(--gold);
}

.vis-dup {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
}

.vis-dup:hover {
  opacity: 1;
  background: var(--line);
}

.vis-list-item:hover,
.vis-list-item.is-active {
  background: var(--kimi-color-hover);
  color: var(--cream);
}

.scene-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--cream-dim);
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.scene-item:hover {
  border-color: var(--line);
}

.scene-item.is-active {
  border-color: var(--gold);
  background: rgba(234, 217, 174, 0.08);
  color: var(--cream);
}

.scene-item-num {
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 5px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.scene-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bean-live-status {
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.bean-live-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bean-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e5484d;
  flex-shrink: 0;
  animation: bean-live-pulse 1.4s infinite;
}

@keyframes bean-live-pulse {
  50% { opacity: 0.35; }
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--gold);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

.panel {
  display: none;
  height: 100%;
  min-height: 0;
}

.panel.is-active {
  display: flex;
  flex-direction: column;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: var(--stage-fill);
}

.stage-slot {
  flex: 1;
  min-height: 0;
  display: flex;
  min-width: 0;
  position: relative;
  overflow: auto;
}

.stage-slot #stage-frame {
  flex: 1;
  min-width: 0;
  transform-origin: center center;
}

.stage-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 12;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: calc(100% - 16px);
  padding: 3px 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--cream);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}

html[data-theme="cream"] .stage-zoom {
  background: rgba(243, 234, 216, 0.92);
  color: #0b0f1a;
}

.stage-zoom-btn {
  width: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Hidden by default (desktop/tablet keep the toolbar permanently
   expanded); the phone breakpoint below is the only place this shows. */
.stage-zoom-toggle {
  display: none;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.stage-zoom-btn.is-active {
  background: rgba(231, 201, 138, 0.28);
  color: var(--gold, #e7c98a);
}

#btn-zoom-in,
#btn-zoom-out {
  font-size: 14px;
  min-width: 22px;
  padding: 0;
}

.stage-zoom-split {
  width: 1px;
  height: 14px;
  background: currentColor;
  opacity: 0.25;
  margin: 0 2px;
}

.transport-split {
  width: 1px;
  height: 14px;
  background: currentColor;
  opacity: 0.25;
  margin: 0 4px;
}

.stage-zoom-btn:hover {
  background: rgba(231, 201, 138, 0.2);
}

.stage-zoom-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.stage-zoom-btn:disabled:hover {
  background: transparent;
}

.color-swatch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  padding: 0;
}

.color-swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(231, 201, 138, 0.45);
  background: #080b14;
}

.color-grid-menu {
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px;
  min-width: 176px;
}

/* .popout-menu's base rule is display:none, shown via
   .popout.open > .popout-menu { display:block } - that rule wins on
   specificity while closed, but ties with a plain .color-grid-menu
   { display:grid } and loses to source order, which made this render
   permanently visible regardless of open state. Grid layout needs its
   own display, so it's scoped to the same .open state here instead. */
.popout.open > .color-grid-menu {
  display: grid;
}

.color-grid-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  padding: 0;
}

.color-grid-swatch:hover {
  border-color: rgba(231, 201, 138, 0.6);
}

.color-grid-swatch.is-active {
  border: 2px solid var(--gold);
}

.color-grid-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  cursor: pointer;
  overflow: hidden;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}

.color-grid-custom input {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  cursor: pointer;
  opacity: 0;
}

.board-paper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 0.5rem;
}

.board-paper-row input[type="color"] {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.board-paper-dot {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.board-paper-dot.is-active {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.canvas-wrap.is-light-paper .coord {
  color: rgba(11, 15, 26, 0.45);
}

#canvas-panel.frame-916 .stage-slot {
  justify-content: center;
  align-items: center;
  background: #05070d;
  container-type: size;
  overflow: hidden;
}

#canvas-panel.frame-916 #stage-frame {
  flex: none;
  width: min(100cqw, calc(100cqh * 9 / 16));
  height: min(100cqh, calc(100cqw * 16 / 9));
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  outline: 1px solid rgba(231, 201, 138, 0.22);
  box-shadow: 0 0 0 1px rgba(11, 15, 26, 0.8);
}

.axiom-studio.is-giving #canvas-panel {
  position: relative;
}

.axiom-studio.is-giving .stage-slot {
  min-height: 0;
  padding-bottom: 52px;
}

.axiom-studio.is-giving .timeline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52px;
  z-index: 11;
  background: rgba(11, 15, 26, 0.9);
  border-top: 1px solid var(--line);
}

.axiom-studio.is-giving .timeline-canvas-wrap,
.axiom-studio.is-giving .timeline-bar .hint {
  display: none;
}

.axiom-studio.is-watch #btn-rec,
.axiom-studio.is-watch #popout-share,
.axiom-studio.is-watch #popout-plan,
.axiom-studio.is-watch .panel-dock,
.axiom-studio.is-watch #btn-stage-move,
.axiom-studio.is-watch #btn-stage-pen,
.axiom-studio.is-watch #btn-stage-erase,
.axiom-studio.is-watch #btn-ink-undo,
.axiom-studio.is-watch #btn-ink-redo,
.axiom-studio.is-watch [data-pen-width],
.axiom-studio.is-watch [data-shape],
.axiom-studio.is-watch #btn-stage-graph,
.axiom-studio.is-watch #btn-stage-sketch,
.axiom-studio.is-watch #btn-stage-reset,
.axiom-studio.is-watch #popout-board-color,
.axiom-studio.is-watch #popout-pen-color,
.axiom-studio.is-watch .stage-zoom-split,
.axiom-studio.is-watch [data-sketch-graph],
.axiom-studio.is-watch #popout-ink,
.axiom-studio.is-watch [data-visual] {
  display: none;
}

.btn-graph-speed {
  min-width: 5.4rem;
}

#main-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#main-canvas.is-pen,
#main-canvas.is-shape {
  cursor: crosshair;
}

#main-canvas.is-erase {
  cursor: cell;
}

#main-canvas.is-lasso {
  cursor: crosshair;
}

.live-pulse {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(6px);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--cream);
  z-index: 11;
}

.live-pulse[hidden] {
  display: none;
}

.live-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ff5a5a;
  animation: bean-live-pulse 1.6s ease-in-out infinite;
}


#main-canvas.is-move {
  cursor: grab;
}

#main-canvas.is-panning {
  cursor: grabbing;
}

.overlay-eq {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(6px);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 18px;
  color: var(--cream);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  cursor: grab;
  z-index: 10;
}

.overlay-note {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(6px);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--cream-dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  max-width: 80%;
  text-align: center;
  cursor: grab;
  z-index: 10;
}

.overlay-caption {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 10px;
  transform: none;
  background: rgba(10, 14, 26, 0.82);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--cream);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 11;
}

.canvas-wrap.has-caption .overlay-note {
  bottom: 58px;
}

.overlay-eq.is-visible,
.overlay-note.is-visible {
  pointer-events: auto;
}

.overlay-caption.is-visible {
  opacity: 1;
}

.overlay-eq.is-dragging,
.overlay-note.is-dragging,
.pip-camera.is-dragging,
.stage-web-wrap.is-dragging {
  cursor: grabbing;
  opacity: 1;
}

.coord {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 11px;
  color: rgba(243, 234, 216, 0.35);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.stage-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(243, 234, 216, 0.3);
  pointer-events: none;
  margin: 0;
  white-space: nowrap;
}

.axiom-studio.is-giving .stage-hint,
.stage-hint.is-hidden {
  display: none;
}

.param-panel {
  position: absolute;
  top: 8px;
  left: 8px;
  right: auto;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--cream-dim);
  display: none;
  min-width: 220px;
  max-width: min(420px, calc(100% - 24px));
  z-index: 13;
  pointer-events: auto;
}

.param-panel.visible {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-panel.is-collapsed {
  min-width: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
}

.param-panel-tab {
  display: inline-flex;
  align-items: center;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream-dim);
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  max-width: min(320px, calc(100vw - 32px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.param-panel-tab:hover {
  color: var(--gold);
  border-color: rgba(231, 201, 138, 0.45);
}

.graph-chip-head {
  justify-content: flex-end;
  gap: 0;
}

.graph-chip-expr {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--cream);
  font-family: var(--font-display, Georgia, serif);
}

.graph-chip-expr input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 15, 26, 0.7);
  color: var(--cream);
  font: inherit;
  font-size: 13px;
  padding: 4px 8px;
}

.graph-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.graph-chip-row label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.graph-chip-row input[type="number"] {
  width: 3.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 15, 26, 0.7);
  color: var(--cream);
  font: inherit;
  padding: 3px 6px;
}

.axiom-studio.is-watch .param-panel {
  display: none;
}

.pip-camera:not(.is-live) {
  display: none;
}

.timeline {
  height: 168px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
  display: flex;
  flex-direction: column;
}

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  min-height: 40px;
}

.timeline-bar .hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#timeline-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.code-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.code-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
}

.code-toolbar select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 6px 8px;
}

.code-area {
  display: flex;
  flex: 1;
  min-height: 0;
}

.code-input,
.code-output {
  flex: 1;
  background: #080b14;
  border: none;
  padding: 12px;
  font-family: var(--kimi-font-mono);
  font-size: 13px;
  line-height: 1.6;
  outline: none;
}

.code-input {
  color: var(--cream);
  border-right: 1px solid var(--line);
  resize: none;
}

.code-output {
  color: var(--muted);
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
}

.concept-svg {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.concept-hint {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.panel[data-panel="concept"].is-active {
  flex-direction: column;
}

.panel[data-panel="saved"].is-active {
  flex-direction: column;
  overflow: auto;
}

.saved-library {
  padding: 16px;
  max-width: 720px;
}

.saved-library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.saved-library #btn-saved-save {
  margin: 8px 0 4px;
}

.saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.saved-item.is-current {
  border-color: var(--gold);
}

.saved-title {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 2px 4px;
}

.saved-title:focus {
  outline: 1px solid var(--gold);
  border-radius: 4px;
}

.saved-meta {
  font-size: 11px;
  color: var(--muted, var(--cream-dim));
  white-space: nowrap;
}

.saved-actions {
  display: flex;
  gap: 2px;
}

.export-preview {
  padding: 16px;
  overflow: auto;
}

.export-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.record-face-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--cream-dim);
  margin: 8px 0;
  cursor: pointer;
}

#btn-record-video-stop {
  margin-top: 6px;
}

.video-record-status {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--cream-dim);
}

.video-record-status.is-recording {
  color: #e85a5a;
}

.field {
  display: block;
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--cream);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 4px;
}

.dictate-status {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  min-height: 32px;
}

.dictate-status.active {
  color: var(--gold);
}

.stage-web-wrap {
  position: absolute;
  inset: 10%;
  z-index: 35;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.stage-web-drag {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 36;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  color: var(--cream-dim);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.stage-web-drag svg {
  width: 14px;
  height: 14px;
}

.stage-web-drag:hover,
.stage-web-drag:active {
  color: var(--gold);
  cursor: grabbing;
}

.stage-web-wrap:not([hidden]) {
  display: block;
}

.stage-web-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 36;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  color: var(--cream-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.stage-web-close svg {
  width: 12px;
  height: 12px;
}

.stage-web-close:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.stage-web-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 14px;
  background: #fff;
}

.quiz-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 26, 0.92);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 24px;
}

.quiz-overlay.active {
  display: flex;
}

.quiz-q {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--cream);
  margin-bottom: 16px;
  text-align: center;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.quiz-choice {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--cream-dim);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.quiz-choice:hover {
  border-color: var(--gold);
  color: var(--cream);
}

.quiz-choice.correct {
  border-color: var(--gold);
  background: rgba(231, 201, 138, 0.14);
  color: var(--gold);
}

.quiz-choice.wrong {
  border-color: #ffb4a2;
  color: #ffb4a2;
}

.toast {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--cream-dim);
  z-index: 30;
  display: none;
  max-width: 260px;
}

.toast.active {
  display: block;
}

.pip-camera {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  z-index: 8;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(231, 201, 138, 0.45);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  background: #080b14;
  cursor: grab;
}

.pip-camera:active {
  cursor: grabbing;
}

.pip-camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}

.pip-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: linear-gradient(160deg, #101523, #141a2c);
  color: var(--gold);
  pointer-events: none;
}

.pip-placeholder svg {
  width: 52px;
  height: 52px;
}

.pip-placeholder span {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pip-camera.is-live .pip-placeholder {
  display: none;
}

.canvas-wrap.layout-camera #main-canvas {
  position: absolute;
  width: 220px;
  height: 124px;
  right: 0.85rem;
  bottom: 0.85rem;
  top: auto;
  left: auto;
  border-radius: 14px;
  border: 2px solid rgba(231, 201, 138, 0.35);
  z-index: 9;
  cursor: grab;
}

.canvas-wrap.layout-camera #pip-camera {
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
  cursor: default;
  z-index: 1;
  display: block;
}

.device {
  width: min(220px, 100%);
  margin: 0.4rem auto 0;
  aspect-ratio: 9 / 16;
  border: 1px solid rgba(231, 201, 138, 0.35);
  border-radius: 22px;
  overflow: hidden;
  background: #000;
  padding: 8px;
}

.device iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 14px;
  background: #fff;
}

.prompt-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: var(--bg);
  margin-bottom: 0.5rem;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  place-items: center;
  z-index: 20;
}

/* Same bug class as .axiom-cloud-panel: display set unconditionally on
   the bare class beats the browser's native [hidden]{display:none}, so
   Close never actually closed it  -  it just sat there covering (and
   z-index-blocking clicks on) whatever was underneath, including part of
   the topbar's icon buttons. */
.sheet:not([hidden]) {
  display: grid;
}

.sheet-panel {
  width: min(680px, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.account-panel {
  max-height: min(88vh, 720px);
  overflow: auto;
}

.account-panel .axiom-role-badge {
  margin: 0 0 0.4rem;
  display: inline-block;
}

.account-h {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cream);
  margin: 1.15rem 0 0.45rem;
}

.account-panel .btn {
  margin-bottom: 0.35rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0.7rem;
}

.theme-swatch {
  min-height: 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg-alt);
  color: var(--cream);
  font-size: 11px;
  cursor: pointer;
}

.theme-swatch.is-active {
  border-color: var(--gold);
}

.theme-dots {
  display: flex;
  gap: 4px;
}

.theme-dots i {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.font-scale {
  display: flex;
  gap: 8px;
  margin-top: 0.4rem;
}

.boot-error {
  position: fixed;
  z-index: 50;
  left: 1rem;
  right: 1rem;
  top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #3a1d1a;
  color: #ffb4a2;
  border: 1px solid rgba(255, 180, 162, 0.4);
}

.axiom-impersonation-banner {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  right: 0;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: #4a2a12;
  color: #ffcf9e;
  border-bottom: 1px solid rgba(255, 207, 158, 0.4);
  font-size: 13px;
}

.axiom-impersonation-banner:not([hidden]) {
  display: flex;
}

.axiom-impersonation-banner #btn-exit-impersonation {
  min-width: auto;
  padding: 2px 12px;
}

.katex {
  color: var(--cream);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- Staff sign-in gate ---- */

#axiom-gate {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--bg);
}

#axiom-gate .axiom-gate-card {
  width: 100%;
  max-width: 22rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem 1.35rem;
  color: var(--cream);
}

#axiom-gate .axiom-gate-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

#axiom-gate .axiom-gate-brand .mark {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1.4rem;
}

#axiom-gate .axiom-gate-brand .kicker {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

#axiom-gate .axiom-gate-brand .wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

#axiom-gate .axiom-gate-copy {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--cream-dim);
}

#axiom-gate .axiom-gate-error {
  margin: -0.5rem 0 0.85rem;
  font-size: 0.82rem;
  color: #ff9d8a;
}

#axiom-gate .axiom-gate-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.35rem;
}

#axiom-gate input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
  box-sizing: border-box;
}

#axiom-gate input:focus {
  outline: none;
  border-color: var(--gold);
}

.axiom-role-badge {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  margin-left: 0.5rem;
}

/* ---- Cloud panel ---- */

.axiom-cloud-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 22rem;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 1px solid var(--line);
  z-index: 500;
  flex-direction: column;
  color: var(--cream);
}

/* display:flex on the class alone beats the browser's native
   [hidden]{display:none} (author styles win over UA styles regardless of
   specificity), so the panel never actually closed  -  Close/X just set an
   attribute with no visible effect. Only apply flex when NOT hidden. */
.axiom-cloud-panel:not([hidden]) {
  display: flex;
}

.axiom-cloud-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.axiom-cloud-panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.axiom-cloud-panel-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
  flex: 1;
}

.axiom-cloud-panel-body h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1.25rem 0 0.6rem;
}

.axiom-cloud-status {
  min-height: 1.2rem;
  font-size: 0.82rem;
  color: var(--gold);
  margin: 0.5rem 0 0;
}

.axiom-cloud-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.axiom-cloud-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}

.axiom-cloud-item button {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.axiom-cloud-item .axiom-cloud-delete {
  color: #e85a5a;
}

.axiom-cloud-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.axiom-cloud-share-row {
  display: flex;
  gap: 0.4rem;
}

.axiom-cloud-share-row input,
.axiom-cloud-share-row select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--cream);
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
}

.axiom-cloud-item .axiom-role-tag {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---- AI-assist buttons on block cards ---- */

.block-ai-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.btn-mini {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream-dim);
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-mini:hover {
  border-color: var(--gold);
  color: var(--cream);
}

.btn-mini.is-active {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-mini:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-mini.is-error {
  border-color: #e85a5a;
  color: #e85a5a;
}

.vis-presets {
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.vis-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.vis-3d-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted, #9aa5b1);
  cursor: pointer;
}

/* ---- Sketch-to-LaTeX modal ---- */

#axiom-sketch-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 26, 0.85);
  padding: 1.25rem;
}

.axiom-sketch-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  max-width: 90vw;
}

.axiom-sketch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.axiom-sketch-lead {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted, #c8bfa8);
  max-width: 40rem;
}

#axiom-sketch-canvas {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
  display: block;
  max-width: 100%;
}

.axiom-sketch-status {
  min-height: 1.2rem;
  font-size: 0.82rem;
  color: var(--gold);
  margin: 0.6rem 0 0;
}

.axiom-sketch-engine {
  display: flex;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted, #9aa5b1);
}

.axiom-sketch-engine label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.axiom-sketch-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------------
 * Responsive: tablet is the priority secondary target (phone is a
 * baseline "works, not squeezed to uselessness" tier, not a full
 * from-scratch phone redesign). Desktop styles above are untouched.
 * ------------------------------------------------------------------- */

/* Tablet (portrait tablets and small laptops): keep the 3-column
   editor layout, just narrower so it still fits without the canvas
   getting crushed to nothing when a side column is open. */
@media (max-width: 900px) {
  .side-column.has-open {
    width: 240px;
  }

  .panel-dock {
    width: 76px;
  }

  .panel-dock-btn {
    font-size: 10px;
    padding: 7px 3px;
  }

  .topbar-modes > .popout > .btn {
    min-width: 4.4rem;
    font-size: 0.85rem;
  }

  .topbar-title {
    min-width: 0;
  }

  .stage-zoom-btn {
    min-height: 30px;
    padding: 0 8px;
  }
}

/* Phone: side columns become full-height overlay drawers instead of
   squeezing the canvas, the top bar's brand mark hides to make room
   for the title, and touch targets grow. */
@media (max-width: 640px) {
  .topbar {
    padding: 6px 8px;
    gap: 6px;
  }

  .brand {
    display: none;
  }

  .topbar-title {
    font-size: 0.95rem;
  }

  .topbar-modes > .popout > .btn {
    min-width: 3.6rem;
    font-size: 0.8rem;
    padding: 6px 8px;
  }

  .panel-dock {
    width: 64px;
  }

  .panel-dock-btn {
    font-size: 9px;
    padding: 8px 2px;
  }

  .panel-dock-btn--accent {
    font-size: 11px;
  }

  .side-column {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 64px;
    z-index: 45;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.001);
  }

  #side-column-left.has-open,
  #side-column-right.has-open {
    width: min(86vw, 320px);
  }

  #side-column-right.has-open {
    left: auto;
    right: 0;
  }

  .stage-zoom {
    max-width: calc(100vw - 16px);
    gap: 6px;
  }

  .stage-zoom-btn {
    min-height: 34px;
    min-width: 34px;
    padding: 0 10px;
    font-size: 12px;
  }

  .tool-icon {
    width: 18px;
    height: 18px;
  }

  .color-swatch-btn {
    width: 34px;
  }

  .color-grid-menu {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .color-grid-swatch,
  .color-grid-custom {
    width: 34px;
    height: 34px;
  }

  .timeline-bar {
    flex-wrap: wrap;
    min-height: auto;
  }

  .topbar-transport {
    flex-wrap: wrap;
    gap: 6px;
  }

  .live-pulse,
  .stage-hint {
    display: none;
  }

  /* Multi-track Script/Canvas/Voice timeline is a fine-grained editing
     surface that doesn't work at phone width - transport controls
     (play/record/prev/next/speed) stay, the track rows hide. */
  .timeline-canvas-wrap {
    display: none;
  }

  .panel-dock-toggle {
    display: flex;
  }

  .axiom-studio.dock-collapsed .panel-dock,
  .axiom-studio.dock-collapsed .side-column {
    display: none;
  }

  .dock-bottom {
    height: 160px;
  }

  .dock-bottom .float-panel-body {
    flex-direction: column;
  }

  .float-panel[data-dock="float"].is-open {
    width: min(90vw, 320px) !important;
    left: 5vw !important;
    top: 10vh !important;
  }

  .axiom-studio.dock-collapsed .panel-dock-toggle svg {
    transform: rotate(180deg);
  }

  .stage-zoom-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .stage-zoom.is-collapsed > :not(.stage-zoom-toggle) {
    display: none;
  }
}
